IQSS / Amelia

Amelia: A Package for Missing Data
http://gking.harvard.edu/amelia
61 stars 17 forks source link

Plot #2

Closed vonera closed 9 years ago

vonera commented 11 years ago

I'm using Amelia 1.7.1, R 3.0.1

by trying to plot the result of an amelia run i get the following error

Error in compare.density(output = x, var = which.vars[i], legend = FALSE, : The 'var' option points to a non-existant column.

my test data is a 500 by 4 matrix with time in the first column and doubles in 2,3 and 4 columns (2,3,4 contain missing values)

-------------------------------------------------------------------------------------------------------

require(Amelia) require(R.matlab)

with_missings <- readMat("Artdata_wm_xt2_ut2.mat") time_series = as.matrix(with_missings$simp) time_series[is.nan(time_series)] <- NA

colnames(time_series) <- c("time","S2", "u_sin","u_lin")

a.out <- amelia(x = time_series, m=1, ts=1, lgstc=c("S2"), lags=c("S2","u_sin"), leads=c("S2","u_sin"), polytime = 3) summary(a.out) plot(a.out)

---------------------------------------------------------------------------------------------------------

if i change the last line to plot(a.out, which.vars <- c(2,3,4)) its working fine.

----------------------------------------------------------------------------------------------------------

Calling plot.amelia() without specification of vars: It seems that the problem is caused by the following line

numericVars <- sapply(x$imputations[[1]], "is.numeric")

changing it to

numericVars <- sapply(x$imputations$imp1[1,], "is.numeric") or numericVars <- sapply(x$imputations[[1]][1,], "is.numeric") solved the problem.

mattblackwell commented 9 years ago

This was an issue with matrix inputs as opposed to data.frame inputs. Should be fixed in develop branch. Should be out in 1.7.3