[R] confidence intervals for nls or nls2 model
Francisco Mora Ardila
fmora at oikos.unam.mx
Wed May 16 03:29:56 CEST 2012
On Tue, 15 May 2012 20:33:02 -0400, David Winsemius wrote
> On May 15, 2012, at 8:08 PM, Francisco Mora Ardila wrote:
>
> > Hi all
> >
> > I have fitted a model usinf nls function to these data:
> >
> >> x
> > [1] 1 0 0 4 3 5 12 10 12 100 100 100
> >
> >> y
> > [1] 1.281055090 1.563609934 0.001570796 2.291579783 0.841891853
> > [6] 6.553951324 14.243274230 14.519899320 15.066473610 21.728809880
> > [11] 18.553054450 23.722637370
> >
> > The model fitted is:
> >
> > modellogis<-nls(y~SSlogis(x,a,b,c))
> >
> > It runs OK. Then I calculate confidence intervals for the actual
> > data using:
> >
> > dataci<-predict(as.lm(modellogis), interval = "confidence")
> >
> > BUt I don´t get smooth curves when plotting it, so I want to get
> > other "confidence
> > vectors" based on a new x vector by defining a new data to do
> > predictions:
> >
> > x0 <- seq(0,15,1)
> > dataci<-predict(as.lm(modellogis), newdata=data.frame(x=x0),
> > interval = "confidence")
> >
> > BUt it does not work:
>
> I am really getting tired of seeing the phrase "doesn't work". And on
> my machine it throws an error saying there is no as.lm function> This
> seemes to give "smooth results:
Sorry for that "doesn't work". Also, I forgot to say function as.lm() is in tha package
nls2, which also fit nls models.
>
> dataci<-predict(as.lm(modellogis), newdata=data.frame(x=x0), interval
> = "confidence")
>
> And notice that this message is in ?predict.nls
>
> interval
> "At present this argument is ignored.
Yeah, that´s why I´m using nls2 package
>
> > I get the same initial confidence interval
> >
> > Any ideas on how to get tconfidence and prediction intervals using
> > new X data on a
> > previous model?
> >
> > Thanks
> >
> > Francisco
> >
> >
> >
> > ----------------------
> > Francisco Mora Ardila
> > Estudiante de Doctorado
> > Centro de Investigaciones en Ecosistemas
> > Universidad Nacional Autónoma de México
> >
> > ______________________________________________
> > 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.
>
> David Winsemius, MD
> West Hartford, CT
----------------------
Francisco Mora Ardila
Estudiante de Doctorado
Centro de Investigaciones en Ecosistemas
Universidad Nacional Autónoma de México
More information about the R-help
mailing list