
Schematic of CR-4 with Example Data
Consider again the following Completely Randomized 4 group design:
Level a1
a2 a3 a4 Total
3
6
3
3
1
2
2
2
4
5
4
3
2
3
4
3
7
8
7
6
5
6
5
6
7
8
9
8
10
10
9
11
Mean 2.75
3.5 6.25 9.0 5.375
Plot of the Group Means

Inspection of the plot of group means suggests, that although it is possible to fit a straight line through the points, there also seems to be a little bit of curvalinearnity present.
Trend analysis partitions the sum of squares for the model into portions due to linear trend, quadratic trend, cubic trend, etc. If there are k groups it is possible to look at up to k - 1 trends, although often researchers combine together all trends above quadratic or cubic.
Coefficients of Orthogonal Polynomials
Trend analysis is performed using coefficients of orthogonal polynomials. For the four group design the coefficients are:
Group -> 1 2 3 4 Linear -3 -1 1 3 Quadratic 1 -1 -1 1 Cubic -1 3 -3 1
Here is a table with more coefficients of orthogonal polynomials.
Plotting Coefficients of Orthogonal Polynomials
Plot of Linear Trend

Plot of Quadratic Trend

Plot of Cubic Trend

Using the Coefficients of Orthogonal Polynomials
One way to perform trend analysis is to use the coefficients of orthogonal polynomials to weight the group sums to compute sums of squares for each of the trends in a manner very similar to computing planned orthogonal comparisons. Using the coefficients in this manner yields the following ANOVA Summary Table:
| Source | SS | df | MS | F | |
| Between Groups | 194.5 | 3 | 64.833 | 44.28 | |
| Linear Trend | 184.9 | 1 | 184.900 | 126.30 | |
| Non-Linear | 9.6 | 2 | 4.800 | 3.28 | |
| Quadratic Trend | 8.0 | 1 | 8.000 | 5.46 | |
| Cubic Trend | 1.6 | 1 | 1.600 | 1.09 | |
| Within Groups | 41.0 | 28 | 1.464 | ||
| Total | 235.5 | 31 |
Stata Example
An alternative is to apply the coefficients of orthogonal polynomials directly to the observations and to analyze using regression.
input y grp o1 o2 o3
3 1 -3 1 -1
6 1 -3 1 -1
3 1 -3 1 -1
3 1 -3 1 -1
1 1 -3 1 -1
2 1 -3 1 -1
2 1 -3 1 -1
2 1 -3 1 -1
4 2 -1 -1 3
5 2 -1 -1 3
4 2 -1 -1 3
3 2 -1 -1 3
2 2 -1 -1 3
3 2 -1 -1 3
4 2 -1 -1 3
3 2 -1 -1 3
7 3 1 -1 -3
8 3 1 -1 -3
7 3 1 -1 -3
6 3 1 -1 -3
5 3 1 -1 -3
6 3 1 -1 -3
5 3 1 -1 -3
6 3 1 -1 -3
7 4 3 1 1
8 4 3 1 1
9 4 3 1 1
8 4 3 1 1
10 4 3 1 1
10 4 3 1 1
9 4 3 1 1
11 4 3 1 1
end
anova y grp
Number of obs = 32 R-squared = 0.8259
Root MSE = 1.21008 Adj R-squared = 0.8072
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 194.50 3 64.8333333 44.28 0.0000
|
grp | 194.50 3 64.8333333 44.28 0.0000
|
Residual | 41.00 28 1.46428571
-----------+----------------------------------------------------
Total | 235.50 31 7.59677419
anovacontrast grp, values(-3 -1 1 3) title(linear)
linear
Contrast variable grp (-3 -1 1 3)
source SS df MS Dep Var = y
---------+--------------------------------- N of obs = 32
contrast | 184.9 1 184.9000 F = 126.27
error | 41 28 1.4643 Prob > F = 0.0000
---------+---------------------------------
anovacontrast grp, values(1 -1 -1 1) title(quadratic)
quadratic
Contrast variable grp (1 -1 -1 1)
source SS df MS Dep Var = y
---------+--------------------------------- N of obs = 32
contrast | 8 1 8.0000 F = 5.46
error | 41 28 1.4643 Prob > F = 0.0268
---------+---------------------------------
anovacontrast grp, values(-1 3 -3 1) title(cubic)
cubic
Contrast variable grp (-1 3 -3 1)
source SS df MS Dep Var = y
---------+--------------------------------- N of obs = 32
contrast | 1.6 1 1.6000 F = 1.09
error | 41 28 1.4643 Prob > F = 0.3048
---------+---------------------------------
regress y o1 o2 o3
Source | SS df MS Number of obs = 32
-------------+------------------------------ F( 3, 28) = 44.28
Model | 194.50 3 64.8333333 Prob > F = 0.0000
Residual | 41.00 28 1.46428571 R-squared = 0.8259
-------------+------------------------------ Adj R-squared = 0.8072
Total | 235.50 31 7.59677419 Root MSE = 1.2101
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
o1 | 1.075 .095665 11.24 0.000 .8790392 1.270961
o2 | .5 .2139134 2.34 0.027 .0618183 .9381817
o3 | -.1 .095665 -1.05 0.305 -.2959608 .0959608
_cons | 5.375 .2139134 25.13 0.000 4.936818 5.813182
------------------------------------------------------------------------------
test o1 /* linear */
( 1) o1 = 0.0
F( 1, 28) = 126.27
Prob > F = 0.0000
test o2 /* quadratic */
( 1) o2 = 0.0
F( 1, 28) = 5.46
Prob > F = 0.0268
test o3 /* cubic */
( 1) o3 = 0.0
F( 1, 28) = 1.09
Prob > F = 0.3048
test o2 o3 /* nonlinear */
( 1) o2 = 0.0
( 2) o3 = 0.0
F( 2, 28) = 3.28
Prob > F = 0.0526
Using xi3
This time we will use orthoginal polynomials built into xi2 using the o prefix.
xi3: regress y o.grp
o.grp _Igrp_1-4 (_Igrp_4 for grp==4 omitted)
Source | SS df MS Number of obs = 32
-------------+------------------------------ F( 3, 28) = 44.28
Model | 194.50 3 64.8333333 Prob > F = 0.0000
Residual | 41.00 28 1.46428571 R-squared = 0.8259
-------------+------------------------------ Adj R-squared = 0.8072
Total | 235.50 31 7.59677419 Root MSE = 1.2101
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Igrp_1 | 2.403773 .2139134 11.24 0.000 1.965591 2.841955
_Igrp_2 | .5 .2139134 2.34 0.027 .0618183 .9381817
_Igrp_3 | -.2236068 .2139134 -1.05 0.305 -.6617885 .2145749
_cons | 5.375 .2139134 25.13 0.000 4.936818 5.813182
------------------------------------------------------------------------------
describe _Igrp_1 _Igrp_2 _Igrp_3
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------
_Igrp_1 double %10.0g deg=1 orth. poly. for grp
_Igrp_2 double %10.0g deg=2 orth. poly. for grp
_Igrp_3 double %10.0g deg=3 orth. poly. for grp
test _Igrp_1 /* linear */
( 1) _Igrp_1 = 0.0
F( 1, 28) = 126.27
Prob > F = 0.0000
test _Igrp_2 /* quadratic */
( 1) _Igrp_2 = 0.0
F( 1, 28) = 5.46
Prob > F = 0.0268
test _Igrp_3 /* cubic */
( 1) _Igrp_3 = 0.0
F( 1, 28) = 1.09
Prob > F = 0.3048
test _Igrp_2 _Igrp_3 /* nonlinear */
( 1) _Igrp_2 = 0.0
( 2) _Igrp_3 = 0.0
F( 2, 28) = 3.28
Prob > F = 0.0526