I have a dataset with time-series and cross-sectional variables with a sample size of less than 100. I have three variables (var1
, var2
, var3
) that do not vary over time and a time-series variable (var4
) that does vary over time.
I plan to examine associations between var1
and var2
, var2
and var4
, and var3
and var4
. Before analysis, I want to conduct multiple imputation (mice). My <100 sample size and general research questions bar me from using SEM or path analysis, and therefore I don't believe FIML as a missing data treatment is an option for me.
If I wasn't conducting mice, I would examine var1
and var2
using a wide-form dataset, and examine other associations involving var4
with a long-form dataset. However, I believe it would be unwise to have more than one multiply-imputed dataset. Due to the variance inherent in mice, var2
will have different imputed values between the datasets. While I haven't read about this specific issue in the literature, it seems like a bad idea. Additionally, I want to avoid conducting analysis with var1
and var2
on a long-form dataset due to the variables' cross-sectional nature.
Is it possible to rectify both issues at the same time, or do I need to give in on one of them? If I have misunderstood anything, please correct me.
set.seed(1234)
library(tidyverse)
library(missMethods)
library(mice)
id <- rep(1:10)
var1 <- sample(1:10, 10, replace = TRUE)
var2 <- sample(1:20, 10, replace = TRUE)
var3 <- sample(10:30, 10, replace = TRUE)
wide <- data.frame(id, var1, var2, var3) %>%
delete_MCAR(p = .2, cols_mis = c("var1", "var2", "var3"))
id <- rep(1:10, each = 10)
time <- rep(1:10, times = 10)
var4 <- rnorm(10)
long <- data.frame(id, time, var4) %>%
delete_MCAR(p = .2, cols_mis = "var4")
df <- merge(wide, long, by = "id")
imputed_wide <- mice::mice(data = wide, m = 5, seed = 1234,
printFlag = FALSE)
imputed_long <- mice::mice(data = df, m = 5, seed = 1234,
printFlag = FALSE)
# Same analysis, different results on different data
summary(pool(with(data = imputed_wide, exp = lm(var1 ~ var2))))
#> term estimate std.error statistic df p.value
#> 1 (Intercept) 6.19456035 1.9042540 3.25301157 3.969347 0.03163845
#> 2 var2 -0.01256283 0.1725381 -0.07281189 3.987911 0.94546139
summary(pool(with(data = imputed_long, exp = lm(var1 ~ var2))))
#> term estimate std.error statistic df p.value
#> 1 (Intercept) 6.1510957 0.47795118 12.869716 93.92766 1.895427e-22
#> 2 var2 -0.0441173 0.04124086 -1.069747 95.42650 2.874315e-01
# Compare mean and SD of var2 between datasets
## Wide
impdat <- complete(imputed_wide, action = "long", include = FALSE)
pool_mean <- with(impdat, by(impdat, .imp, function(x)
c(mean(x$var2), sd(x$var2))))
Reduce("+", pool_mean)/length(pool_mean)
#> [1] 9.380000 6.124072
## Long
impdat <- complete(imputed_long, action = "long", include = FALSE)
pool_mean <- with(impdat, by(impdat, .imp, function(x)
c(mean(x$var2), sd(x$var2))))
Reduce("+", pool_mean)/length(pool_mean)
#> [1] 9.816000 6.076727