[R] Simple linear regression

Douglas Bates bates at stat.wisc.edu
Thu Jul 10 16:42:46 CEST 2003


Martin Maechler <maechler at stat.math.ethz.ch> writes:

> >>>>> "KKWa" == Ko-Kang Kevin Wang <kwan022 at stat.auckland.ac.nz>
> >>>>>     on Thu, 10 Jul 2003 23:00:00 +1200 (NZST) writes:
> 
>     KKWa> Try: ?lm
> 
> no.  see below
> 
>     KKWa> On 10 Jul 2003, Gorazd Brumen wrote:
> 
>     >> Date: 10 Jul 2003 12:54:46 +0200 From: Gorazd Brumen
>     >> <gbrumen at student.ethz.ch> To: R-help at stat.math.ethz.ch
>     >> Subject: [R] Simple linear regression
>     >> 
>     >> Dear all,
>     >> 
>     >> My friend wants to fit a model of the type
>     >> 
>     >> z = a x^n y^m + b,
>     >> 
>     >> where x, y, z are data and a, b, n, m are unknown
>     >> parameters.
>     >> 
>     >> How can he transform this to fit in the linear regression
>     >> framework?  Any help would be appreciated.
> 
> He can't.  When all 4   a, b, n, m  are parameters, this is a
> non-linear regression problem.  --> Function  nls()
> 
> Now, effectively 2 of the 4 are linear, 2 are non linear;
> such a problem is denoted as  `` partially linear least-squares ''
> In such a case it's quite important (for efficiency and
> inference reasons) to make use of this fact.
> 
>  ---> use  nls(...., method = "plinear" , ....)

I think it should be 'algorithm = "plinear"'

The full call would be something like

nls(z ~ cbind(x^n*y^m, 1), data = mydata, start=c(n = 1.0, m = 2.0),
    algorithm = "plinear")

Must the exponents n and m be positive?  If so, I recommend using the
logarithm of the exponents as the parameters in the optimization

nls(z ~ cbind(x^exp(logn)*y^exp(logm), 1), data = mydata,
   start=c(logn = 0., logm = log(2.0)),  algorithm = "plinear")




More information about the R-help mailing list