[R] [Help] Error when using nls

Charilaos Skiadas cskiadas at gmail.com
Sat Sep 29 15:49:13 CEST 2007


On Sep 29, 2007, at 12:00 AM, Niner wrote:

> Hi,
>
>      I am a student of Earthquake Engineering, and am new to R.
> Currently I try to run nonlinear regression analysis by R. My data
> has three variables: X, Y, and Z. Z is a function of (X, Y). My R
> script is as below.

In general it is recommended that you provide reproducible code,  
typically using one of the built in data sets instead of a data set  
of your own that we have no access to.

> # call nls funciton
> out <- nls(Z~X/(1/(a+b*ev+c*(Y^2))+X/(d+e*exp(f*Y)))-g, data1,
> selfStart, trace=T)
>
>
> In total there are 59 sets of (X,Y,Z). When I run this script, I got
> the error message as:
>
> parameters without starting value in 'data': a, b, d, e, f, g
>
>
> I don't know what this means. Besides, I use "selfStart" option, such
> that the nls is supposed to run by finding the initial values of
> (a,b,c,d,e,f,g) itself. Why the nls asks me to give the starting  
> values?

"selfStart" is not an "option", it is a function which you would use  
to construct the self-starting object. Look at ?selfStart for an  
example on how to use it.
To the best of my understanding, you need to either:
1) provide starting values (what I would recommend, if you have a  
sense for the range), or
2) provide R with a mechanism for finding the starting values (via  
constructing a selfStart object, see ?selfStart), or
3) ask R to make very poor guesses, by leaving the start argument  
empty [  out <- nls(Z~X/(1/(a+b*ev+c*(Y^2))+X/(d+e*exp(f*Y)))-g,  
data1, trace=T)   ]
which has a high chance of choking out on you. In an example I just  
tried, R set all the parameter values to 1.

> What should I do next? Does anyone can explain the meaning of the
> error message?
> Any comment is appreciated. Thanks a lot.
>
>
> Regards,
> Niner
> ----------------------------------------------------
> Niner, Seattle
> ninerdummy at gmail.com
>

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College



More information about the R-help mailing list