简体   繁体   English

如何在R中生成随机缺失(MNAR)数据?

[英]How to generate Missing Not at random (MNAR) data in R?

I have Y being binomially distributed with probability 0.1 and N=100 . 我让Y以二项式分布的概率为0.1且N = 100。 And independent variable x with normally distributed mean 0 and 0.5. 自变量x的正态分布均值为0和0.5。 and I want to generate MNAR mechanism on Y. 我想在Y上生成MNAR机制。

To generate MNAR data you can use a data generating process where the missingness mechanism depends on the unobserved data. 要生成MNAR数据,您可以使用数据生成过程,其中缺失机制取决于未观察到的数据。

# 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM