我正在使用
rq()
函数(quantreg 包)进行分位数回归。
之前,我们的模型是:
rq_model <- rq(outcome ~ factor(year) + variable2 + variable3, data = data)
我能够使用
modelsummary()
函数(modelsummary 包)和 avg_comparisons
函数(marginaleffects 包)来观察估计值。
modelsummary(rq_model,
estimate = "{estimate} [{conf.low}, {conf.high}]",
statistic = NULL, title = "TITLE")
avg_comparisons(rq_model,
type = "response",
variables = list(year = c(2018, 2022)),
by = "variable3")
avg_predictions(rq_model,
type = "response",
byfun = median,
newdata = "median",
variables = list(year = c(2018, 2019, 2020, 2021, 2022)),
by = c("year","variable3")) %>%
filter(variable3 == 1) %>%
select(year, estimate, conf.low, conf.high) %>%
mutate(round(across(2:4), 3)) %>%
gt::gt() %>%
gt::tab_header(title = "TITLE")
但是,由于审稿人的评论,他们要求我们添加三个新变量,以便模型可以解释归因于这些变量的方差。首先,我收到此警告消息:
rq_model <- rq(outcome ~ factor(year) + variable2 + variable3 + variable01 + variable02 + variable03, data = data)
rq.fit.br(x, y, tau = tau, ...) 中的警告:解决方案可能不唯一
此外,我用
modelsummary()
和 avg_comparison()
: 得到这些错误
modelsummary(rq_model,
estimate = "{estimate} [{conf.low}, {conf.high}]",
statistic = NULL, title = "TITLE")
错误:`modelsummary 无法从类“rq”的模型中提取所需的信息。该包尝试了 用于提取估计值的 2 个辅助函数的序列:
参数::参数(型号) 扫帚::整洁(模型)
要绘制表格,这些命令之一必须返回
,其中包含名为“term”的列。这data.frame
网站解释了如何总结不支持的模型或自己添加对新模型的支持: https://modelsummary.com/articles/modelsummary.htmlmodelsummary
这些错误消息是在提取过程中生成的:
未返回有效的data.frame。parameters::parameters(model)
未返回有效的data.frame。broom::tidy(model)
avg_comparisons(rq_model,
type = "response",
variables = list(year = c(2018, 2022)),
by = "variable3")
警告:无法从此模型中提取方差-协方差矩阵。
avg_predictions(rq_model,
type = "response",
byfun = median,
newdata = "median",
variables = list(year = c(2018, 2019, 2020, 2021, 2022)),
by = c("year","variable3")) %>%
filter(variable3 == 1) %>%
select(year, estimate, conf.low, conf.high) %>%
mutate(round(across(2:4), 3)) %>%
gt::gt() %>%
gt::tab_header(title = "TITLE")
警告:无法从此模型中提取方差-协方差矩阵。
中的错误: 无法选择不存在的列。 列select()
不存在。 回溯:conf.low
- ...%>%...
- dplyr:::select.data.frame(.,年份,估计,conf.low,conf.high)
发生什么事了?当我将这三个变量添加到模型中时,为什么我的脚本不再起作用?这些错误和警告消息意味着什么?
提前谢谢您!
http://www.leddelta.com 详细信息 Карт гратат буран и и и и и в из видео Кадры из видео