Ines Naya
2010-Feb-15 21:58 UTC
[R] Variance functions in nlme: varFixed with nlme() function.
Dear R-help suscribers, I am doing a meta-analysis of sea urchin growth data in R. I am fitting a non-linear growth function using nlme(). Most of my observations are means, and I want to give them weights according to the number of individuals that were used to obtain those means (as I do not have standard deviations associated with all of them). According to the nlme help page and Pinheiro and Bates (2000), at least from what I was able to understand, you can do that by using the argument weights and defining a varFixed that in my case I understand it would be of the form varFixed(~1/numberofindividuals). When I try to do this, R throws this error (or warning) even in the most simple examples: In conLin$Xy * varWeights(object) : longer object length is not a multiple of shorter object length Doing this with a linear example and using function lme works fine. Trying other variance functions (e.g. varExp) works fine. Unfortunately, I do need non-linearity and that variance structure. Dr. Stephen Smith raised the same question in the S-news archive back in 2004 (http://www.biostat.wustl.edu/archives/html/s-news/2004-03/msg00094.html) with a very good example of what was happening but did not get any answers. Is it an implementation problem? Can it be solved someway? Any help or feedback would be really appreciated. Here is a dummy example to reproduce the problem using the Loblolly dataset: -------------------------------------------------------------------------------------------------------> fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc),data = Loblolly, fixed = Asym + R0 + lrc ~ 1, random = Asym ~ 1, start = c(Asym = 103, R0 = -8.5, lrc = -3.3)) Works fine> fm2 <- update(fm1, weights=varFixed(~age))There were 44 warnings (use warnings() to see them)> warnings()Warning messages: 1: In conLin$Xy * varWeights(object) : longer object length is not a multiple of shorter object length 2: In conLin$Xy * varWeights(object) : longer object length is not a multiple of shorter object length ... fm3 <- update(fm1, weights=varExp(~age)) Works fine ----------------------------------------------------------- R Settings: ----------------------------------------------------------- R version 2.10.1 (2009-12-14) in Linux (Ubuntu Karmic Koala 32 bits) package ?nlme? version 3.1-96 locale: "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C" Thanks in advance, In?s Naya ------------------------------------------------------------ inesnaya[at]gmail.com / inaya[at]udc.es Recursos Marinos y Pesquer?as Facultade de Ciencias Universidade da Coru?a A Coru?a - SPAIN Telf: (+34) 981167000 Ext. 2204 http://www.recursosmarinos.net