PY206: Statistical Methods for Psychology
Trend Analysis
Trend Analysis
M&D, Chapter 6; Chapter 4 (pp. 169-176) Date: 11/27/05
Slide 1
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Introduction
When a quantitative factor is used, trend analysis is very useful
Slide 2
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Linear trend
Standard form of ANOVA could be applied but would not capitalize on the quantitative information available Lets develop a model that specifies that recall is a linear function of study time
Yij = 0 + 1 X j + ij
We know how to obtain 1 by using techniques from linear regression
Slide 3
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Linear trend
With some algebraic manipulation, we can rewrite 1 in the following manner (assuming equal n):
1 =
c Y
j =1 a j
c2 j
j =1
cj = X j X
cj is a deviation score on the X variable (distance from mean)
c Y has the form of a contrast c = X X = 0 In fact
Note that
j j j j
Thus, slope of a linear trend can be obtained by forming a contrast of Yj the group means ,where the coefficients take on a special form
cj = X j X
Slide 4
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Linear fit
By assuming a linear model, the following fit is obtained
In this case the contrast coefficients are c1 = 1.5, = 0.5, c3 = 0.5, and c4 = 1.5
Slide 5
c2
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Nonlinearity?
Slide 6
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Nonlinearity
Testing for nonlinearity is a test for departures from linearity Yij = 0 + 1 X j + ij
Yij = 0 + 1 X j + 2 X 2 + 3 X 3 + ij j j
In general, up to a 1 terms might be used
Yij = 0 + 1 X j + ... + a1 X a1 + ij j
To test for departures from linearity, we need to assess the null hypothesis including all s for j > 1
H 0 : 2 = 3 = ... = a 1 = 0
Slide 7
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Testing for nonlinearity
How do we test this? As usual, we need the restricted and full models For the restricted model we have Yij = 0 + 1 X ij + ij , df = N 2 We can derive the error for the restricted model as SSE ( R ) = SS total SSlinear
Slide 8
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Full model
The full model with quadratic and cubic terms
Yij = 0 + 1 X j + 2 X 2 + 3 X 3 ij j j
Has N a df (a = 4 for memory data) When we have a 1 powers of X, the resulting trend passes through the mean value of Y for each group (equal n is assumed)
Predicted score for observations at level j are Y j
Yij ( F ) = Y j
Thus
SSE ( F ) = Yij Yij ( F ) = ( Yij Y j )
Slide 9
2
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Full model
But we should note that
SSE ( F ) = SS within
The usual F ratio
( SSE ( R ) SSE ( F )) /( df R df F ) F= SSE ( F ) / df F ( SS total SSlinear SS within ) /[( N 2) ( N a )] F= SS within /( N a )
Can be rewritten as
And further simplified to
F= ( SSbetween SSlinear ) /(a 2) MS within
Slide 10
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Example
F=
(172.5 158.7) /(4 2) = 2.38 2.9
F(2,20) = 2.38 is not significant at the 0.05 level Possible nonlinearity may reflect sampling error
However, this does not mean that the null hypothesis is true; we lack sufficient evidence to declare coefficients nonzero
Slide 11
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Individual higher order terms
Note that we have tested for departures from linearity
Yij = 0 + 1 X j + ... + a1 X a1 + ij j H 0 : 2 = 3 = ... = a1 = 0
In many cases, we might be interested in testing for a specific higher order term Most typical case involves testing for quadratic trends Cubic trend is also possible, and higher order trends are fairly rare (though it is always possible to test them)
Slide 12
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Higher order terms
linear quadratic
cubic
linear + quadratic
Slide 13
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Trends and contrast weights
Lets try to understand the pattern of contrast coefficients Example: with 4 groups, a linear trend is tested by: 3 1 +1 +3 Quadratic trend: +1 1 1 +1 Imagine that you applied linear weights to linear plot
Resultant contrast would be zero
Likewise for quadratic weights when data exhibit quadratic trend
Slide 14
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Trends and contrast weights
Contrast matches the desired shape of the data If you applied the linear-contrast weights to quadratic plot, it would yield a nonzero value because the data have a quadratic trend If you plot the contrast values, they in fact will have the shape of the relationship they are tuned to
Slide 15
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Example
Slide 16
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Contrast sum of squares
For each contrast, the sum of squares is obtained via
n 2 SS = c2 j Remember that = c jY j
Lets call SSdeviation = SSbetween SSlinear The sum of squares attributable to nonlinearity can be partitioned into two components:
SSdeviation = SSquadratic + SScubic
Slide 17
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Partitioning
When a = 4, the three trend contrasts completely partition the variation between groups
SS between = SS linear + SS quadratic + SS cubic
This holds because the trend contrasts form an orthogonal set (non-overlapping contributions)
Slide 18
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Deviation from linearity and specific trends
Before we had tested the null hypothesis that
Yij = 0 + 1 X j + 2 X 2 + 3 X 3 + ij j j
H 0 : 2 = 3 = 0
We found no evidence to reject the null hypothesis: we lacked sufficient evidence to declare nonlinearities But we just saw that we rejected the null hypothesis of 2 = 0 How can the two statements be reconciled?
Slide 19
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Deviation from linearity and specific trends
We saw before that F test for deviation from linearity is
( SSbetween SSlinear ) /(a 2) F= MS within
Thus
F= (( SSlinear + SSquadratic + SScubic ) SSlinear ) /( a 2) MS within
Slide 20
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Deviation from linearity and specific trends
So that the F test for deviation from linearity is
F= ( SSquadratic + SScubic ) / 2 MS within
At the same time, the F test for the quadratic trend by itself is
F= SSquadratic MS within
Slide 21
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Deviation from linearity and specific trends
When SScubic is small, the F statistic when the quadratic trend alone is tested may be nearly twice as large as the F statistic when both trends are included The test for the quadratic trend alone is more powerful than the test of deviation from linearity
More specific test Not diluted by the cubic test
The exact test that one applies will depend on the theoretical framework
Testing deviations from linearity is important Testing specific trends (e.g., quadratic) may also be
Slide 22
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Removing linear effects
To understand the meaning of a quadratic term, we can remove the linear effects from the data The linear trend is characterized by the best-fitting line
Yij = 0.5 + 2.3 X j
What are the errors of the trend model? linear
Slide 23
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Example
Mean error for each group
Errors suggest that the linear trend is not sufficient to describe the data (pattern in the residuals)
Consistent with the statistically significant quadratic trend
Slide 24
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Example
A model with both linear and quadratic components included
Yij = 3.25 + 6.05 X j 0.75 X 2 j
Slide 25
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Example
What are the errors of the quadratic model?
Slide 26
Luiz Pessoa, Brown University 2005
PY206: Statistical Methods for Psychology
Trend Analysis
Cubic trends
What would happen if we included the cubic term?
Yij = 5.0 + 8.83 X j 2.0 X 2 + 0.167 X 3 j j
The inclusion of the cubic trend completely accounts for the between-group variation
Predicted means are equal to the sample means
Because the quadratic trend model provides a very close fit to the sample means, there is no evidence for the need to include the cubic trend in the model To consider more sophisticated techniques, one should consider the more general formalism of curve fitting
Slide 27
Luiz Pessoa, Brown University 2005