[R] How using the weights argument in nls2?

Gabor Grothendieck ggrothendieck at gmail.com
Thu Sep 2 23:08:40 CEST 2010


On Thu, Sep 2, 2010 at 11:09 AM, Ivan Allaman <ivanalaman at yahoo.com.br> wrote:
>
> Good morning gentlemen!
>
> How using a weighted model in nls2? Values with the nls are logical since
> values with nls2 are not. I believe that this discrepancy is due to I did
> not include the weights argument in nls2.
>

Just to follow up, nls2 was ignoring the weights argument.  This is
now fixed in the development version of nls2.  The weights and no
weights versions below give different residual sum of squares showing
that weights is not ignored:

library(nls2)
# grab development version
source("http://nls2.googlecode.com/svn/trunk/R/nls2.R")
BOD2 <- cbind(BOD, w = 1:6)
nls2(demand ~ a + b*Time, data = BOD2, start = c(a = 1, b = 1),
   weights = w, alg = "brute")

# compare against
nls2(demand ~ a + b*Time, data = BOD2, start = c(a = 1, b = 1),
   alg = "brute")

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list