[R] nls weights warning message

From: Lisa Readdy <readdylj_at_googlemail.com>
Date: Thu, 31 Jul 2008 12:31:17 +0100


The following warning message occurs when running the nls on some data:



Warning message:
In is.na(wts) : is.na() applied to non-(list or vector) of type 'NULL'

and I would like to know what is causing it and how I can fix it.

As an example, the following, from Venables and Ripley, which does not produce the warning message and then on the data which does procude the warning message.


##Venables and rippley

library(MASS)
data(wtloss)
wtloss.st = c(b0=90, b1=95, th=120)
n1<-length(wtloss)
Weight=c(1,rep(0.1,n1-1))

wtloss.fm = nls(Weight ~ b0 + b1*2^(-Days/th), data=wtloss, start=wtloss.st, trace=T, weights=Weight )
wtloss.fm

##My data

y<-c(73,73,70,74,75,115,105,107,124,107,116,125,102,144,178,149,177,124,157,128,
169,165,186,152,181,139,173,151,138,181,152,188,173,196,180,171,188,174,198,172,
176,162,188,182,182,141,191,190,159,170,163,197)

x<-c(1,1,1,1,1,2,2,3,3,3,3,3,3,4,4,4,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,8,8,8, 8,8,8,8,8,8,8,9,9,9,9,9,11,12)

Data<-data.frame(cbind(y,x))

n2<-length(x)
weight<-c(1,rep(0.1,n2-1))

Ta<-min(Data$x)
Tb<-max(Data$x)
G.st<-c(k=0.005, g1=50,g2=550)


#no weights
growthFit<-nls(y~((g1)*exp((log(g2/g1))*(1-exp(-k*(x-Ta)))   /(1-exp(-k*(Tb-Ta))))), data=Data, start=G.st, trace=T)

#with weights
growthFit.wts<-nls(y~((g1)*exp((log(g2/g1))*(1-exp(-k*(x-Ta)))   /(1-exp(-k*(Tb-Ta))))), data=Data, start=G.st, trace=T, weights=weight)


Thanks in advance

Lisa

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 31 Jul 2008 - 11:50:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 Jul 2008 - 13:33:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive