【发布时间】:2021-08-05 06:41:34
【问题描述】:
我正在尝试在我的多个估算数据集上使用 gtsummary 包计算全局 p 值。我还没有找到解决方案。我知道 gtsummary 允许在多个估算数据集上生成线性回归,但我不认为 add_global_p() 已为此设置。我知道计算 MI 数据集的 anova 需要使用miceadd 包中的 mi.anova 并且 gtsummary 使用 car::anova() 函数。有人对此有解决方案吗?
# loads relevant packages using the pacman package
pacman::p_load(
tidyverse, # data management and visualization
mice, # for multiple imputation
gtsummary) # for tables
# generate a samall sample of the boys dataset for MI
boys_miss <- sample(head(boys,100))
# impute a sample of the boys dataset
boys_imp <- parlmice(boys_miss,
m = 5,
maxit = 5,
cluster.seed = 1234)
# run linear regression on the imputed dataset
boys_imp %>%
with(.,
lm(wgt ~ reg)
) %>%
tbl_regression() %>%
add_global_p() # when I add this function, I get the below error
x `add_global_p()` uses `car::Anova()` to calculate the global p-value,
and the function returned an error while calculating the p-values.
Is your model type supported by `car::Anova()`?
Error in UseMethod("vcov") :
no applicable method for 'vcov' applied to an object of class "c('mira', 'matrix')"
我希望桌子看起来像这样..
【问题讨论】:
-
你能否包含一个代码示例,计算你想使用 D3 函数添加到表中的 pvalues
-
抱歉,不是来自鼠标的 D3 函数,而是来自 mouseadds 包的 mi.anova 函数计算方差。
miceadds::mi.anova(boys_imp, formula="wgt ~ reg", type=2) -
你能模拟一张你希望你的决赛桌看起来如何的桌子吗?例如保留单个 p 值?忽略它们?
-
没有单个值,只有全局 p 值。见上面的编辑。
标签: r linear-regression gtsummary