[R] Newbie Question: Shifted Power Fit?

Bill Simpson wsi at gcal.ac.uk
Thu Aug 16 10:25:13 CEST 2001



> I have multiple sets of 2D data that are coming from
> distributions of the form:
> 
> y = A(x-C)^B     (Eq.1)
> 
> I am trying to estimate for each set the best values 
> of A, B, and C so that Eq.1 will be the best fit for
> the data. I guess that it should be easy to do, but
> I lack the experience :(
Do this:
 library(nls)
 ?nls
Here is an example
x<-3:13
y<-2*(x-3)^1.5  #fake perfect data
fit<-nls(y~a*(x-b)^c,start=list(a=2,b=3,c=1.5))

This gives:
Error in numericDeriv(form[[3]], names(ind), env) : 
        Missing value or an Infinity produced when evaluating the model
Maybe others here can say what is wrong.

I personally tend to use nlm() and minimize the sum of squared errors...

Once it works do summary(fit) to see the fit results.

Bill

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list