簡體   English   中英

“1中的錯誤:ncol(x):長度為0的參數”在R中使用Amelia時

[英]“Error in 1:ncol(x) : argument of length 0” when using Amelia in R

我正在使用面板數據。 我有超過6,000個國家年度觀察結果,並指定了我的Amelia估算如下:

(CountDependentVariable, m=5, ts="year", cs="cowcode", 
                sqrts=c("OtherCountVariable2", "OtherCount3", "OtherCount4"),
                ords=c("OrdinalVar1", "Ordinal Variable 2"), 
                lgstc=c("ProportionVariale"),
                noms=c("NominalVar1"),p2s = 0, idvars = c("country"))

當我運行這些代碼行時,我繼續收到以下錯誤:

Error in 1:ncol(x) : argument of length 0

我看到人們得到類似的錯誤,但在不同的情況下。 重要的是,我從Amelia代碼中遺漏了幾個連續的獨立變量,因為我認為它們被假定為沒有必要這樣做。 有人知道嗎:

1)這個錯誤意味着什么? 2)如何糾正此錯誤?

更新#1:在上面的示例代碼中,根據計數面板數據中的變量類型提供了更多上下文。

更新#2:我做了一些研究,並遇到了一個R文件,其中包含一個診斷 Amelia代碼可能出錯的函數。 運行代碼后,我首先收到以下錯誤消息(此后還有更多錯誤消息):

AMn<-nrow(x)
Error in nrow(x) : object 'x' not found
AMp<-ncol(x)
Error in ncol(x) : object 'x' not found
subbedout<-c(idvars,cs,ts)
Error: object 'idvars' not found

Error Code: 4
if (any(colSums(!is.na(x)) <= 1)) {
all.miss <- colnames(x)[colSums(!is.na(x)) <= 1]
if (is.null(all.miss)) {
all.miss <- which(colSums(!is.na(x)) <= 1)
  }
all.miss <- paste(all.miss, collapse = ", ")
error.code<-4
error.mess<-paste("The data has a column that is completely missing or only has one,observation.  Remove these columns:", all.miss)
return(list(code=error.code,mess=error.mess))
}
Error in is.data.frame(x) : object 'x' not found

Error codes: 5-6
Errors in one of the list variables
idout<-listcheck(idvars,"One of the 'idvars'")
Error in identical(vars, NULL) : object 'idvars' not found

目前,我在idvars參數中放置的國家/地區變量沒有缺失值。 然而,錯誤的第一個“大塊”讓我相信這是如此。

我沒有正確指定上面的Amelia代碼嗎?

我忘了在原始的Amelia代碼中指定數據幀(在額頭上用手拍)。 所以現在,在解決了上面的問題之后,我收到了來自Amelia的以下錯誤:

Amelia Error Code:  44 
 One of the variable names in the options list does not match a variable name in the data.

我檢查了變量名稱,它們逐字匹配到我在數據幀中命名的名稱。

暫無
暫無

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

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