[R] Comparing Von Bertalanffy Growth Curves

April Lindeman aprillindeman at yahoo.com
Tue Sep 4 20:43:06 CEST 2012



I am trying to compare Vbert growth curves from several years of fish data. I am following the code provided by: http://www.ncfaculty.net/dogle/fishR/gnrlex/VonBertalanffy/VonBertalanffy.pdf. Specifically the section on VBGM Comparisons between groups. 
 
This code is pretty cut and dry. I am able to run it perfectly with the "fake" data that is provided. But when I run it with my own data I get stuck with this line: 
fitGen <- nls(vbGen,data=LMB,start=svGen)
 
I get this error code: Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model.

 
Does anyone know how to fix it? I have no missing values and do not know how to fix the infinity produced. 

Here is my data set: structure(list(Age = c(1L, 2L, 3L, 5L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), MM = c(155.79, 296.37, 325.77, 374.65, 181.46, 258.31, 321.88, 355.6, 139.75, 230.72, 319.61, 344.84, 130.92, 236.34, 290.53, 360.33, 400.61, 155.33, 240.87, 315.46, 345.05, 378.2, 134.71, 256.66, 333.71, 362.99, 381.46, 153.91, 217.21, 287.8, 357.28, 385.62, 222.25, 288.93, 294.05, 332.79, 367.39), Year = c(2005L, 2005L, 2005L, 2005L, 2006L, 2006L, 2006L, 2006L, 2007L, 2007L, 2007L, 2007L, 2008L, 2008L, 2008L, 2008L, 2008L, 2009L, 2009L, 2009L, 2009L, 2009L, 2010L, 2010L, 2010L, 2010L, 2010L, 2011L, 2011L, 2011L, 2011L, 2011L, 2012L, 2012L, 2012L, 2012L, 2012L)), .Names = c("Age", "MM", "Year"), class = "data.frame", row.names = c(NA, -37L)) 

 
In case it's helpful here is all my code before this point: 
str(LMB) 
MMi=as.integer(MM) 
Yearf=as.factor(Year) 
Agei=as.integer(Age) 
( svCom <- vbStarts(MMi~Agei,data=LMB)) 
( svGen <- lapply(svCom,rep,2) ) 
vbGen <- MMi~Linf[Yearf]*(1-exp(-K[Yearf]*(Age-t0[Yearf]))+error) 
fitGen <- nls(vbGen,data=LMB,start=svGen) 

 
Thank you, April




More information about the R-help mailing list