[R] Question about fitting power

Liaw, Andy andy_liaw at merck.com
Wed Jan 25 19:38:49 CET 2006


The two methods are fitting different models.  With lm(), the model is

  y = a * x^b * error

or, equivalently,

  ln(y) = ln(a) + b * ln(x) + ln(error)

With nls(), the model is

  y = a * x^b + error

Thus you will get two different estimates.

Andy

From: Ana Quitério
> 
> Hi R users
> 
>  
> 
> I'm trying to fit a model y=ax^b.
> 
> I know if I made ln(y)=ln(a)+bln(x)  this is a linear regression.
> 
>  
> 
> But I obtain differente results with nls() and lm()
> 
>  
> 
> My commands are:   nls(CV ~a*Est^b, data=limiares, start 
> =list(a=100,b=0),
> trace = TRUE)  for nonlinear regression
> 
>                         and :  lm(ln_CV~ln_Est, 
> data=limiares) for linear
> regression
> 
>  
> 
>  
> 
> Nonlinear regression model:   a=738.2238151  and    b=-0.3951013 
> 
>  
> 
> Linear regression:   Coefficients:
> 
>                                 Estimate    Std. Error    t value
> Pr(>|t|)    
> 
> (Intercept)  7.8570224  0.0103680   757.8   <2e-16 ***
> 
> ln_Est      -0.5279412  0.0008658  -609.8   <2e-16 ***
> 
>  
> 
>  
> 
> I think it should be   a=exp("(Intercept)  ") = 
> exp(7.8570224) = 2583.815
> and b=ln_Est
> 
>  
> 
> Probably I'm wrong, but why??
> 
>  
> 
>  
> 
> Thanks in advance.
> 
>  
> 
> Ana Quiterio
> 
>  
> 
>  
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list