Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

ho_ancova example

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Newsom

Psy 522/622 Multiple Regression and Multivariate Quantitative Methods, Winter 2024 1

Analysis of Covariance (ANCOVA) Example


Sex and Depression with Physical Impairment as a Covariate
This example illustrates the equivalence of the regression and ANCOVA approaches to investigating
whether sex differences in depression still exist after taking into account differences in physical functioning
(activities of daily living or ADLs). Because the approaches are statistically equivalent, there would never be
any need to do both analyses. Also, I used a hierarchical regression here to illustrate the change after
adding the covariate but there is absolutely no need to use hierarchical entry.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).

Estimated Marginal Means

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.

regression vars=w1cesd9 w1sex cw1adldif


/descriptives=mean stdev n sig corr
/statistics=anova r coeff ses cha
/dependent=w1cesd9
/method=enter w1sex /enter cw1adldif.

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

Confidence level used: 0.95

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

Min 1Q Median 3Q Max


-5.394 -3.633 -1.394 2.367 20.606
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.6334 0.2684 17.262 <0.0000000000000002
w1sex 0.7602 0.3411 2.229 0.0261

Residual standard error: 4.986 on 904 degrees of freedom


Multiple R-squared: 0.005464, Adjusted R-squared: 0.004364
F-statistic: 4.966 on 1 and 904 DF, p-value: 0.02609

> 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

Residual standard error: 4.604 on 903 degrees of freedom


Multiple R-squared: 0.1527, Adjusted R-squared: 0.1508
F-statistic: 81.35 on 2 and 903 DF, p-value: < 0.00000000000000022

> # test change in R-sq for adding cadldif, if desired


> #manually compute change in R-sq for adding cadldif, if desired
> deltr2 = summary(model2)$r.squared - summary(model1)$r.squared
> deltr2
[1] 0.147203

> #test R-sq for significance


> anova(model1,model2)
Analysis of Variance Table
Model 1: w1cesd9 ~ w1sex
Model 2: w1cesd9 ~ w1sex + cadldif
Res.Df RSS Df Sum of Sq F Pr(>F)
1 904 22470
2 903 19144 1 3325.8 156.87 < 0.00000000000000022

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.

You might also like