r - svyglm 和交互包在 R4.0.2 而不是 R3.6.3 中显示错误
问题描述
我有一个 syvglm 代码,可以在 R3.6.3 中使用,但在 R4.0.2 中不能使用(它会给出以下错误消息:
对于 svylgm:
错误:必须使用有效的下标向量子集元素。x 下标类型错误
omit
。i 它必须是逻辑、数字或字符。回溯:
- 调查::svyglm(...)
- 调查:::svyglm.survey.design(...)
- 调查:::
[.survey.design2
(设计, -nas, )- base::
[.data.frame
(x$variables, i, ..1, drop = FALSE)- vctrs:::
[.vctrs_vctr
(xj, i)- vctrs:::vec_index(x, i, ...)
- vctrs::vec_slice(x, i)
对于交互包:
错误:<labelled> - 不允许回溯:
- 交互::probe_interaction(...)
- 交互作用::sim_slopes(...)
- 交互:::center_ss(...)
- 交互:::center_ss_survey(...)
- jtools::gscale(vars = ndfvars, data = design, center.only = TRUE) ...
- vctrs:::
-.vctrs_vctr
(左,右)- 避风港:::vec_arith.haven_labelled.default("-", e1, e2)
- vctrs::stop_incompatible_op(op, x, y)
- vctrs:::stop_incompatible(...)
- vctrs:::stop_vctrs(...)
我的代码是:
design <-
svydesign(
id = ~I_i ,
data = sm ,
weights = ~w ,
)
fit <- svyglm(sc ~ sex + school +sex*school, design)
summary(fit)
probe_interaction(fit, pred = school, modx = sex)
我希望继续使用 R4.0.2,因为降级 R 会给其他 R 包带来很多问题。probe_Interaction 部分也不适用于旧版本的 R(PC 计算机)。任何线索出了什么问题?
数据:
structure(list(I_i = structure(c(-54, 1000987, 1000166), label = "ID institution", format.spss = "F39.0", display_width = 39L, labels = c(Filtered = -99, Don't know = -98, Refused = -97, Not in list = -96, Implausible value = -95, Not reached = -94, Does not apply = -93, Question erroneously not asked = -92, Survey aborted = -91, Unspecific missing = -90, Not participated = -56, Not determinable = -55, Missing by design = -54, Anonymized = -53, Implausible value removed = -52, No estimate in check module = -51 ), class = c("haven_labelled", "vctrs_vctr", "double")), w = c(0.197917401820921, 0.186422150045312, 0.275986837527898),sc = c(NA, 7.66666666666667, 8.66666666666667 ), sex = structure(c(1, 1, 0), label = "Gender", format.spss = "F3.0", display_width = 9L, labels = c(Implausible value = -95, Unspecific missing = -90, Missing by design = -54, <U+0085> male? = 1, <U+0085> female? = 2), class = c("haven_labelled", "vctrs_vctr", "double")), school = c(NA, 1L, 1L)), row.names = c(NA, 3L), class = "data.frame")
解决方案
推荐阅读
- python - 如何在 Django 中设置外键条件
- c# - 在某些项目中,BeforeBuild 目标永远不会被执行
- python - 如何在列表中搜索名称并使用 oop - python 中的方法将其删除
- swiftui - SwiftUI 和 AppKit:如何知道窗口是否聚焦
- flutter - 如何修复非空字符串必须提供给文本小部件?
- android - 如何在 android studio 中修复我的 sdk 文件夹错误
- c++ - C++ - 返回带有未知模板参数的模板
- flutter - 数据未插入多个 Hive Box
- python - 如何在到达 mainloop() 之前更新 tkinter 窗口
- python - 如何正确处理多个运行时错误?