R语言 gt汇总卡方结果与卡方检验不同

toiithl6  于 2023-04-09  发布在  其他
关注(0)|答案(1)|浏览(135)

我做了两次卡方检验,得到了不同的结果:
(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
谁能解释一下不同的结果?
谢谢

des4xlb0

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

相关问题