Dear Friends, I am seeking for any help on an error message in lme functions. I use mixed model to analyze a data with compound symmetric correlation structure. But I get an error message: "Error in corMatrix.corCompSymm(object) : NA/NaN/Inf in foreign function call (arg 1)". If I change the correlation structure to corAR1, then no error. I have no clue how to solve this problem. I would highly appreciate any help. Thanks in advance and looking forward to any help. JY I attached my data and codes here: # data: mytable mytrait myloc RIL A1 0.590950330 0 1 A2 -0.315469846 -1 2 A3 -0.265690115 0 3 A4 0.342885046 0 4 A5 0.007613402 1 5 A6 0.285997884 0 6 A7 0.333841975 0 7 A8 -0.599817735 -1 8 A9 0.242621036 0 9 A10 0.518959588 1 10 cs<-corCompSymm(0.5, form=~1|RIL, fixed=T) model<-lme(mytrait~myloc, data=mytable, random=~1|RIL, na.action=na.omit, correlation=cs) Error in corMatrix.corCompSymm(object) : NA/NaN/Inf in foreign function call (arg 1)
You need repeated measures for a random effect to make any sense. I modified your example as follows, and the error went away. > mytable$RIL2 <- rep(1:4, 1:4) > cs2 <- corCompSymm(value=0.5, form=~1|RIL2) > model2<-lme(mytrait~myloc, data=mytable, random=~1|RIL2, + correlation=cs2) (I've made similar mistakes and had great difficulty finding the problem.) spencer graves J.Fu wrote:> Dear Friends, > > I am seeking for any help on an error message in lme > functions. I use mixed model to analyze a data with > compound symmetric correlation structure. But I get an > error message: "Error in corMatrix.corCompSymm(object) : > NA/NaN/Inf in foreign function call (arg 1)". If I change > the correlation structure to corAR1, then no error. I have > no clue how to solve this problem. I would highly > appreciate any help. > Thanks in advance and looking forward to any help. > > JY > > > I attached my data and codes here: > > # data: mytable > mytrait myloc RIL > A1 0.590950330 0 1 > A2 -0.315469846 -1 2 > A3 -0.265690115 0 3 > A4 0.342885046 0 4 > A5 0.007613402 1 5 > A6 0.285997884 0 6 > A7 0.333841975 0 7 > A8 -0.599817735 -1 8 > A9 0.242621036 0 9 > A10 0.518959588 1 10 > > cs<-corCompSymm(0.5, form=~1|RIL, fixed=T) > model<-lme(mytrait~myloc, data=mytable, random=~1|RIL, > na.action=na.omit, correlation=cs) > > Error in corMatrix.corCompSymm(object) : NA/NaN/Inf in > foreign function call (arg 1) > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html-- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA spencer.graves at pdf.com www.pdf.com <http://www.pdf.com> Tel: 408-938-4420 Fax: 408-280-7915
p.s. You may also find useful the process I followed to diagnose this problem. 1. I copied your example into R and confirmed that I could replicate the error. 2. I read the documentation, invoked debug, and tried different things to isolate the problem. For example, I listed the code for corCompSymm. The documentation led me to "Initialize(cs)", which gave me the same error message. 3. Ultimately, I found in Pinhiero and Bates (2000) Mixed-Effects Models for S and S-Plus (Springer) an example that looked exactly like yours but did NOT produce the same error message to "Initialize". By comparing the example that worked with the superficially identical case that didn't, I found the difference. hope this helps. spencer graves ####################### You need repeated measures for a random effect to make any sense. I modified your example as follows, and the error went away.> mytable$RIL2 <- rep(1:4, 1:4) > cs2 <- corCompSymm(value=0.5, form=~1|RIL2) > model2<-lme(mytrait~myloc, data=mytable, random=~1|RIL2,+ correlation=cs2) (I've made similar mistakes and had great difficulty finding the problem.) spencer graves J.Fu wrote:> Dear Friends, > > I am seeking for any help on an error message in lme > functions. I use mixed model to analyze a data with > compound symmetric correlation structure. But I get an > error message: "Error in corMatrix.corCompSymm(object) : > NA/NaN/Inf in foreign function call (arg 1)". If I change > the correlation structure to corAR1, then no error. I have > no clue how to solve this problem. I would highly > appreciate any help. > Thanks in advance and looking forward to any help. > > JY > > > I attached my data and codes here: > > # data: mytable > mytrait myloc RIL > A1 0.590950330 0 1 > A2 -0.315469846 -1 2 > A3 -0.265690115 0 3 > A4 0.342885046 0 4 > A5 0.007613402 1 5 > A6 0.285997884 0 6 > A7 0.333841975 0 7 > A8 -0.599817735 -1 8 > A9 0.242621036 0 9 > A10 0.518959588 1 10 > > cs<-corCompSymm(0.5, form=~1|RIL, fixed=T) > model<-lme(mytrait~myloc, data=mytable, random=~1|RIL, > na.action=na.omit, correlation=cs) > > Error in corMatrix.corCompSymm(object) : NA/NaN/Inf in > foreign function call (arg 1) > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html-- Spencer Graves, PhD Senior Development Engineer PDF Solutions, Inc. 333 West San Carlos Street Suite 700 San Jose, CA 95110, USA spencer.graves at pdf.com www.pdf.com <http://www.pdf.com> Tel: 408-938-4420 Fax: 408-280-7915