orpoly | Orthogonal polyomial contrasts (unequal spacing | N) | orpoly |
The ORPOLY macro finds contrast coefficients for orthogonal polynomials for testing a quantitative factor variable, and constructs CONTRAST (or ESTIMATE) statements (for use with PROC GLM or PROC MIXED) using these values.
This is most useful when either (a) the factor levels are unequally spaced
(Trials=1 2 4 10), or (b) the sample sizes at the different levels are
unequal. In these cases, the 'standard' orthogonal polynomial coefficients
cannot be used. The ORPOLY macro uses the SAS/IML orpoly()
function to find the correct values, and to construct the required CONTRAST
(or ESTIMATE) statements.
When the factor levels are equally spaced, *and* sample sizes are equal, the POLY macro provides a simpler way to generate the contrast coefficients, and the associated INTER macro generates contrasts for interactions among the polynomial contrasts.
orpoly()
function to find the correct values, and to construct the required CONTRAST
(or ESTIMATE) statements.
%orpoly(var=A, file=temp);
DATA=_LAST_
]
name(s)
of quantitative factor variable(s)
for orthogonal polynomial contrasts.
FILE=PRINT
, simply prints the generated statements in the listing file.
To use the generated contrast statements directly following a PROC GLM step, use the FILE= parameter to assign a fileref and create temporary file, which may be used in a GLM step.
TYPE=CONTRAST
]
data testit; do a=1 to 5; do b=1, 5, 9, 13; do obs=1 to 2; y = a + a*a + b + 5*normal(0); output; end; end; end; run;
Assign a filename for the CONTRAST statements, generate them with ORPOLY,
and %INCLUDE
in the GLM step.
filename poly 'orpoly.tst' mod; %orpoly(data=testit, var=a b, file=poly);
proc glm data=testit; class a b; model y=a b a*b; %include poly;
The ORPOLY macro generates the following lines, which are used in the PROC GLM step:
contrast "A-lin" A -0.22361 -0.11180 -0.00000 0.11180 0.22361; contrast "A-quad" A 0.18898 -0.09449 -0.18898 -0.09449 0.18898; contrast "A-3rd" A -0.11180 0.22361 0.00000 -0.22361 0.11180; contrast "B-lin" B -0.21213 -0.07071 0.07071 0.21213; contrast "B-quad" B 0.15811 -0.15811 -0.15811 0.15811;