我试图将rdd包中的rdds模型输入到模型摘要中,但我做不到。这是我的代码:
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....""发布于 2022-04-09 18:36:07
再看一遍错误:
*Assertion failed. One of the following must apply:
checkmate::check_character(estimate): Must have length 1, but has length 3
checkmate::check_character(estimate): Must have length 8, but has length 3*这指的是estimate参数,它说应该长度为1或长度为8,这是因为列表中有8种模型。因此,要么只为estimate提供一个值,要么为每个模型提供1个值。您提供了3,这不符合任何一项条件。
https://stackoverflow.com/questions/71807836
复制相似问题