I am trying to generate MCAR, MAR and MNAR data. MCAR and MNAR are relatively easy. However I am struggling with MAR data.
I generate 500 observations with 2 variables (Y and X) out of a multivariate normal distribution with correlation 0.7.
library(mvtnorm) set.seed(1994) nobs = 500 nvar = 2 corr = 0.7 miss.prop = 0.4 mu <- rep(0,nvar) Sigma <- matrix(corr, nrow=nvar, ncol=nvar) + diag(nvar)*(1-corr) #draw from a multivariate normal y <- rmvnorm(n=nobs, mean=mu, sigma=Sigma)
Then I use the package CoImp such that
y.miss <- MAR(y, perc.miss = 0.4, setseed = 1994)@db.missing
Then I make a plot of the whole data. Black dots are the complete observations and the orange-ish triangles are the the missing data (so in theory we wouldn't observe them, but because it is simulated data we can see them :P ).
However, I am not sure how this algorithm is working because I do not really see any pattern on the data. As long as I understand missing values on Y should be dependent on the value of X..
I would really appreciate some clarification on this and maybe some short code on how to manually simulate MAR data.