I have Y being binomially distributed with probability 0.1 and N=100 . And independent variable x with normally distributed mean 0 and 0.5. and I want to generate MNAR mechanism on Y.
To generate MNAR data you can use a data generating process where the missingness mechanism depends on the unobserved data.
# Generate the true data
y1 <- rbinom(100, size=1, prob=0.1)
# Generate the missing process. Depends on the "true" observed value
r <- rbinom(length(y1), size=1, prob=c(.25, .1)[y1+1])
y <- y1
y[r==1] <- NA
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.