编码和输出
> dredge(regional ~ national, foreign, tbili2_recip, data = s2)
Error in eval(.expr_beta_arg) : object 'foreign' not found样本数据
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()中工作。
我查看了关于这个话题的堆叠溢出的其他文章,没有任何运气。
发布于 2019-11-15 17:43:38
试试这个:
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
https://stackoverflow.com/questions/58881799
复制相似问题