jamovi / jmv

jamovi for R
https://www.jamovi.org
57 stars 27 forks source link

Can't verify post hoc effect size option from ancova() #306

Open carlosivanr opened 3 years ago

carlosivanr commented 3 years ago

Hi there. I'm relatively new to the jmv package and have been trying it in R. I really like it so far, but I'm running into an issue with calculating effect sizes for the post hoc tests in a one way ANCOVA with three groups. I'm using a sample dataset from Maxwell, Delaney, & Kelly's text in the AMCP R package. I've tried running the analysis with jmv and with an approach described in Field et al., 2012. Everything checks out for the two approaches except for the effect sizes in the post-hoc comparisons. I'm attaching a copy of the code which should run as long as the packages are installed. Is there something that I'm missing about how to properly configure the ancova() function in jmv? Any help on this would be greatly appreciated.

# --- One way ANCOVA jmv
library(AMCP)
library(jmv)

# Load data
data(chapter_9_table_7)

# Convert group to factor
chapter_9_table_7$Condition <- as.factor(chapter_9_table_7$Condition)

# one way ANCOVA in jmv
ancova(formula = Post ~ Pre + Condition,
       data = chapter_9_table_7,
       ss = "3",
       effectSize = 'partEta',
       postHoc = ~ Condition,
       postHocCorr = 'bonf',
       postHocES = "d",
       emMeans = ~ Condition)

# Effect sizes are 0.3361555, 0.4873439, 0.1508555

# ---- One way ANCOVA non-jmv
# Approach described in Field et al., 2012
library(car)
library(effects)
library(compute.es)

# Create ANCOVA model
model <- aov(Post ~ Pre + Condition, data = chapter_9_table_7)

# Display type 3 ss results
Anova(model, type = "3")

# Display emmeans and confidence intervals
em_means <- effect("Condition", model, se = TRUE)
summary(em_means)

# Display the standar errors
em_means$se

# Display the standard deviations, estimated by multiplying se by the sqrt of n
n <- c(10,10,10)
em_means$se*sqrt(n)

# Use the em_means, sd, and n for post hoc effect sizes
# Grp 1 vs 2
mes(7.536616, 11.984895, 5.398312, 5.397476, 10, 10 )

# Grp 1 vs 3
mes(7.536616, 13.978489, 5.398312, 5.393536, 10, 10)

# Grp 2 vs 3
mes(11.984895, 13.978489, 5.397476, 5.393536, 10, 10)

# Effect sizes are 0.82, 1.19, 0.37
jonathon-love commented 3 years ago

could you try using the latest version of jmv from our repo, and see if that brings things into alignment?

remotes::install_github('jamovi/jmv')

# this might be necessary first, not sure:

remotes::install_github('jamovi/jmvcore')

CRAN raised a bunch of requirements for submitting packages, which make it difficult for us to push updates.

with thanks

jonathon

carlosivanr commented 3 years ago

Hi Jonathon,

Thanks! The post-hoc effect sizes are now displayed correctly. That's a bummer to hear that there are barriers to getting packages updated. Good thing there a work around and will keep it in mind if I run into anything else down the line.

For what it's worth, I did have to run this line to get things to work and I'm running Rstudio 1.2.5042, R 4.0.0, and macOS 10.15.7 (Catalina)

remotes::install_github('jamovi/jmvcore')

Thanks again,

C