total_trials <- 1000
more_significant_count <- 0
for (i in 1:total_trials) {
age <- rnorm(50, mean = 45, sd = 10)
mecfs_status <- rbinom(50, 1, prob = 0.5)
niirf <- age + mecfs_status + rnorm(50, mean = 0, sd = 1)
model1 <- lm(niirf ~ 1) # Intercept only
model2 <- lm(niirf ~ mecfs_status)
anova_1_2 <- anova(model1, model2)
anova_1_2_pval <- anova_1_2[['Pr(>F)']][[2]]
model3 <- lm(niirf ~ age)
model4 <- lm(niirf ~ mecfs_status + age)
anova_3_4 <- anova(model3, model4)
anova_3_4_pval <- anova_3_4[['Pr(>F)']][[2]]
if (anova_1_2_pval > anova_3_4_pval) {
more_significant_count <- more_significant_count + 1
}
}
print(paste0("In ", more_significant_count, " out of ", total_trials, " total trials (", 100*more_significant_count/total_trials, "%), the p-value when adding ME/CFS status to an intercept-only model was higher (less significant) than the p-value when adding ME/CFS status to a model with an age covariate."))
anova_1_2
anova_3_4