[R] weighting in nls

Robert Brown FM CEFAS r.g.brown at cefas.co.uk
Thu Jan 27 15:55:10 CET 2005


I'm fitting nonlinear functions to some growth data but  I'm getting radically different results in R to another program (Prism). Furthermore the values from the other program give a better fit and seem more realistic.  I think there is a problem with the results from the r nls function. The differences only occur with weighted data so I think I'm making a mistake in the weighting. I'm following the procedure outlined on p 244 of MASS (or at least I'm trying to).

Thus, I'm using mean data with heteroscedasticity so I'm weighting by n/ variance, where the variance is well known from a large data set. This weighting factor is available as the variable 'novervar'.

The function is a von Bertalanffy curve of the form weight~(a*(1-exp(-b*(age-c))))^3.  Thus I'm entering the command in the form:

solb1wvb<-nls(~sqrt(novervar)*(weight-(a*(1-exp(-b*(age-c))))^3),data=solb1.na.rm,start=list(a=0.85,b=0.45,c=0.48))

Can anyone suggest what I'm doing wrong?  I seem to be folowing the instructions in MASS. I tried following the similar instructions on page 450 of the white book but these were a bit cryptic.

I'm using R 2.0.0 on a Windows 2000 machine

Regards,

Robert Brown


***********************************************************************************
This email and any attachments are intended for the named re...{{dropped}}




More information about the R-help mailing list