Notes on Maxwell & Delaney

Similar documents
Notes on Maxwell & Delaney

BIOL Biometry LAB 6 - SINGLE FACTOR ANOVA and MULTIPLE COMPARISON PROCEDURES

Statistics Lab One-way Within-Subject ANOVA

COMPARING SEVERAL MEANS: ANOVA

4:3 LEC - PLANNED COMPARISONS AND REGRESSION ANALYSES

Keppel, G. & Wickens, T. D. Design and Analysis Chapter 4: Analytical Comparisons Among Treatment Means

Orthogonal contrasts and multiple comparisons

Difference in two or more average scores in different groups

Orthogonal and Non-orthogonal Polynomial Constrasts

STAT 263/363: Experimental Design Winter 2016/17. Lecture 1 January 9. Why perform Design of Experiments (DOE)? There are at least two reasons:

ANALYTICAL COMPARISONS AMONG TREATMENT MEANS (CHAPTER 4)

Introduction to the Analysis of Variance (ANOVA)

Using SPSS for One Way Analysis of Variance

These are all actually contrasts (the coef sum to zero). What are these contrasts representing? What would make them large?

Inference for the Regression Coefficient

Notes on Maxwell & Delaney

Statistics Lab #6 Factorial ANOVA

One-Way ANOVA. Some examples of when ANOVA would be appropriate include:

Stats fest Analysis of variance. Single factor ANOVA. Aims. Single factor ANOVA. Data

Design & Analysis of Experiments 7E 2009 Montgomery

What Does the F-Ratio Tell Us?

Chapter 5 Contrasts for one-way ANOVA

More about Single Factor Experiments

Inferences for Regression

Sampling Distributions: Central Limit Theorem

Regression With a Categorical Independent Variable

Multiple Regression. More Hypothesis Testing. More Hypothesis Testing The big question: What we really want to know: What we actually know: We know:

Analytical Comparisons Among Treatment Means (Chapter 4) Analysis of Trend (Chapter 5) ERSH 8310 Fall 2009

Hypothesis testing: Steps

The legacy of Sir Ronald A. Fisher. Fisher s three fundamental principles: local control, replication, and randomization.

Week 14 Comparing k(> 2) Populations

Multiple t Tests. Introduction to Analysis of Variance. Experiments with More than 2 Conditions

Unbalanced Data in Factorials Types I, II, III SS Part 1

Introduction to the Analysis of Variance (ANOVA) Computing One-Way Independent Measures (Between Subjects) ANOVAs

Analysis of Variance (ANOVA)

Multiple Comparisons

INTRODUCTION TO ANALYSIS OF VARIANCE

Specific Differences. Lukas Meier, Seminar für Statistik

Comparing Several Means: ANOVA

Hypothesis testing: Steps

1 Introduction to Minitab

Regression With a Categorical Independent Variable: Mean Comparisons

STA 6167 Exam 3 Spring 2016 PRINT Name

Coding in Multiple Regression Analysis: A Review of Popular Coding Techniques

Chapter 1 Statistical Inference

The One-Way Repeated-Measures ANOVA. (For Within-Subjects Designs)

(b)complete the table to show where the function is positive (above the x axis) or negative (below the x axis) for each interval.

The One-Way Independent-Samples ANOVA. (For Between-Subjects Designs)

R 2 and F -Tests and ANOVA

Ch 3: Multiple Linear Regression

Design of Engineering Experiments Chapter 5 Introduction to Factorials

Chapter 7 Factorial ANOVA: Two-way ANOVA

Linear regression. We have that the estimated mean in linear regression is. ˆµ Y X=x = ˆβ 0 + ˆβ 1 x. The standard error of ˆµ Y X=x is.

Extensions of One-Way ANOVA.

Recall that a measure of fit is the sum of squared residuals: where. The F-test statistic may be written as:

H0: Tested by k-grp ANOVA

9 Correlation and Regression

THE PEARSON CORRELATION COEFFICIENT

One-Way ANOVA Source Table J - 1 SS B / J - 1 MS B /MS W. Pairwise Post-Hoc Comparisons of Means

ANOVA (Analysis of Variance) output RLS 11/20/2016

AMS 7 Correlation and Regression Lecture 8

Unit 27 One-Way Analysis of Variance

Correlation 1. December 4, HMS, 2017, v1.1

Multiple Linear Regression

Contrasts and Multiple Comparisons Supplement for Pages

One-Way Analysis of Variance. With regression, we related two quantitative, typically continuous variables.

Contrast Analysis: A Tutorial

Analysis of Covariance. The following example illustrates a case where the covariate is affected by the treatments.

Analysis of variance

Workshop 7.4a: Single factor ANOVA

Variance Decomposition and Goodness of Fit

" M A #M B. Standard deviation of the population (Greek lowercase letter sigma) σ 2

An Old Research Question

Laboratory Topics 4 & 5

Linear Regression. In this lecture we will study a particular type of regression model: the linear regression model

Variance Decomposition in Regression James M. Murray, Ph.D. University of Wisconsin - La Crosse Updated: October 04, 2017

Power Analysis using GPower 3.1

Regression and the 2-Sample t

Ch. 16: Correlation and Regression

Test 3 Practice Test A. NOTE: Ignore Q10 (not covered)

Glossary. The ISI glossary of statistical terms provides definitions in a number of different languages:

Regression With a Categorical Independent Variable

Simple Linear Regression

Lectures 5 & 6: Hypothesis Testing

STAT 525 Fall Final exam. Tuesday December 14, 2010

DESIGNING EXPERIMENTS AND ANALYZING DATA A Model Comparison Perspective

Sampling distribution of t. 2. Sampling distribution of t. 3. Example: Gas mileage investigation. II. Inferential Statistics (8) t =

Regression Analysis. Table Relationship between muscle contractile force (mj) and stimulus intensity (mv).

1 The Classic Bivariate Least Squares Model

Complete the following table using the equation and graphs given:

ANOVA Situation The F Statistic Multiple Comparisons. 1-Way ANOVA MATH 143. Department of Mathematics and Statistics Calvin College

Orthogonal, Planned and Unplanned Comparisons

1 Overview. 2 Multiple Regression framework. Effect Coding. Hervé Abdi

STAT 350 Final (new Material) Review Problems Key Spring 2016

(ii) Scan your answer sheets INTO ONE FILE only, and submit it in the drop-box.

Factorial designs. Experiments

Lec 1: An Introduction to ANOVA

Regression. Marc H. Mehlman University of New Haven

Inferences on Linear Combinations of Coefficients

What If There Are More Than. Two Factor Levels?

Transcription:

Notes on Maxwell & Delaney PSCH 710 6 Chapter 6 - Trend Analysis Previously, we discussed how to use linear contrasts, or comparisons, to test specific hypotheses about differences among means. Those discussions implicitly assumed that the ing variable, or factor, was qualitative, in the sense that the levels of the factor were not ordered. In such cases, the levels of the factor are said to form a nominal scale. In some situations, however, the levels of the factor clearly are ordered: the ages of children in a developmental study, for example, or the amount of time given to study lists of words in a memory experiment. It makes sense to say that one level is greater than another, and therefore these factors are quantitative rather than qualitative. In such cases, we often are interested in particular kinds of comparisons across s. For example, we may want to know if performance in a memory test is a linear or nonlinear function of study time. As we shall see, we can use linear comparisons to answer such questions. Using linear comparisons to examine the effects of a quantitative factor is often referred to as trend analysis, or the method of orthogonal polynomials. The mathematical methods for computing these contrasts are exactly the same as those used to compare the levels of qualitative factor. 6.1 rose data 6.1.1 omnibus test We will use the data stored in the data frame, rose to illustrate trend analysis. The following commands set up R to use sum-to-zero coding for the effects (i.e., the α s) associated with different levels of factors, polynomial contrasts for ordered factors (more on this in a moment), and loads the data: > options(contrasts=c("contr.sum","contr.poly") ) > options(digits=4) # formats the output > load(url("http://psycserv.mcmaster.ca/bennett/psy710/datasets/rose.rdata") ) rose contains the integer variables age and score from a hypothetical score that recorded some measure of cognitive performance in children who were 8, 9, 10, 11, and 12 years of age. I am going to create a ing variable (i.e., a factor) from age, and then plot the mean score as a function of age in Figure 1. > rose$agegroup <- factor(rose$age, labels = "g", ordered = FALSE) > y.means <- tapply(rose$score, rose$agegroup, mean) > x. <- sort(unique(rose$age))$ Just for fun, let s compute the correlation between age and the mean: > cor(x., y.means) 1

rose data mean score 10 12 14 16 8 9 10 11 12 age Figure 1: Rose data. [1] 0.98287 The correlation is quite high and, together with the graph, suggests that there is an association between score and age. Now we do an ANOVA using the aov() and summary() commands: > rose.aov.01 <- aov(score ~ agegroup, data = rose) > summary(rose.aov.01) agegroup 4 455.6 113.9 1.672 0.173 Residuals 45 3064.9 68.1 We get the same results if we use lm() and print the summary table with anova(): > rose.lm.01 <- lm(score ~ agegroup, data = rose) > anova(rose.lm.01) Response: score agegroup 4 456 114 1.67 0.17 Surprisingly, the effect of agegroup is not statistically significant. What is going on here? The problem is that the omnibus F test evaluates a very general question, namely whether there are any differences across s. However, the very high correlation, as well as the data in Figure 1, suggest that there is a linear relation between score and agegroup. What we need is a method for testing for the presence of specific trends that may exist between score and agegroup. This method is called, not surprisingly, trend analysis. 2

6.1.2 ordered factors Trend analysis involves nothing more than the calculation of linear contrasts, or comparisons, among levels of a quantitative factor. In R, a quantitative factor is called an ordered factor: it is a ing variable that preserves the order among levels. Although linear contrasts can be used to test for arbitrary differences across levels of an ordered factor, in trend analysis we are interested in only a few possible patterns of differences, or trends, across the levels of an ordered factor. Several trends are shown in Figure 2. Each plot in Figure 2 show the weights for a single trend contrast. The weights are shown in the columns of the following matrix: > contr.poly(n = 5,scores=c(8,9,10,11,12)).L.Q.C ^4 [1,] -0.6325 0.5345-3.162e-01 0.1195 [2,] -0.3162-0.2673 6.325e-01-0.4781 [3,] 0.0000-0.5345-4.096e-16 0.7171 [4,] 0.3162-0.2673-6.325e-01-0.4781 [5,] 0.6325 0.5345 3.162e-01 0.1195 These contrast weights shown in Figure 2 with the assumption that there are an equal number of subjects in each. A careful inspection of this matrix, and the plots in Figure 2, will show that the trend contrasts form an orthogonal set. (Note that these values are not the same as those listed in your textbook. For example, the book uses the following weights to test for a linear trend across 5 s: [-1.5, -0.5, 0.5, 1.5]. The difference in weights will not alter the results of F tests, but it will alter the value of ψ for each comparison.) To perform a trend analysis, we frist need to create an ordered factor for our rose data set: > rose$orderedage <- factor(rose$age, labels = "a", ordered = TRUE) > class(rose$orderedage) [1] "ordered" "factor" > class(rose$agegroup) [1] "factor" > unique(rose$orderedage) [1] a1 a2 a3 a4 a5 Levels: a1 < a2 < a3 < a4 < a5 > unique(rose$agegroup) [1] g1 g2 g3 g4 g5 Levels: g1 g2 g3 g4 g5 Note the difference in the levels for orderedage and agegroup. 3

linear trend quadratic trend 0.6 0.2 0.2 0.6 0.4 0.0 0.4 cubic trend quartic trend 0.6 0.2 0.2 0.6 0.4 0.0 0.4 Figure 2: Linear, quadratic, cubic, and quartic trends. 6.1.3 trend analysis using aov Now we simply do an ANOVA with our new ordered variable using aov: > rose.aov.02 <- aov(score ~ orderedage, data = rose) > summary(rose.aov.02) orderedage 4 455.6 113.9 1.672 0.173 Residuals 45 3064.9 68.1 The results are exactly the same as the previous one. Why? Because the ANOVA table shows the overall effect of, which does not depend on the code used to represent the variable. In other words, the overall, omnibus F is exactly the same regardless of whether is represented as a factor or an ordered factor. The effect of using an ordered factor becomes apparent when we partition SS orderedage. Notice how the command split is used in the next command to break SS orderedage into four components. Why four components? Because there are five age s, so there are 5 1 = 4 orthogonal trends. > summary(rose.aov.02, split = list(orderedage = list(1, 2, 3, 4))) orderedage 4 455.6 113.9 1.672 0.1730 orderedage: C1 1 440.2 440.2 6.463 0.0145 * orderedage: C2 1 8.9 8.9 0.130 0.7202 4

orderedage: C3 1 5.6 5.6 0.082 0.7762 orderedage: C4 1 1.1 1.1 0.016 0.9014 Residuals 45 3064.9 68.1 This table is not very informative, so I am going to give names to each component. > summary(rose.aov.02, split = list(orderedage = list(linear = 1, quadratic = 2, + cubic = 3, quartic = 4))) orderedage 4 456 114 1.67 0.173 orderedage: linear 1 440 440 6.46 0.015 * orderedage: quadratic 1 9 9 0.13 0.720 orderedage: cubic 1 6 6 0.08 0.776 orderedage: quartic 1 1 1 0.02 0.901 The table shows SS contrast, F, and p for each linear comparison. The first contrast is the linear trend, the second is the quadratic trend, the third is the cubic trend, and the fourth contrast is the quartic trend. We can see that the test for linear trend is significant, which means that we reject the null hypothesis 0.6325µ 1 0.3162µ 2 + 0µ 3 + 0.3162µ 4 + 0.6325µ 5 = 0 (1) Compare SS orderedage to the sums of squares for each comparison. Because the trends are derived from orthogonal contrasts, SS orderedage = SS linear + SS quadratic + SS cubic + SS quartic. Also, because each trend is a linear contrast, there is 1 df for each trend. Finally, because the trends are orthogonal, F omnibus = (1/4)(F linear + F quadratic + F cubic + F quartic ). 6.1.4 testing for significance of nonlinear trends Sometimes we want to know if a the relationship between our independent and dependent variables is or is not nonlinear, regardless of the form of the nonlinearity. This type of question can be addressed by doing a single test on the ed nonlinear trends. The following commands perform such an analysis in R. Notice the 2:4 syntax used to specify that contrasts 2, 3, and 4 are combined. > summary(rose.aov.02, split = list(orderedage = list(linear = 1, nonlinear = 2:4))) orderedage 4 456 114 1.67 0.173 orderedage: linear 1 440 440 6.46 0.015 * orderedage: nonlinear 3 15 5 0.08 0.973 5

The results again indicate that the linear trend is significant. The test for nonlinearity is not significant. This test for nonlinearity can be thought of as an omnibus F test on the nonlinear trends. Finally, in some situations we may be interested in evaluating the linear and quadratic trends and ignoring any remaining nonlinear trends. This analysis can be done by listing the linear and quadratic trends in the split command and ing the remaining nonlinear trends: > summary(rose.aov.02, split = list(orderedage = list(lin = 1, quad=2, other = 3:4))) orderedage 4 456 114 1.67 0.173 orderedage: lin 1 440 440 6.46 0.015 * orderedage: quad 1 9 9 0.13 0.720 orderedage: other 2 7 3 0.05 0.953 6.1.5 calculating ψ for each trend Finally, it is a simple matter to list the value of ψ for each comparison: > coef(rose.aov.02) (Intercept) orderedage.l orderedage.q orderedage.c orderedage^4 13.5240 6.6345-0.9408-0.7463 0.3251 > confint(rose.aov.02) # confidence intervals 2.5 % 97.5 % (Intercept) 11.173 15.875 orderedage.l 1.378 11.891 orderedage.q -6.197 4.316 orderedage.c -6.003 4.510 orderedage^4-4.931 5.581 6.1.6 interpretation of ψ values What do these values of ψ mean? Each ψ can be turned into a regression weight, b: b = ˆψ a j=1 c2 j (2) where c j is the j-th weight in the linear contrast. These regression weights can be used to construct a regression equation that expresses the observed scores in terms of a polynomial contrast weights ij = β 0 + b L c Lj + b Q c Qj + b C c Cj + + e ij (3) where B 0 is the intercept, the b s are regression weights, and the c s are the contrast weights, and j represents the level of the ordered factor. For example, c L1, c Q1, and c C1 represent the first weights of the linear, quadratic, and cubic contrasts; c L2, c Q2, and c C2 represent the second weights of the 6

linear, quadratic, and cubic contrasts; and so on. This interpretation is valid provided the ordered levels are equally spaced and there are equal numbers of subjects in each. In the present example, the values of the intercept and four ψ s are 13.524, 6.6345, -0.9409, -0.7463, and 0.3251. For the polynomial contrasts used by R, the sum of the squared weights is 1. Therefore, the regression coefficients equal the values of the comparisons(b j = ψ j = [6.6345, 0.9409, 0.7463, 0.3251]). Combining the b s with the values of the contrast weights (shown above) allows us to use Equation 3 to calculate the mean scores for the four s: Ȳ 1 = 13.524 + 6.6345( 0.6325) 0.9408(0.5345) 0.7463( 0.3162) + 0.3251(0.1195) = 9.10 Ȳ 2 = 13.524 + 6.6345( 0.3162) 0.9408( 0.2673) 0.7463(0.6325) + 0.3251( 0.4781) = 11.05 Ȳ 3 = 13.524 + 6.6345(0) 0.9408( 0.5345) 0.7463(0) + 0.3251(0.7171) = 14.26 Ȳ 4 = 13.524 + 6.6345(0.3162) 0.9408( 0.2673) 0.7463( 0.6325) + 0.3251( 0.4781) = 16.19 Ȳ 5 = 13.524 + 6.6345(0.6325) 0.9408(0.5345) 0.7463(0.3162) + 0.3251(0.1195) = 17.02 These values correspond exactly to the means: > with(rose, tapply(score,orderedage,mean) ) # calc means a1 a2 a3 a4 a5 9.10 11.05 14.26 16.19 17.02 6.2 planned vs. post-hoc comparisons I have been acting as though the previous analyses were planned comparisons. However, it certainly is permissible to do post-hoc trend analyses. In such cases, you should use Scheffé s method to control familywise Type I errors. However, I think that we often do ourselves a disservice by not doing planned trend analyses on ordered factors. Why? Because psychological theories rarely are developed to the point where they predict a quantitative relation between independent and dependent variables that includes anything higher than a quadratic component. In other words, it is unlikely that a theory would have the form shown in Equation 3. It is more likely to find a theory that looks like this ij = β 0 + α L X j + e ij (4) or this ij = β 0 + α L X j + α Q X 2 j + e ij (5) Sometimes the theory is implicit. For instance, if we are measuring some ability in children in grades 1 through 5, we may strongly suspect that the ability increases from grades 1 through 4 and levels off. This expectation is equivalent to saying that we expect to find significant linear and quadratic trends. In this case, it makes sense to test for linear and quadratic trends and ignore the higher-order nonlinear trends. Such comparisons would be more powerful than an omnibus F test and provide more direct tests of our hypothesis. Of course, I am not saying that you should always do trend analyses on ordered factors. Instead, I am suggesting that you think about how your dependent variable may be related to the levels of your ing variable and then use an appropriate test to evaluate your hypothesis. 7