简体   繁体   English

使用 MuMIn 中的挖泥机错误:未找到 object

[英]Using dredge from MuMIn error: object not found

Code and output代码和output

 > dredge(regional ~ national, foreign, tbili2_recip, data = s2)
 Error in eval(.expr_beta_arg) : object 'foreign' not found

Sample data样本数据

 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")

I am actually trying to do this for a few different variables than shown here, but all are having the same issue.实际上,我正在尝试对一些与此处显示的变量不同的变量执行此操作,但所有变量都有相同的问题。 Anything obvious I am overlooking?有什么明显的我忽略了吗? Variables are all numeric and it works in a typical lm().变量都是数字的,它在典型的 lm() 中工作。

I checked the other posts on stackoverflow on this topic with no luck.我检查了有关此主题的 stackoverflow 上的其他帖子,但没有运气。

Try this:尝试这个:

model <- lm(regional ~ national + foreign + tbili2_recip, data=s2)
options(na.action = "na.fail")
dredge(model)

You need first to fit a model (I used lm because it is the basic one) and then you can use it as an argument to dredge .您首先需要安装一个 model (我使用lm因为它是基本的),然后您可以将其用作dredge的参数。 Also, as you can see here dredge function error - R package MuMln , you need the options(na.action = "na.fail") in order to make it work.另外,正如您在此处看到的疏通 function 错误 - R package MuMln ,您需要options(na.action = "na.fail") Finally, formulas use + and not , so we need regional ~ national + foreign + tbili2_recip最后,公式使用+而不是,所以我们需要regional ~ national + foreign + tbili2_recip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM