[R] weighting in nls

Liaw, Andy andy_liaw at merck.com
Thu Jan 27 16:25:06 CET 2005


Can you show us the difference; i.e., what are the parameter estimates and
associated SEs from the two programs?  Even better, can you supply an
example data set?

[With is `trick' for weighted nls, you need to be careful with the output of
predict().]

Andy

> From: Robert Brown FM CEFAS
> 
> 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}}
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list