I have been currently assigned a work where I need to translate a SAS code to R. I have been able to successfully do 80% of it and now I am stuck at the part where PROC NLIN is used. From what I read, PROC NLIN is used to fit Non-Linear Models andI am not sure if the code is actually is doing that and hence, stuck at how to do it in R. The code is as follows -
proc nlin data=ds1 outest=estout;
parms ET= 0 f= 10.68;
E= f- R*(1-ET*M);
L = E*E;
model.like = sqrt(E*E);
by Name ;
run;
The sample data is as follows -
Name M R
Anna 0.5456231 4.118197
Anna 0.5359164 4.240243
Anna 0.541881 3.943975
Anna 0.5436047 3.822222
Anna 0.5522962 3.58813
Anna 0.5561487 3.513195
Anna 0.5423374 3.666507
Anna 0.525836 3.715371
Anna 0.5209941 3.805572
Anna 0.5304675 3.750689
Anna 0.5232541 3.788292
When I went through the pages on PROC NLIN in SAS help, the argument 'MODEL' is used to specify the equation but the code here doesn't have a model equation. Model.like is to specify the likelihood function (page 4316 - https://support.sas.com/documentation/cdl/en/statugnlin/61811/PDF/default/statugnlin.pdf) So what is this code doing? I am totally confused. I, initially felt that this can be done in R using nls() and I tried the following -
fit = nls(E~ f - R*(1-eta*M),sample, start=list(eta=0,phi=10.86)
,trace=T)
But I quickly realised this is wrong because the model didn't converge even after 5000 iterations. This is because, I don't have a column 'E' in my dataset. So, how is SAS doing it? Any help is appreciated!