ho_ancova example
ho_ancova example
ho_ancova example
Psy 522/622 Multiple Regression and Multivariate Quantitative Methods, Winter 2024 1
SPSS Syntax
ANCOVA2
*the EMMEANS normally produces estimated (i.e., observed) means but adding the WITH statement and the
covariate name and MEAN gives adjusted means.
GLM w1cesd9 BY w1sex WITH w1adldif
/EMMEANS=TABLES(w1sex) with (w1adldif=mean).
Regression
*center w1adldiff.
*aggregate command finds the mean of the sample which can be used in the subsequent computation.
aggregate /madldif=MEAN(w1adldif).
compute cw1adldif=w1adldif - madldif.
*use a descriptives to check if centered.
1
These data come from the Later Life Study of Social Exchanges (LLSSE) Sorkin, D. H., & Rook, K. S. (2004). Interpersonal control strivings and
vulnerability to negative social exchanges in later life. Psychology and Aging, 19(4), 555–564. https://10.1037/0882-7974.19.4.555. Newsom, J. T.,
Rook, K. S., Nishishiba, M., Sorkin, D. H., & Mahan, T. L. (2005). Understanding the relative importance of positive and negative social exchanges:
Examining specific domains and appraisals. The Journals of Gerontology Series B: Psychological Sciences and Social Sciences, 60(6), P304-P312.
2
GLM does not print the regression coefficient, so could use MANOVA to obtain.
manova w1cesd9 by w1sex(0,1) with w1adldif
/print=signif(efsize)
/design.
Newsom
Psy 522/622 Multiple Regression and Multivariate Quantitative Methods, Winter 2024 2
R Code
ANCOVA
> library(car)
> ancova_model <- aov(w1cesd9 ~ w1sex + w1adldif, data=d)
> Anova(ancova_model, type="III")
Anova Table (Type III tests)
Response: w1cesd9
Sum Sq Df F value Pr(>F)
(Intercept) 2597.8 1 122.5377 <0.0000000000000002 ***
w1sex 10.4 1 0.4918 0.4833
w1adldif 3325.8 1 156.8738 <0.0000000000000002 ***
Residuals 19143.9 903
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> #adjusted means
> library(emmeans)
> marginal = emmeans(ancova_model, ~ w1sex)
> summary(marginal)
w1sex emmean SE df lower.CL upper.CL
0 4.97 0.249 903 4.48 5.46
1 5.19 0.195 903 4.81 5.57
Regression
> #listwise deletion to make sure each regression model has same n
> d = d[complete.cases(d[,c("w1sex","w1cesd9","w1adldif")]),]
> #always check to make sure this worked
> #summary(d)
> #listwise deletion to make sure each regression model has same n when centering
> d = d[complete.cases(d[,c("w1sex","w1cesd9","w1adldif")]),]
> #center (create deviation scores of) the covariate first
> d$cadldif <- scale(d$w1adldif, center = TRUE, scale = FALSE)
> #always check to make sure this worked
> #summary(d)
>
> #hierarchical regression using base R function lm
> model1 = lm(w1cesd9~w1sex, data=d)
> model2 = lm(w1cesd9~w1sex + cadldif, data=d)
> summary(model1)
Call:
lm(formula = w1cesd9 ~ w1sex, data = d)
Residuals:
Newsom
Psy 522/622 Multiple Regression and Multivariate Quantitative Methods, Winter 2024 3
> summary(model2)
Call:
lm(formula = w1cesd9 ~ w1sex + cadldif, data = d)
Residuals:
Min 1Q Median 3Q Max
-11.446 -3.072 -1.021 1.869 21.719
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.9660 0.2493 19.919 <0.0000000000000002
w1sex 0.2230 0.3179 0.701 0.483
cadldif 3.1350 0.2503 12.525 <0.0000000000000002
Write-up
I illustrate a write-up of both methods here, but there would never be a reason to do a regression analysis
and an ANCOVA to test the same hypothesis.
ANCOVA Results
An analysis of covariance (ANCOVA) was conducted to test for mean differences between men and women
on depression after controlling for physical impairment. Descriptive statistics indicated that women had
higher depression scores than men, with M = 5.394 and M = 4.633, respectively. The results for the
ANCOVA, however, indicated that there was no gender difference once physical impairment was controlled
for, F(1,903) = .49, p = .48. The adjusted means indicated a small difference between male (M = 5.19) and
female (M = 4.97) depression scores once physical impairment was taken into account. The covariate,
physical impairment, was significantly related to depression, however, B = 3.135, 95% CI[2.64,3.62], SE =
.250, = .387, p < .001. Both independent variables together accounted for approximately 15% of the
variance in depression, R2 = .153, F(2,903) = 81.35, p < .001.
Regression Results
A multiple regression model was tested to examine whether gender was related to depression after
controlling for physical impairment. Although previous analyses showed that gender had a significant
association with depression without controlling for other factors, gender was no longer significant once
physical functioning was included in the model, B = .223, SE = .318, = .022, p = .48. The unstandardized
coefficient indicated that women had a mean depression score that was only .223 points higher than the
mean depression score for men. Physical impairment was a significant predictor of depression, however, B
= 3.135, 95% CI[2.64,3.62], SE = .250, = .387, p < .001, indicating that depression scores were
approximately three points higher for each unit increase of the physical impairment scale. The standardized
coefficient suggested that this was a moderate effect. Approximately 15% of the variance in depression was
accounted for by both predictors considered together, R2 = .153, F(2,903) = 81.35, p < .001.