IQSS / Amelia

Amelia: A Package for Missing Data

Home Page:http://gking.harvard.edu/amelia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug when `NA`s are present in date/time variables supplied to `idvars`

ngreifer opened this issue · comments

amcheck() checks to see if there are any NA values in any POSIXt (date/time) variables in the dataset and throws an error if so, but it runs the check for all variables in the dataset, not just those not named in idvars. It should ignore variables named in idvars, as these will neither be imputed nor used in the imputation but may exist in the dataset as metadata. The simple fix is to exclude the idvars variables in the check for POSIXt variables.

Amelia/R/amcheck.r

Lines 941 to 947 in 4de6306

if (is.data.frame(x)) {
is.posix <- function(x) inherits(x, c("POSIXt", "POSIXct", "POSIXlt"))
posix.check <- sapply(x, is.posix)
if (any(is.na(x[, posix.check]))) {
stop("NA in POSIXt variable: remove or convert to numeric")
}
}