I have this information:
A xo x y yo p_1 p_2 p_3 p_4 s1 s2 s3 s4
1 1.7 1.7 0.45 0.45 1 0 0 0 0.45 #N/A #N/A #N/A
1 1.7 2.7 2.49 0.45 1 0 0 0 0.45 #N/A #N/A #N/A
2 1.7 1.7 0.48 0.48 0 1 0 0 0.45 0.48 #N/A #N/A
2 1.7 2.7 3.49 0.48 0 1 0 0 0.45 0.48 #N/A #N/A
3 1.7 1.7 0.58 0.58 0 0 1 0 0.45 0.48 0.58 #N/A
3 1.7 2.7 2.19 0.58 0 0 1 0 0.45 0.48 0.58 #N/A
And I wanted to translate the following SAS script to R:
proc model data=five method=MARQUARDT maxiter=1000;
yo=p1S1+p2S2+...+p&maxi S&maxi;
y=yo*EXP(-(b12)*x**-(b13))/EXP(-(b12)*xo**-(b13))
fit y /converge=0.001 estdata=start outpredict out=resinicial outest=params dw dwprob;
outvars num_parc y yo x xo resid pred actual truque id;
run; %mend fits;
In R I am using the package min.pack doing the following:
library(minpack.lm)
Gfun=function(x,t,G0,t0){
y=yo*exp(-(x[1])*x^-(x[2]))/exp(-(x[1])*xo^-(x[2]))
return(y)
}
Yresid <- function(parS, yObs, x,yo,xo) { # Resíduos
YObs-Yfun(parS,x=x,yo=yo,xo=xo)
}
parStart=c(3.405398, 0.40278)
nls.out <- nls.lm(par=parStart, fn = Yresid, YObs = Y, X=X,Yo=Yo,Xo=Xo,
control = nls.lm.control(nprint=1,
ftol = .Machine$double.eps,
ptol = .Machine$double.eps,
maxfev=10000, maxiter = 500))
But I get the following error:
Error in t ^ - (x [2]): non-numeric argument to binary operator
and I also do not know how to indicate the function of yo=p1S1+p2S2+...+p&maxi S&maxi