Reputation: 9
I have a dataset that I ran ANCOVA on and did postHoc analysis. when I view the summary of my data by typing summary(data), I only see the t value and p value.
Is there a way I can see cohen's d value on this? Am using the R stats package.
Upvotes: 0
Views: 821
Reputation: 3228
Greetings! First off, you would never use Cohen's d for an ANCOVA. A much more common effect size for ANCOVA is eta squared or partial eta squared. Additionally, I didn't see you post any code or data, so it is hard to guess exactly how you have run your model so far. I can run a model with some data you can use in case you want to at least know how, but next time provide the dput
of your data in your question along with your code you have run so far.
First we can load the effectsize
library to obtain our eta squared estimate and load our data with minor changes.
#### Library ####
library(effectsize)
library(tidyverse)
library(rstatix)
#### Load Data ####
data(obk.long,
package = "afex")
#### Modify Data ####
obk.long <- obk.long[1:240 %% 3 == 0, ]
obk.long$id <- seq_len(nrow(obk.long))
If we look at the data, we can check to see that it is appropriate (at least on the surface) for ANCOVA:
#### Inspect Data ####
glimpse(obk.long)
Here you can see the data from this command:
Rows: 80
Columns: 7
$ id <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1…
$ treatment <fct> control, control, control, control, control, control…
$ gender <fct> M, M, M, M, M, M, M, M, M, M, M, M, M, M, M, F, F, F…
$ age <dbl> -4.75, -4.75, -4.75, -4.75, -4.75, -2.75, -2.75, -2.…
$ phase <fct> pre, post, post, fup, fup, pre, post, post, fup, fup…
$ hour <fct> 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4…
$ value <dbl> 4, 3, 3, 3, 4, 5, 2, 5, 5, 1, 5, 4, 5, 6, 6, 7, 2, 5…
We can then fit an ANCOVA with this model:
#### Fit Data to ANCOVA ####
fit <- aov(value ~ gender + phase + treatment,
data = obk.long)
summary(fit)
Here you can see the summary from the model:
Df Sum Sq Mean Sq F value Pr(>F)
gender 1 9.11 9.11 2.932 0.091 .
phase 2 3.06 1.53 0.493 0.613
treatment 2 81.04 40.52 13.037 1.41e-05 ***
Residuals 74 229.98 3.11
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
We can also look at our pairwise comparisons with this code:
#### Tukey PWC ####
tukey_hsd(fit)
As seen here:
# A tibble: 7 × 9
term group1 group2 null.…¹ estim…² conf.…³ conf.…⁴ p.adj p.adj…⁵
* <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
1 gender F M 0 0.675 -0.110 1.46 9.1 e-2 ns
2 phase fup post 0 -0.125 -1.18 0.929 9.57e-1 ns
3 phase fup pre 0 -0.531 -1.82 0.760 5.89e-1 ns
4 phase post pre 0 -0.406 -1.70 0.885 7.33e-1 ns
5 treatme… contr… A 0 2.04 0.773 3.30 7.14e-4 ***
6 treatme… contr… B 0 2.21 1.10 3.31 2.56e-5 ****
7 treatme… A B 0 0.170 -1.01 1.35 9.37e-1 ns
# … with abbreviated variable names ¹null.value, ²estimate, ³conf.low,
# ⁴conf.high, ⁵p.adj.signif
From there you simply run this code:
#### Run Effect Size ####
eta_squared(fit,
partial = T)
Which gives you the effect size:
# Effect Size for ANOVA (Type I)
Parameter | Eta2 (partial) | 95% CI
-----------------------------------------
gender | 0.04 | [0.00, 1.00]
phase | 0.01 | [0.00, 1.00]
treatment | 0.26 | [0.12, 1.00]
- One-sided CIs: upper bound fixed at [1.00].
There are a number of things you should check with an ANCOVA before running it or obtaining a summary from the model. It is best to make sure it fits all model assumptions before interpreting results like effect sizes. Let me know if this was helpful.
Upvotes: 1