[R] poly() with unnormalized values

Michael Friendly friendly at yorku.ca
Thu Dec 17 23:29:03 CET 2009


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




More information about the R-help mailing list