[R] poly() with unnormalized values
Gray Calhoun
gray.calhoun at gmail.com
Fri Dec 18 05:18:05 CET 2009
Hi Michael,
If I remember right, this question has been asked several times on
this mailing list in the past. The reference listed in the help page
for poly explain how to get the un-orthogonalized coefficients, but
those coefficients aren't needed for prediction. For more details,
though, search the mailing list archives (especially since I may be
forgetting something).
Best,
Gray
On Thu, Dec 17, 2009 at 2:29 PM, Michael Friendly <friendly at yorku.ca> wrote:
> How can I get the result of, e.g., poly(1:3. degree=2) to give me the
> unnormalized integer coefficients
> usually used to explain orthogonal polynomial contrasts, e.g,
>
> -1 1
> 0 -2
> 1 1
>
> As I understand things, the columns of x^{1:degree} are first centered and
> then
> are normalized by 1/sqrt(col sum of squares), but I can't
> see how to relate this to what is returned by poly(). > poly(1:3, degree=2)
> 1 2
> [1,] -7.071068e-01 0.4082483
> [2,] -9.073264e-17 -0.8164966
> [3,] 7.071068e-01 0.4082483
> attr(,"degree")
> [1] 1 2
> attr(,"coefs")
> attr(,"coefs")$alpha
> [1] 2 2
>
> attr(,"coefs")$norm2
> [1] 1.0000000 3.0000000 2.0000000 0.6666667
>
> attr(,"class")
> [1] "poly" "matrix"
>>
>
> I've read the code for poly(), but $alpha and $norm2 are undocumented, and I
> still still can't see the inverse
> transformation
>
> -Michael
>
> --
> Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology
> Dept.
> York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html
> Toronto, ONT M3J 1P3 CANADA
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Gray Calhoun
Assistant Professor of Economics
Iowa State University
More information about the R-help
mailing list