我做了两次卡方检验,得到了不同的结果:
(1)gt摘要
table1_demographic_data <-
subsetted.demographic %>%
tbl_summary(by= post_covid_dic,
missing = "no",
missing_text= "NA",
type= list(comorbid_HTN ~ "dichotomous"),
statistic = list(
all_continuous() ~ "{mean}?{sd}",
all_categorical() ~ "{n} ({p}%)"), percent = "row") %>%
add_p() %>%
modify_header(label = "**Variable**", statistic ~ "**Test
Statistic**") %>%
modify_fmt_fun(statistic ~ style_sigfig) %>%
bold_labels() %>%
bold_p() %>%
modify_caption("table 1: Demographic characteristics")
table1_demographic_data
x2=4.3 p=0.039
(2) chisquare.test
chisq.test(subsetted.demographic$post_covid_dic,
subsetted.demographic$comorbid_HTN)
结果:x2=3.8076 p=0.05
谁能解释一下不同的结果?
谢谢
1条答案
按热度按时间des4xlb01#
gt_summary::add_p
的文档说它默认使用卡方检验,没有连续性校正,而stats::chisq.test
默认使用连续性校正。如果你想要连续性校正,我认为你可以将参数
test.args = all_tests("chisq.test") ~ list(correct = TRUE)
添加到gt_summary::add_p
。如果你不想要它,将参数correct=FALSE
添加到stats::chisq.test