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)
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)
I supose you are following the SAS formulation style. R has a different formulation style, such as: da <- expand.grid(A=factor(1:3), x=1:10) da$y <- as.numeric(da$A)*da$x/(1.2+da$x)+rnorm(da$x, 0, 0.1) m0 <- nls(y~Asym[A]*x/(Time[A]+x), data=da, start=list(Asym=c(1,2,3), Time=c(1,1,1))) summary(m0) At your disposal. Walmes. ----- ..oooO .................................................................................................. ..(....)... 0ooo... Walmes Zeviani ...\..(.....(.....)... Master in Statistics and Agricultural Experimentation ....\_)..... )../.... walmeszeviani at hotmail.com, Lavras - MG, Brasil ............ (_/............................................................................................ -- View this message in context: http://n4.nabble.com/problem-with-nls-function-tp1290020p1290034.html Sent from the R help mailing list archive at Nabble.com.
<quote> From: hammadi jbeli <hammadi.jbeli_at_gmail.com> Date: Tue, 26 Jan 2010 23:40:47 +0100 I have used R formulation style and I found this in some R documentations. </quote> Sorry, that makes no sense. I would recommend you go back to your original dataset and pick a very small subset of it--with only 2 variables, for example. Then try running nls on that, so at least your code line will be a manageable size. Also, as people regularly remind me :-), post a *small* but reproducible data set so we can see what sort of stuff you're feeding into these functions. {like, say, L.minor.m1<-nls(Y~a_1_1*D_1+a_1_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F)), start=list(a_1_1=0.0593,a_2_1=-0.0822),trace=TRUE) } Tho' I tend to suspect an attempt to fit that many independent exp(gamma)'s is doomed to failure. If you can explain what the underlying data represent, there may be a better, and vectorized, way to find a fit function. Carl