[Rd] Use of lm on polynomial models (PR#14014)

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 19 11:40:44 CEST 2009

RTFM time: h^3 is not the cube of h in an R formula (for that you need 
I(h^3)).  See ?formula, for example.

Simpler would be lm(w ~ poly(h, 3, raw=TRUE))

On Sun, 18 Oct 2009, michael_karsh at earthlink.net wrote:

> Full_Name: Michael Aaron Karsh
> Version: 2.8.0.
> OS: Windows XP
> Submission from: (NULL) (
> When I try lm(w ~ h^3 + h^2 + h) for example, it only gives 
> coefficients for the intercept and for h.  It does not give 
> coefficients for h^2 or h^3.

So it is behaving correctly.

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-devel mailing list