R-beta: Polynomials in lm/glm

Peter Dalgaard BSA
Fri, 15 Aug 1997 13:17:58 -0000

"Matthew R. Nelson" <mrn at superh.hg.med.umich.edu> writes:

> I was a bit surprised to find that when I attempted to add a polynomial
> term to a linear model using either lm or glm as could be done in S
> resulted in a fit without that term included and without warning(!!), e.g.
>
> > lm(response ~ x + x^2, data).
>
> As far as I can gather, there is no poly() yet in R, and if lm/glm do not
> allow functions of variables as their formula arguements, is our only
> option to add variables to our dataframe before using lm/glm?

I(x^2) should work. We've discussed previously, whether x^2 should do
what you expect, and as far as I remember the consensus was positive.

In general, one cannot expect to be able to do computations in model
formulas (think of autoflu~onset+duration != autoflu~age).

--
   O__  ---- Peter Dalgaard             Blegdamsvej 3
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907