Re: [R] Weighted nls

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Tue 12 Jul 2005 - 03:38:46 EST


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@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
>
>
>



R-help@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 Received on Tue Jul 12 03:45:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:29 EST