簡體   English   中英

使用 MuMIn 中的挖泥機錯誤:未找到 object

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

代碼和output

 > 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() 中工作。

我檢查了有關此主題的 stackoverflow 上的其他帖子,但沒有運氣。

嘗試這個:

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

您首先需要安裝一個 model (我使用lm因為它是基本的),然后您可以將其用作dredge的參數。 另外,正如您在此處看到的疏通 function 錯誤 - R package MuMln ,您需要options(na.action = "na.fail") 最后,公式使用+而不是,所以我們需要regional ~ national + foreign + tbili2_recip

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM