Dear R-list members,
Some months ago I wrote a message on the usage of gnls (nlme library) and here I come again.
Let me give an example:
I have a 10 year length-at-age data set of 10 fishes (see growth.dat at the end of this message) and I want to fit a von Bertalanffy growth model, Li= Linf*(1-exp(-k*(ti-t0))) where Li = length at age i, Linf= asymptotic length, k= curvature parameter, ti= age i, and t0= age of length 0.
I'd solved the problem using nls but the points are not independent. The length-at-age data are correlated for each fish because I'm following the growth history of each specimen.
Trying to use gnls I wrote to R-list and to Mr. Jose Pinheiro who kindly advised me on this matter. The problem was that using S-Plus he could fit the model and I, using R with the same commands, got an error message:
+ data=growth.dat, params= Linf +K + t0 ~ 1, start=list(Linf=500,K=0.2,t0=0),
+ control = list(returnObject = T), corr = corAR1(form=~fish|age))
Error in "[<-.factor"(*tmp*, , value = grpShrunk[revOrderShrunk]) :
Argument "i" is missing, with no default
If I use nls function I can estimate the parameters:
Formula: lt ~ Linf * (1 - exp(-K * (age - t0)))
Parameters:
Estimate Std. Error t value Pr(>|t|)
Linf 509.72841 7.93394 64.247 < 2e-16 ***
K 0.19888 0.00764 26.031 < 2e-16 ***
t0 0.29873 0.04462 6.696 1.4e-09 ***
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Residual standard error: 10.32 on 97 degrees of freedom
Correlation of Parameter Estimates:
Linf K
K -0.9631
t0 -0.6472 0.7827
Well, I would be grateful to receive any help.
Best regards,
Antonio Olinto
Fisheries Institute
Sao Paulo - BRASIL
-------------