[Rd] problems with nls?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Mar 5 09:49:16 CET 2009


I don't see why this is relevant to R-devel rather than R-help.

Your script must be very old: the NEWS for R 1.9.0 said

         Packages ctest, eda, modreg, mva, nls, stepfun and ts have been
         merged into stats, and lqs has been returned to MASS.

That's 5 years ago now.

Function nls() still exists, and is in the 'stats' package which is 
loaded in a default R session.

On Wed, 4 Mar 2009, per243 wrote:

> I need to make nonlinear regression with the posterior script, but how is the
> problem? I have error in library (nls), package 'nls' has been merged into
> 'stats'.

It was _not_ an error:

> library(nls)
Warning message:
package 'nls' has been merged into 'stats'

so if your script did not run something else was the error.  (We don't 
have the dataset, so cannot reproduce what you did.)

> I need help?
> What other forms I have to make nonlinear regression? and how I find to
> calculate statistics y residuals, scatterplot.

Please read 'An Introduction to R' and then a basic book on 
statistics with R.

>
> thanks
>
>
>
> SCRIPT
>
> ros<-read.table("Dataset.csv",header=T,sep=",")
> ros
> attach(ros)
>
>
> # preliminaries
>
> options(width=44)
> options(digits=3)
>
> ## Nonlinear Regression
>
> par(mfrow=c(1,2))
>
> attach(ros)
> plot(U1.7km, R, main="(a)")
>
>
> library(nls)
> mod1<-nls(R ~
> beta1*(U1.7km^beta2)+(Hm^beta3)),start=list(beta1=2.031,beta2=0.800,beta3=-0.255),
> trace = TRUE)
>
> summary(mod1)
> coef(mod1)
> coef(summary(mod1))
>
> lines(R, fitted.values(mod1), lwd=2)
>
> plot(R, residuals(mod1), type="b", main="(b)")
> abline(h=0, lty=2)


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list