[R] nls, nlrq, and box-cox transformation
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Nov 20 15:56:22 CET 2003
On Thu, 20 Nov 2003, Philippe Grosjean wrote:
> >Dear r-help members
> >I posted this message already yesterday, but don't know whether it
> >reached you since I joined the group only yesterday.
> >I would like to estimate the boxcox transformed model
> > (y^t - 1)/t ~ b0 + b1 * x.
> >Unfortunately, R returns with an error message when I try to
> >perform this with the call
> >nls( I((y^t - 1)/t) ~ I(b0 + b1*x),
> > start = c(t=1,b0=0,b1=0), data = mydataframe)
>
> >The error message is: Object "t" not found
>
> >Apparently R seems not to accept parameters on the left hand
> >side of a regression model. I know that my do-it-yourself
> >strategy is not necessary, since the package box-cox is
> >available. Unfortunately, I want the use the box-cox
> >transformation in a quantile regression, i.e. I have to replace
> >nls by nlrq in the call above.
>
> >Any suggestions?
>
> >Thanks and best regards,
> > Johannes Ludsteck
>
> You suggest the solution yourself: transform the equation to have all
> parameters at the right, thus:
>
> y ~ ((b0 + b1 * x) * t + 1) ^ 1/t
>
> (double check if this is correct)
But for nls that changes the fitting criterion from least-squares to
something completely different.
For the original problem, this is not the correct Box-Cox transformation,
as the normalizer has been omitted. I am unaware of `package box-cox'
(and that is not a valid package name AFAIK), but function boxcox in MASS
computes the correct likelihood.
Now nlrq uses a different criterion and Philippe's suggestion may work
there. I can't tell quickly: the help page does not say what the
criterion is. But if those are the same, then I suspect the criterion is
uninteresting as a way to choose t, since two of the three aims of
Box-Cox are to stabilize the distribution of lhs - rhs.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list