Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Abu Hajar
1
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
The first step in the ANCOVA analysis is to check the “Independence of the covariate and
treatment effect” assumption. This is accomplished by checking if the mean of the covariate is
equal across the different levels of the grouping variable. We will simply run ANOVA with the
covariate as the outcome and the dose as the predictor (grouping variable). The ANOVA results
are presented in the Table below. The ANOVA model states that the differences between the
2
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
covariate means across the different groups are not significant. Thus, the covariate can be included
in the ANCOVA.
ANOVA
Covariate
Sum of Squares df Mean Square F Sig.
Between Groups 12.769 2 6.385 1.979 .158
Within Groups 87.097 27 3.226
Total 99.867 29
To carry out ANCOVA, go to Analyze General Linear Model Univariate (Figure below).
Once a covariate is selected, the “Post Hoc” button will be disabled. W comparisons using the
“Contrasts” option. Click “Contrasts” where you can select one of the several available standard
contrasts. Select “Simple” from the dropdown list and change the “Reference Category” to “First”
as shown in the Figure below and click “Change”. Simple contrast compares each level to the first
category.
3
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Click “Continue” to go back to the main dialogue box. Click “Options” and drag the variable
“Dose” to the “Display Means for” box as shown in the Figure below. Check the “Compare main
effects” box and from the dropdown list, select one of the proposed adjustments (Bonferroni or
Sidak are recommended).
Click “Continue” to go back to the main dialogue box and click “OK”.
4
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
SPSS output
The first main output is Levene’s test result as shown in the following Table. The result clearly
states that the homogeneity assumption has been violated (Levene’s statistic is significant).
The next table is the “Test of Between-Subjects Effects” (ANOVA). Clearly, the covariate has a
significant contribution to the model (sig = 0.035). The Dose is also significant which in this means
that by including the covariate in the model, its effect is removed (eliminated) so the Dose becomes
a significant predictor (or factor). The 𝑆𝑆𝑀 is 31.92, 25.185 of which is accounted for by the Dose.
To understand the importance of the 𝑆𝑆𝑀 and 𝑆𝑆𝑅 , you may run an ANOVA analysis (without the
covariate) and observe the differences in errors (between ANOVA and ANCOVA).
The “Parameters Estimates” table presents the regression coefficients as explained earlier in the
ANOVA chapter (two dummy variables for each dose level). In this case, the reference category
is the one with the highest value, that is the high dose. The B values in the table represent the
differences between the groups means and the 𝑡-statistic values indicate whether those differences
are significant. From this table, we can conclude that there is a significant difference between the
high dose and the placebo groups. However, the difference between the high and low doses is not
significant. The covariate’s coefficient (0.416) indicates that if all other factors are equal (similar
5
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
doses), a one-unit increase in the covariate results in a 0.416-unit increase in the outcome and the
direction is positive (increase with an increase).
Parameter Estimates
Dependent Variable: Outcome
95% Confidence Interval
Parameter B Std. Error t Sig. Lower Bound Upper Bound
Intercept 4.014 .611 6.568 .000 2.758 5.270
Covariate .416 .187 2.227 .035 .032 .800
[Dose=1.00] -2.225 .803 -2.771 .010 -3.875 -.575
[Dose=2.00] -.439 .811 -.541 .593 -2.107 1.228
[Dose=3.00] 0a . . . . .
a. This parameter is set to zero because it is redundant.
The “Contrast Results” table shows the contrast analysis and the first comparison is between the
placebo and the low dose. The second comparison is between the high dose and the placebo groups.
Both contrasts are significant at 0.05 level which is consistent with the earlier findings (regression
coefficients).
6
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
One may consider exploring the means of the groups as a way of comparison after determining
that the differences are significant. However, the original means are of little help because they
have not been adjusted for the effect of the covariate. Thus, the group means are adjusted in SPSS
as shown in the following Table “Estimates”. Notice that the SPSS does not allow you to run
planned contrasts as defined in the ANOVA. There might be a way to go around it using a special
coding or one may elect to run a multiple linear regression and the planned contrasts are defined
based on the regression coefficients with respect to the reference category.
Estimates
Dependent Variable: Outcome
95% Confidence Interval
Dose Mean Std. Error Lower Bound Upper Bound
Placebo 2.926a .596 1.701 4.152
Low dose 4.712a .621 3.436 5.988
High dose 5.151a .503 4.118 6.184
a. Covariates appearing in the model are evaluated at the following
values: Covariate = 2.7333.
Finally, the Sidak-corrected post hoc comparisons are presented in the “Pairwise Comparisons”
Table shown below. Based on these comparisons, we can conclude that the high dose differs
significantly from the placebo (as portrayed earlier). Also, the high and lose dose are significantly
different. However, the pairwise comparisons indicate that the low dose is not significantly
different from the placebo (unlike the findings of the regression coefficients).
Pairwise Comparisons
Dependent Variable: Outcome
95% Confidence Interval for
Mean Differenceb
(I) Dose (J) Dose Difference (I-J) Std. Error Sig.b Lower Bound Upper Bound
Placebo Low dose -1.786 .849 .130 -3.953 .381
High dose -2.225* .803 .030 -4.273 -.177
Low dose Placebo 1.786 .849 .130 -.381 3.953
High dose -.439 .811 .932 -2.509 1.631
High dose Placebo 2.225* .803 .030 .177 4.273
Low dose .439 .811 .932 -1.631 2.509
Based on estimated marginal means
*. The mean difference is significant at the .05 level.
b. Adjustment for multiple comparisons: Sidak.
7
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
In summary, we can look at the parameter estimates of the covariate and sign of the parameter
(regression coefficient) tells us the direction of the relationship. You may run ANCOVA by
running the classic multiple linear regression in a hierarchical way by entering the covariate in the
first block and the dummy coded variables in the second block. There will be few differences
because the dummy coding assumes 0 and 1 with respect to the placebo (baseline group).
Finally, we need to check the assumption of homogeneity of regression slopes. This means that
the relationship between the outcome and the covariate is pretty similar across the different
categories (treatment groups). To test this assumption, we rerun the ANCOVA with a customized
model. Access the main dialogue box and insert the variables in the same way. Click “Model”
select “Custom”. We need to select a model that includes the interaction between the independent
variable and the covariate. First include the main effects of each variable and then include the
interaction of the two variables. The Model dialogue box should appear like the following Figure.
In the SPSS output, you need to look at the “Tests of Between-Subjects Effects” table. Look at the
interaction term and you can see that it is significant, which means that the assumption of
homogeneous slopes has been broken. In other words, the results of ANCOVA analysis are
probably biased. Unfortunately, SPSS does not offer an easy replacement (nonparametric) for
ANCOVA.
8
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
9
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Example: A researcher was interested in evaluating the effect of a drug dose on a certain health
indicator (outcome). The researcher also believes that the effect would be different based on the
gender. 48 patients were selected for the experiment (24 males and 24 females) and were divided
into 3 groups: placebo, low, and high doses. The experimental data is presented in the following
table.
70 55 65 60 65 30
60 80 60 85 70 30
60 65 70 65 55 55
60 70 65 70 55 35
55 75 60 70 60 20
60 75 60 80 50 45
55 65 50 60 50 40
Total 485 535 500 535 460 285
𝑋̅ 60.625 66.875 62.500 66.875 57.500 35.625
𝑉𝑎𝑟 24.554 106.696 42.857 156.696 50.000 117.411
𝑠 4.955 10.329 6.547 12.518 7.071 10.836
10
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Two-way ANOVA is very similar to one-way ANOVA where we will find the 𝑆𝑆𝑇 which is broken
down into 𝑆𝑆𝑀 and 𝑆𝑆𝑅 . The 𝑆𝑆𝑀 is broken down further into variance explained by the first
independent variable 𝑆𝑆𝐴 , variance explained by the second 𝑆𝑆𝐵 , and variance explained by the
interaction of the two 𝑆𝑆𝐴×𝐵 .
To begin with, we calculate 𝑆𝑆𝑇 which represents the variability between all scores (ignoring the
experimental conditions) as 𝑆𝑆𝑇 = Grand 𝑠 2 × (𝑁 − 1). The grand variance is the variance of all
48 participants’ scores (190.78). Thus, 𝑆𝑆𝑇 = 8,966.7 (𝑑𝐹 = 47).
To calculate 𝑆𝑆𝑀 , we need to consider the six experimental groups as follows:
2
𝑆𝑆𝑀 = ∑ 𝑛𝑘 (𝑥̅ 𝑘 − 𝑥̅𝑔𝑟𝑎𝑛𝑑 )
So the 𝑆𝑆𝑀 deals with each group of the six groups (placebo-male, placebo-female, low-male, low-
female, high-male, high-female) and is calculated as follows:
𝑆𝑆𝑀 = 8(60.625 − 58.33)2 + 8(66.875 − 58.33)2 + 8(62.5 − 58.33)2
+ 8(66.875 − 58.33)2 + 8(57.5 − 58.33)2 + 8(35.625 − 58.33)2 = 5,479.17
The 𝑑𝐹 for 𝑆𝑆𝑀 is equal to the number of groups – 1 (𝑑𝐹 = 5).
By dividing our experimental procedure to six groups, we were able to explain 5,479.17 variance
units of the 8,966.7.
To break down the 𝑆𝑆𝑀 , we will first deal with the independent variable (gender). Therefore, we
need to rearrange the groups based on the gender (ignoring the dose and placing all males in one
group and all females into another) as follows:
11
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
We then rearrange the data based on the doses and ignoring the gender variable as follows:
The 𝑑𝐹 for 𝑆𝑆𝑔𝑒𝑛𝑑𝑒𝑟×𝑑𝑜𝑠𝑒 is the multiplication of the 𝑑𝐹 for both variables = 2. It can also be
determined by subtracting the 𝑑𝐹 of both variables from the 𝑑𝐹 of 𝑆𝑆𝑀 (5 – 1 – 2 = 2).
Finally, the residual sum of squares 𝑆𝑆𝑅 is the difference between 𝑆𝑆𝑇 and 𝑆𝑆𝑀 = 8,966.7 –
5,479.17 = 3,487.53. Alternatively, 𝑆𝑆𝑅 can be computed as: 𝑠12 (𝑛1 − 1) + 𝑠22 (𝑛2 − 1) + ⋯ +
𝑠𝑛2 (𝑛𝑛 − 1). The numbers 1, 2, … , 𝑛 correspond to the groups. So 𝑆𝑆𝑅 = 24.554 (8 – 1) + 106.696
(8 – 1) + 42.857 (8 – 1) + 156.696 (8 – 1) + 50 (8 – 1) + 117.411 (8 – 1) =3,487.5. The 𝑑𝐹 for the
𝑆𝑆𝑅 is the number of groups × (number of observations in each group – 1) = 6 × (8 – 1) = 42.
12
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Now that we have the sum of squares and the corresponding 𝑑𝐹’s, we can calculate the mean sum
of squares and the 𝐹 ratios.
168.75
𝑀𝑆𝑔𝑒𝑛𝑑𝑒𝑟 = = 168.75
1
3,332.3
𝑀𝑆𝑑𝑜𝑠𝑒 = = 1,666.15
2
1,978.13
𝑀𝑆𝑔𝑒𝑛𝑑𝑒𝑟×𝑑𝑜𝑠𝑒 = = 989.07
2
3,487.53
𝑀𝑆𝑅 = = 83.04
42
The 𝐹-ratio is computed by dividing the mean sum of squares by the residual mean sum of squares
as follows:
𝑀𝑆𝑔𝑒𝑛𝑑𝑒𝑟 168.75
𝐹𝑔𝑒𝑛𝑑𝑒𝑟 = = = 2.032
𝑀𝑆𝑅 83.04
𝑀𝑆𝑑𝑜𝑠𝑒 1,666.15
𝐹𝑑𝑜𝑠𝑒 = = = 20.06
𝑀𝑆𝑅 83.04
𝑀𝑆𝑔𝑒𝑛𝑑𝑒𝑟×𝑑𝑜𝑠𝑒 989.07
𝐹𝑔𝑒𝑛𝑑𝑒𝑟×𝑑𝑜𝑠𝑒 = = = 11.91
𝑀𝑆𝑅 83.04
Each of the above 𝐹-ratios can then be compared against a critical value obtained from the 𝐹-
distribution (based on the 𝑑𝐹’s) to determine if the effect of each predictor is significant or not.
13
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Remember that this is an independent design (different participants were assigned to the different
groups). Go to Analyze General Linear Model Univariate. Select the independent and
dependent variables as shown in the Figure below.
14
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
The “Model” button will allow you to customize the model (for instance, you may only want to
test the main effects rather than the full factorial effects). The “Model” becomes handy if we have
3 or more independent variables. We will keep the default settings in “Model”.
Click on “Plots” to select the graphs you want to appear in your output. One of the most useful
graphical outputs in factorial ANOVA is the interaction graph which helps us understand the
combined effect of gender and dose. Select the variables as shown in the Figure below.
Click “Add” and if there are no additional graphs you wish to plot, click “Continue”.
“Contrasts” will allow you to establish useful comparisons using the SPSS standard contrasts. One
disadvantage of contrasts is that they compare the main effects but not the interactions. For the
gender variable, there is no need to establish a contrast because there are only two categories under
this variable. For the dose variable, there are 3 levels so we can select different options for contrasts
(from the Contrast dropdown list) such as:
15
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Simple contrast, which compares each level to the first category. In our example, SPSS
will compare the low to the placebo and the high to the placebo.
Repeated contrast, which compares each level to the previous one. In our example, it will
compare the low to the placebo and then the high to the low.
Helmert contrast, which compares each level to all subsequent levels. In our example, it
will compare the placebo to the low and high dose groups and then will compare the low
to the remaining groups (only the high).
We will use “Helmert contrast for the dose variable as shown in the Figure below (remember to
click “Change” to save the contrast).
16
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Click continue to go back to the main dialogue box and click “Options” and select the options
shown in the Figure below.
Click “Continue” to go back to the main dialogue box and then click “OK” to view the output.
17
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
SPSS output
The first output is the descriptive statistics table as shown below. These descriptive statistics were
already computed when we first discussed the concepts of ANOVA (page 10 of these handouts).
Descriptive Statistics
Dependent Variable: Outcome
Gender Dose Mean Std. Deviation N
Male Placebo 66.8750 10.32940 8
Low 66.8750 12.51784 8
High 35.6250 10.83562 8
Total 56.4583 18.50259 24
Female Placebo 60.6250 4.95516 8
Low 62.5000 6.54654 8
High 57.5000 7.07107 8
Total 60.2083 6.33815 24
Total Placebo 63.7500 8.46562 16
Low 64.6875 9.91106 16
High 46.5625 14.34326 16
Total 58.3333 13.81232 48
The next table is Levene’s test output which tells us that the variances are homogenous.
The most important output is the “Tests of Between-Subjects Effects” shown below. From this
table, we can conclude that there is a significant main effect of the dose. This conclusion can be
confirmed by looking at the “Descriptive Statistics” Table from which we can see that the placebo
and the low dose effects have close means (63.75 and 64.69, respectively) while the high is much
less than the two (46.56). The gender effect on the outcome is not significant. Again, going back
to the “Descriptive Statistics” table, we can see that the overall means of the female and male
18
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
groups are pretty close (56.45 and 60.21, respectively). We can also take a look at the graphical
output we requested (“Estimated Marginal Means of Outcome”). Finally, we can conclude that the
interaction between gender and dose has a significant effect on the outcome. In other words, this
informs us that the effect of the dose on the outcome was different for male participants and female
participants. If we inspect the “Estimated Marginal Means of Outcome” Figure, we can see that
the dose has very little effect for female participants while there is a pronounced effect of the dose
(high dose) for male participants. In general, non-parallel lines in this Figure indicate a significant
interaction effect.
Notice that we earlier concluded that the dose has a significant effect but based on the interaction
analysis, we were able to identify that the dose’s effect is only significant for male participants.
This indicates that the main effects can be misleading in factorial designs.
19
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
The “Contrast Results (K Matrix)” Table is the result of the Helmert contrast analysis (only on the
dose). You can see that the table is divided into two main components. The first is the “Level 1 vs.
Later” which compares the first category (placebo) to the other two groups. So the comparison is
between the mean of the placebo (63.75) to the mean of the other two groups [(64.69 + 46.56)/2 =
55.63]. The difference between the two means = 63.75 – 55.63 = 8.12. This difference (contrast)
is significant. This implies that any amount of the drug will be significant but this is misleading
because if we inspect the placebo and low groups, we can be certain that these two groups are
almost similar.
The second component of the table is the “Level 2 vs. Level 3” contrast which tests the difference
between the low and the high groups. The difference is 18.125 which is also significant.
The next output is the “Multiple Comparisons” table which presents the post hoc results.
Remember that we only asked for post hoc tests for the dose variable. The results in the table
inform us that the placebo and low dose groups are not significantly different whereas the high
group is significantly different from the other two groups. Remember that the post hoc tests
(similar to contrasts) do not inform us on the interactive effect of the two independent variables.
20
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Multiple Comparisons
Dependent Variable: Outcome
The “Homogeneous Subsets” table provides similar conclusions in which the placebo and low
groups are combined as homogenous subsets (equal means).
21
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Outcome
Subset
Dose N 1 2
Tukey HSDa,b High 16 46.5625
Placebo 16 63.7500
Low 16 64.6875
Sig. 1.000 .954
Ryan-Einot-Gabriel-Welsch High 16 46.5625
b
Range Placebo 16 63.7500
Low 16 64.6875
Sig. 1.000 .772
Means for groups in homogeneous subsets are displayed.
Based on observed means.
The error term is Mean Square(Error) = 83.036.
a. Uses Harmonic Mean Sample Size = 16.000.
b. Alpha = .05.
Questions: What will you infer if the “Estimated Marginal Means of Outcome” looked like this?
We can conclude that the effect is not interactive (as the dose increases, similar trend is observed
for both genders). So when the two lines are almost parallel, we can safely assume that there is no
interaction. However, if the two lines cross, the interaction is significant.
22
Applied Statistics for Engineers – Week 9 Handouts Husam A. Abu Hajar
Question: What if one or more of the factorial assumptions (parametric assumptions) were
broken)?
SPSS does not provide nonparametric counterpart to the factorial ANOVA. Other software might
still be used. Data transformation might provide the solution (for non-normal and/or
heterogeneous-variances data).
Self-study problem
People with obsessive compulsive disorder (OCD) tend to check things too many times, so they
may check whether they locked the door too many times and it will take them forever to leave the
house. One of the OCD theories suggests that it is caused by a combination of the mood (positive
or negative) interacting with your rules on when to stop (you continue the task until you feel like
stopping or until you feel that you’ve done the task as best as possible). Davey et al. (2003) tested
this hypothesis on a group of people by inducing positive mood, negative mood, and no mood in
different participants. The outcome (dependent variable) is the number of things that each
participant will check before leaving home on a holiday. Half of the participants in each mood
were asked to generate items (checks) until they feel like stopping (“as many as can” stop rule)
whereas the other were asked to generate items (checks) for as long as they felt like continuing the
task (“feel like continuing” stop rule). Conduct the proper analysis to test the hypothesis that the
OCD is affected by the combination of the mood and the stop rule. The data is in “Davey et al.
(2003)” data file.
23