如何将Modelsummary与rddpackage一起使用?
我正在尝试将我的RDDS模型从RDD软件包输入到模型摘要中,而我不能。 这是我的代码:
rdd_model_names <- paste0("model", 1:8)
rdd_model <- list(ll1_covs, ll1_no_covs, ll2_covs, ll2_no_covs, ll3_covs, ll3_no_covs, ll4_covs, ll4_no_covs)
tidy.RD <- function(rdd_model, nm) {
s <- summary(rdd_model)
df <- data.frame(s$coefficients[1, c(1:4,6), drop = FALSE])
print(class(df))
df$term <- nm
df
}
rd_outputs <- lapply(1:8, function(i) tidy.RD(rdd_model[[i]], rdd_model_names[i]) ) %>% bind_rows()
rd_outputs
rdd_table <- modelsummary(rd_outputs, statistic = "p.value") %>%
kable_styling(bootstrap_options = c("striped", "hover")) %>%
add_header_above(c(" "= 2, "Female Share" = 2, "Pre-natal care"= 2, "Daycare enroll" = 2, "Pre-scool enroll" = 2)) ```
""The error that I get is:
Warning in get_gof(models[[j]], vcov_type[[i]], ...) :
`modelsummary could not extract goodness-of-fit statistics from a model
of class "data.frame". The package tried a sequence of 2 helper functions....""
I am trying to input my rdds model from rdd package into model summary and I can't.
This is my code:
rdd_model_names <- paste0("model", 1:8)
rdd_model <- list(ll1_covs, ll1_no_covs, ll2_covs, ll2_no_covs, ll3_covs, ll3_no_covs, ll4_covs, ll4_no_covs)
tidy.RD <- function(rdd_model, nm) {
s <- summary(rdd_model)
df <- data.frame(s$coefficients[1, c(1:4,6), drop = FALSE])
print(class(df))
df$term <- nm
df
}
rd_outputs <- lapply(1:8, function(i) tidy.RD(rdd_model[[i]], rdd_model_names[i]) ) %>% bind_rows()
rd_outputs
rdd_table <- modelsummary(rd_outputs, statistic = "p.value") %>%
kable_styling(bootstrap_options = c("striped", "hover")) %>%
add_header_above(c(" "= 2, "Female Share" = 2, "Pre-natal care"= 2, "Daycare enroll" = 2, "Pre-scool enroll" = 2)) ```
""The error that I get is:
Warning in get_gof(models[[j]], vcov_type[[i]], ...) :
`modelsummary could not extract goodness-of-fit statistics from a model
of class "data.frame". The package tried a sequence of 2 helper functions....""
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
再看一下错误:
这是指
estimate
参数,它表示它的长度应该是 1 或长度 8。这是因为您的列表中有 8 个模型。因此,您要么只为估计
提供一个值,要么为每个模型提供 1 个值。您提供了 3,它不满足任何一个条件。Look at the error again:
This refers to the
estimate
argument, and it says that it should be either of length 1 or of length 8. This is because there are 8 models in your list. So either you supply only one value forestimate
, or you supply 1 value per model. You supplied 3, which does not fulfill either of the conditions.