[R] Problem with "nls" function

hammadi jbeli hammadi.jbeli at gmail.com
Tue Jan 26 02:22:10 CET 2010


Dear R users,
I have a response variable in a csv file called "y" and a matrix of
predictor variables in a csv file called "mat". I have used the function
"nls" I have specified the nonlinear relation between these variable.The
code I have witten is called Rprog which begins with the phrase:
L.minor.m1<-nls(Y~a ....etc..
The program when I execute the program, I obtain the following message:
L.minor.m1 file not found.
You find attached Rprog, y.csv and mat.csv.
Can you please help me, it is very important for my phd thesis.
Thanks in advance.
Hammadi.
-------------- next part --------------
mat<- read.csv(file="mat.csv",head=FALSE,sep=";")
y<-read.csv(file="y.csv",head=FALSE,sep=";")
Y=y[,1]
D_1=mat[,1]
D_2=mat[,2]
D_3=mat[,3]
D_4=mat[,4]
Y_1=mat[,5]
Y_2=mat[,6]
Y_3=mat[,7]
Y_4=mat[,8]
s_F=mat[,9]
s_G=mat[,10]
L.minor=data.frame(Y=Y,D_1=D_1,D_2=D_2,D_3=D_3,D_4=D_4,Y_1=Y_1,Y_2=Y_2,Y_3=Y_3,Y_4=Y_4,s_F=s_F,s_G=s_G)
stdS=1/(sd(s_F))
stdG=1/(sd(s_G))
L.minor.m1<-nls(Y~a_1_1*D_1+a_2_1*D_2+a_3_1*D_3+a_4_1*D_4+a_1_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_1+a_2_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_2+a_3_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_3+a_4_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_4+p_1_1*Y_1+p_2_1*Y_2+p_3_1*Y_3+p_4_1*Y_4+p_1_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_1+p_2_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_2+p_3_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_3

+p_4_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_4,start=list(a_1_1=0.0593,a_2_1=-0.0822,a_3_1=    0.0300
,a_4_1=-0.1259,a_1_2=-0.0477,gamma_1_F=0.5,c_1_F=-0.1555,gamma_2_F=0.5,c_2_F=-0.0292,a_2_2=  0.0873,a_3_2= -0.0567,a_4_2= 0.1443,p_1_1=-0.0297,p_2_1= 0.1865,p_3_1= -0.0776,p_4_1=0.5260,p_1_2=0.0075,gamma_1_G=0.1,c_1_G=-0.1555,gamma_2_G=0.3,c_2_G=-0.0545,p_2_2= -0.1911,p_3_2=0.0696,p_4_2= -0.4640), trace=TRUE)
summary(L.minor.m1)




















More information about the R-help mailing list