[R] polynomial contrasts in R
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Fri Jan 17 09:00:04 CET 2003
You are wrong about S-PLUS! contr.poly only takes as argument the number
of levels required (and uses pre-computed sets for up to 12 levels).
You get orthogonal polynomials for equally-space values from contr.poly in
both systems, as documented.
I don't think you are describing contrasts for an ordered factor, but
orthogonal polynomials in a numeric variable. The latter are computed by
the function poly() in both R and S-PLUS. You could set them up to give a
contrasts matrix if you want, but not a contrasts function (as that is
only passed the number of levels, AFAIR).
On Thu, 16 Jan 2003, George W. Gilchrist wrote:
> In S-Plus, I can obtain polynomial contrasts for an ordered factor with
> contr.poly(). The function also exists in R, however is limited to factors
> where the levels are equally spaced. In S-Plus, one can obtain the contrasts
> for a set of numeric values representing unequally spaced ordered factors.
> Has anyone implemented this in R? I see that the S-Plus function calls
> another function (poly.raw()) that calls a Fortran routine. Thanks for your
> assistance.
--
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