I have this df
df
# A tibble: 248 × 2
asignado mxsitam
<chr> <chr>
1 Control No
2 Control No
3 Intervencion No
4 Intervencion Si
5 Intervencion Si
6 Intervencion Si
7 Control No
8 Intervencion Si
9 Control Si
10 Control Si
# ℹ 238 more rows
I want to use add_difference() and also calculate the p-value of the result obtained.
This is the code.
aticamama %>%
select(c("asignado",
mxsitam)) %>%
mutate(mxsitam= as.integer(if_else(mxsitam== "No", 0,1))) %>%
tbl_summary(by= "asignado",
missing = "always",
digits = list(all_categorical() ~ c(0,1)),
statistic = list(all_categorical() ~ "{n} ({p})"),
missing_text= "Casos perdidos",
percent= "column") %>%
add_overall() %>%
modify_header(label = "") %>%
add_difference()
This is the output
As you can see my diference is -6,9% and my p-value is 0,5.
But when I use prop.test() to calculate my CI it gaves me another p value.
aticamama$variable1 <- factor(aticamama$asignado)
aticamama$variable2 <- factor(aticamama$mxsitam)
tabla_contingencia <- table(aticamama$variable1, aticamama$variable2)
tabla_contingencia
> tabla_contingencia
No Si
0 92 33
1 82 41
resultado_prueba <- prop.test(tabla_contingencia)
resultado_prueba
> resultado_prueba
2-sample test for equality of proportions with continuity correction
data: tabla_contingencia
X-squared = 1,1116, df = 1, p-value = 0,2917
alternative hypothesis: two.sided
95 percent confidence interval:
-0,05236089 0,19102756
sample estimates:
prop 1 prop 2
0,7360000 0,6666667
Now it shows that my p-value is 0,2917. Why?
Also, why with add_p() it doesn't give me a CI?
Why my p-value isn't the same with prop.test() and gtsummary()