[R] Weighted nls

Liaw, Andy andy_liaw at merck.com
Mon Jul 11 19:38:46 CEST 2005


Please do your homework, as the posting guide asks you to.  

1.  From the Example section of ?nls:

## weighted nonlinear regression
Treated <- Puromycin[Puromycin$state == "treated", ]
weighted.MM <- function(resp, conc, Vm, K)
{
    ## Purpose: exactly as white book p.451 -- RHS for nls()
    ##  Weighted version of Michaelis-Menten model
    ## ------------------------------------------------------------
    ## Arguments: 'y', 'x' and the two parameters (see book)
    ## ------------------------------------------------------------
    ## Author: Martin Maechler, Date: 23 Mar 2001, 18:48

    pred <- (Vm * conc)/(K + conc)
    (resp - pred) / sqrt(pred)
}

Pur.wt <- nls( ~ weighted.MM(rate, conc, Vm, K), data = Treated,
              start = list(Vm = 200, K = 0.1),
              trace = TRUE)

2.  This has been covered several times on this list.  Search the archive.

Andy

> From: Rundle, Daniel
> 
> Dear R Community,
>  
> I am attempting to perform a weighted non-linear least 
> squares fit.  It has already been noted that the weights 
> option is not yet implemented for the nls function, but no 
> one seems to offer any suggestions for getting around this 
> problem.  I am still curious if a) anyone has code they have 
> written which includes a weight options for nls, or b) if 
> there is another model which would allow least squares 
> fitting to a non-linear function.
>  
> Thank you for reading this,
>  
> Dan
> 
> ______________________________________________
> 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