[R] Error using augPred with nlme grouped data
Pamela Allen
allen at zoology.ubc.ca
Mon Mar 24 01:59:37 CET 2008
Hello all,
I am having a problem using augPred after I have created an nlme object. My
data is 3933 rows long with no NA's, and is grouped with this function:
vanfem<-groupedData(mass~age.years|name, data=av.mex, labels=list(x="Age",
y="Mass"), units=list(x="(years)", y="(kg)"))
Under the grouping factor "name", this is a character column with 12 levels
(i.e. 12 animals that I have collected "mass" from over their "age.years",
both numeric columns). I create my nlsList object for the vonBertelanffy
growth curve using:
vanfemfunc<-function(age.years, A, lk, t0)
A*((1-exp(-exp(lk)*(age.years-t0)))^3)
vf.list<-nlsList(mass~vanfemfunc(age.years, A, lk, t0), data=vanfem,
start=c("A"=201.8, "lk"=-1.17, "t0"=-2.71))
and then my nlme with:
vf.nlme1<-nlme(vf.list)
Following the methods of Pinheiro and Bates (2000), I try and plot my
predicted values against my actual values by "name" using:
plot(augPred(vf.nlme1, level=0:1))
But it returns this error:
Error in `[[<-.data.frame`(`*tmp*`, nm, value = c(3L, 3L, 3L, 3L, 3L, :
replacement has 3933 rows, data has 12
I'm guessing this has something to do with my grouping factor "name", since
there are 12 levels (animals) in this column.
The only help file I could find about this problem suggested that I give all
of my data columns the class "NULL" and then re-run my nlme, but this did
not work. Any help would be much appreciated!
-Pam
Pamela Allen, MSc Candidate
University of British Columbia
Marine Mammal Research Unit, Fisheries Centre Vancouver, B.C. V6T 1Z4
(778) 835-5823
allen at zoology.ubc.ca
More information about the R-help
mailing list