alexanderrobitzsch / miceadds

Some Additional Multiple Imputation Functions, Especially for 'mice'.
https://alexanderrobitzsch.github.io/miceadds/
16 stars 2 forks source link

warning message when using datalist2mids #3

Closed sdaza closed 6 years ago

sdaza commented 6 years ago

When using datalist2mids I get this error I don't know what is about.

Warning message in data.matrix(x):
“NAs introduced by coercion”Warning message in data.matrix(x):
“NAs introduced by coercion”Warning message in data.matrix(x):
“NAs introduced by coercion”Warning message in data.matrix(x):
“NAs introduced by coercion”

Any hints?

alexanderrobitzsch commented 6 years ago

Am 16.04.2018 um 20:09 schrieb Sebastian Daza:

When using datalist2mids I get this error I don't know what is about.

Warning message in data.matrix(x):
“NAs introduced by coercion”Warning message in data.matrix(x):
“NAs introduced by coercion”Warning message in data.matrix(x):
“NAs introduced by coercion”Warning message in data.matrix(x):
“NAs introduced by coercion”

Any hints?

Could you please provide a reproducible script and data?

--

...........................................

Alexander Robitzsch IPN - Leibniz-Institut für die Pädagogik der Naturwissenschaften und Mathematik an der Universität Kiel Olshausenstraße 62, D-24098 Kiel Tel.: +49 (0)431 880-3487, Fax: -5211 E-Mail: robitzsch@ipn.uni-kiel.de Raum: Olshausenstraße 62, Raum 37

https://sites.google.com/site/alexanderrobitzsch http://www.ipn.uni-kiel.de/de

...........................................

sdaza commented 6 years ago

Here a reproducible example:

library(data.table)
library(miceadds)
library(Amelia)
library(readr)
file = 'https://raw.githubusercontent.com/sdaza/lambda/master/notebooks/chile.csv'

data = data.table(read_csv(file))

vars = c('water', 'sewage', 'elec')
i = which(names(data) %in% vars)
bounds = cbind(i, rep(0, length(i)), rep(100, length(i)))

imp1 = amelia(as.data.frame(data), 
              bounds = bounds, 
              m=5, # only five!
              ts = 'year', cs = 'ctry', 
              splinetime = 4, intercs = TRUE,  
              p2s = 0, 
              logs=c('igdp_pc', 'iurban', 'ilit', 'itfr','Ex', 'water', 'sewage', 'elec'), 
              lags = c('igdp_pc', 'Ex', 'iurban', 'itfr', 'ilit'), 
              leads = c('Ex', 'igdp_pc', 'iurban', 'itfr', 'ilit'),
              empri = .01*nrow(data))

imputations = datalist2mids(imp1$imputations)