1

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

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) What this error means? 2) How to correct this error?

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

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

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.

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

ealfons1
  • 353
  • 1
  • 6
  • 24
  • It probably means that `x` is actually zero length vector of some sort. But beyond that, it's nearly impossible for anyone to debug this _for_ you without access to your data. If we can't run your code and produce the same error, it's quite hard to be of much help. – joran Aug 31 '13 at 03:05
  • [Read](http://stackoverflow.com/q/4442518/324364) about how to debug errors and then edit your question to provide more detailed information based on what you find. – joran Aug 31 '13 at 03:06
  • Without seeing more, I'd say you are hitting a bug in the function you are calling. Seeing 1:nrow(x) (or 1:ncol(x)) is typically a bug in R code, though it will work most of the time. You are usually much better off with a statement like seq_len(NROW(x)) over 1:nrow(x), as this eliminates two bugs at once (1) NULL x, and (2) not null but 0-row x. – leif Aug 31 '13 at 04:42
  • I would run `options(error = recover)` before calling the function, so you can inspect the environment right where the error happens and figure it out on your own. – flodel Aug 31 '13 at 04:44

1 Answers1

2

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.

ealfons1
  • 353
  • 1
  • 6
  • 24