[R] weights in nls

Douglas Bates bates at stat.wisc.edu
Tue Sep 26 18:41:37 CEST 2000


Douglas Bates <bates at cs.wisc.edu> writes:

> In the meantime, you can use the approach that John Chambers and I
> describe in chapter 10 of "Statistical Models in S" (a.k.a. the white
> book) and write the model as a one sided formula giving the weighted
> residual.

I should have checked before I wrote that.  A one-sided formula
doesn't work.  You must use a vector of zeroes of the appropriate
length on the left hand side.

> library(nls)
> data(Puromycin)
> nls(rate ~ Vm * conc/(K + conc), data = Puromycin, weights = 1/conc, 
+    subset = state == "treated", start = c(Vm = 200, K = 0.05))
Nonlinear regression model
  model:  rate ~ Vm * conc/(K + conc) 
   data:  Puromycin 
          Vm            K 
212.68357970   0.06412103 
 residual sum-of-squares:  1195.449 
> nls(rep(0, length(conc)) ~ (rate - Vm * conc/(K + conc))* sqrt(conc), 
+   data = Puromycin, subset = state == "treated", start = c(Vm = 200, K = 0.05))
Nonlinear regression model
  model:  rep(0, length(conc)) ~ (rate - Vm * conc/(K + conc)) * sqrt(conc) 
   data:  Puromycin 
          Vm            K 
218.15162032   0.07471006 
 residual sum-of-squares:  137.4447 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list