首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从MuMIn错误中使用疏浚:找不到对象

从MuMIn错误中使用疏浚:找不到对象
EN

Stack Overflow用户
提问于 2019-11-15 17:16:09
回答 1查看 135关注 0票数 1

编码和输出

代码语言:javascript
复制
 > dredge(regional ~ national, foreign, tbili2_recip, data = s2)
 Error in eval(.expr_beta_arg) : object 'foreign' not found

样本数据

代码语言:javascript
复制
 s2 <- structure(list(regional = c(0, 0, 0, 0, 0, 1), national = c(0, 
 0, 0, 0, 0, 0), foreign = c(0, 0, 0, 0, 0, 0), tbili2_recip = c(1, 
 1, 0, 1, 0, 0), tbili16_recip = c(0, 0, 0, 0, 0, 0), tbili32_recip = c(0, 
 0, 0, 0, 0, 1), tbili33_recip = c(0, 0, 0, 0, 0, 0), tbil_don1 = c(0, 
 0, 0, 0, 0, 0), tbil_don18 = c(1, 0, 0, 0, 1, 0), tip = c(0, 
 0, 0, 0, 0, 0), wit70 = c(0, 0, 0, 0, 0, 0), wit80 = c(0, 0, 
 0, 0, 0, 0), wit90 = c(0, 0, 0, 0, 0, 0), wit91 = c(0, 0, 0, 
 0, 0, 0), weight_diff = c(-3, -9, -33, 18, -8, -26), weight45 = c(0, 
 0, 0, 0, 0, 0), weight70 = c(0, 0, 0, 0, 0, 0), weight_neg45 = c(0, 
 0, 0, 0, 0, 0), weight_neg70 = c(0, 0, 0, 0, 0, 0), work = c(0, 
 0, 0, 0, 0, 0)), row.names = c(NA, 6L), class = "data.frame")

实际上,我试图对几个不同的变量这样做,但所有的变量都有相同的问题。有什么明显的我忽略了吗?变量都是数字变量,它在典型的lm()中工作。

我查看了关于这个话题的堆叠溢出的其他文章,没有任何运气。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-15 17:43:38

试试这个:

代码语言:javascript
复制
model <- lm(regional ~ national + foreign + tbili2_recip, data=s2)
options(na.action = "na.fail")
dredge(model)

首先需要拟合一个模型(我使用了lm,因为它是基本的),然后您可以使用它作为dredge的参数。此外,正如您在这里看到的dredge function error - R package MuMln,您需要options(na.action = "na.fail")才能使它工作。最后,公式使用的是+而不是,,因此我们需要regional ~ national + foreign + tbili2_recip

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58881799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档