[R] Comparing Von Bertalanffy Growth Curves

David L Carlson dcarlson at tamu.edu
Tue Sep 4 23:59:42 CEST 2012


Pretty hard to say since you did not give us all of your code:

> str(LMB)
'data.frame':   37 obs. of  3 variables:
 $ Age : int  1 2 3 5 1 2 3 4 1 2 ...
 $ MM  : num  156 296 326 375 181 ...
 $ Year: int  2005 2005 2005 2005 2006 2006 2006 2006 2007 2007 ...
> MMi=as.integer(MM) 
Error: object 'MM' not found
> Yearf=as.factor(Year) 
Error in is.factor(x) : object 'Year' not found
> Agei=as.integer(Age) 
Error: object 'Age' not found

So you left out an attach(LMB) at least. Then 

> attach(LMB)
> MMi=as.integer(MM) 
> Yearf=as.factor(Year) 
> Agei=as.integer(Age) 
> ( svCom <- vbStarts(MMi~Agei,data=LMB)) 
Error: could not find function "vbStarts"

Now you've left out loading one or more packages with library() commands.
I'll stop here. If you want help, provide "minimal, self-contained,
reproducible code."

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of April Lindeman
> Sent: Tuesday, September 04, 2012 1:43 PM
> To: r-help at r-project.org
> Subject: [R] Comparing Von Bertalanffy Growth Curves
> 
> 
> 
> 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/VonBertalanf
> fy.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
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list