[R] [Help] Error when using nls

Yi-Min Huang ninerh at gmail.com
Sat Sep 29 18:14:13 CEST 2007


Thank you Charilaos, I think I misunderstood the 'selfStart'. After  
checking 'selfStart', I think I don't have the ability to create a  
selfStart object. I don't have good sense to guess the initial  
values. So I tried 'poor guess' by nls. But I got erroe message as:

Error in c * (ev^2) : non-numeric argument to binary operator


I don't understand what this means. If I take out 'c', and run nls  
with poor guess, I got error message as:

Error in nls(N ~ CSR/(1/(a + b * ev + (ev^2)) + CSR/(d + e * exp(f *  
ev))) -  :
	singular gradient

and a warning message of 'no staring values for some parameters'.

What should I do to correct the errors? Is there any way that can  
help me to guess the initial values?
I attached my R script and the data set I used. Any comment is  
appreciated. Thank you very much.



----------------------------------------------------
Yi-Min Huang
ninerh at gmail.com



On Sep 29, 2007, at 6:49 AM, Charilaos Skiadas wrote:

> 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
>
> ______________________________________________
> 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.



More information about the R-help mailing list