< 1:ncol(x)中的错误:长度为0的参数.在R中使用Amelia时 [英] "Error in 1:ncol(x) : argument of length 0" when using Amelia in R

查看:1286
本文介绍了< 1:ncol(x)中的错误:长度为0的参数.在R中使用Amelia时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理面板数据.我已经进行了6,000多个国家/地区年度观测,并指定了以下Amelia估算值:

I am working with panel data. I have well over 6,000 country-year observations, and have specified my Amelia imputation as follows:

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

运行这些代码行时,我继续收到以下错误:

When I run those lines of code, I continue to receive the following error:

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

我已经看到人们会遇到类似的错误,但是情况有所不同.重要的是,我在Amelia代码中遗漏了几个连续的独立变量,因为我的印象是,无需这样做就可以插补它们.有谁知道:

I've seen people get a similar error, but in different contexts. Importantly, there are several continuous independent variables I left out of the Amelia code, because I am under the impression that they get imputed WITHOUT having to do so. Does anyone know:

1)此错误是什么意思? 2)如何更正此错误?

1) What this error means? 2) How to correct this error?

更新1:在上面的示例代码中,就我的计数面板数据中的变量类型而言,提供了更多的上下文.

Update #1: Provided more context, in terms of the types of variables in my count panel data, in the above sample code.

更新#2:我做了一些研究,并遇到一个包含函数

Update #2: I did some research, and ran into an R file containing a function that diagnoses possible errors for Amelia code. After running the code, I got the following error message first (and many more thereafter):

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参数中放置的国家/地区变量没有缺失值.但是,第一个大块"错误让我相信是这样.

Currently, there are no missing values for the country variable I place in the idvars argument. However, the very first "chunk" of errors wants me to believe that this is so.

我没有正确指定上面的Amelia代码吗?

Am I not properly specifying the Amelia code I have above?

推荐答案

我忘了在原始Amelia代码中指定数据框(拍打额头).因此,现在,在解决了上述怪异的问题之后,我从Amelia收到了以下错误消息:

I had forgotten to specify the dataframe in the original Amelia code (slaps hand on forehead). So now, after resolving the whacky issue above, I am getting the following error from Amelia:

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

我已经检查了变量名,并且它们逐字匹配了我在数据框中命名的变量名.

I've checked the variable names, and they match, verbatim, to what I named them in the dataframe.

这篇关于&lt; 1:ncol(x)中的错误:长度为0的参数.在R中使用Amelia时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆