Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when NAs are present in date/time variables supplied to idvars #52

Open
ngreifer opened this issue Feb 14, 2024 · 0 comments
Open

Comments

@ngreifer
Copy link

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")
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant