Hi Albrecht,
Hello,
I am just starting to work with Amelia. The examples from the vignette work all fine, but when I use my own dataset which is being imported from a *.csv, I get the error message "WError in matrix(1, AMn, 1) : non-numeric matrix extent", which is a mystery to me.
Since I am working on computer with a German locale (WinXP) it might have something to do with the imported dataframe. However, from the error message I cannot spot the problem. Attached you find a minimal script and *.csv that should reproduce the error. Any hint how to handle this problem would be greatly appreciated.
With best regards from Berlin,
Albrecht Gradmann
P.S.: This is my first post to an R-related helplist. Please let me know if essential information is missing or improperly posted.
## Minimal script to reproduce error
##
## startup-stuff
library(reshape)
library(Amelia)
## read.csv that
## - considers ":" as NA
## - skips the first 10 rows that are used to supply metainfo
## - does not alter the column names by adding Xes (Stata-convention)
##
name.dates <- read.csv2("minimal.csv",na.strings = ":",skip=10,check.names=FALSE)
# drop superfluous las column
name.dates <- name.dates[,1:13]
## melt and reshape so that the year information is put in colums
melt.dates <- melt(name.dates, id = c("Indicator","Group","Country"))
head(melt.dates)
# Change modes to make summary look like summary(freetrade) from
# Amelia tutorial
melt.dates$value<-as.numeric(melt.dates$value)
melt.dates$variable <- as.character(melt.dates$variable)
melt.dates$variable <- as.integer(melt.dates$variable)
melt.dates$Country <- as.character(melt.dates$Country)
summary(melt.dates)
head(melt.dates)
## Start using Amelia ##
amelia(melt.dates,m=1,ts="variable",cs="Country",idvars=c("Indicator","Group"))
# --> WError in matrix(1, AMn, 1) : non-numeric matrix extent
amelia(melt.dates[,c("Country","variable","value")],m=1,ts="variable",cs="Country")
# --> WError in matrix(1, AMn, 1) : non-numeric matrix extent