I want to use R to simulate discrete data with missing values from a Poisson distribution.
I have tried this: simdata<-rpois(1000,2)
but when I checked if there are missing values, there were none.
$\begingroup$
$\endgroup$
7
-
1$\begingroup$ So, most statistical software has built in functions for this. What software would you like to use? $\endgroup$– J. DekkerCommented Feb 1, 2019 at 6:59
-
1$\begingroup$ Wait... You want to simulate missing data? $\endgroup$– J. DekkerCommented Feb 1, 2019 at 7:03
-
1$\begingroup$ Yes, I want to simulate missing data. $\endgroup$– BeeCommented Feb 1, 2019 at 7:06
-
2$\begingroup$ Of course a built in simulation function will not generate missing values. Consider generating another vector from a binomial distribution n=1000, p=0.99. Then, replace the 0's in that vector by NA, and elementwise multiply the vectors to get a Poisson random variable vector with missing values. $\endgroup$– J. DekkerCommented Feb 1, 2019 at 7:08
-
1$\begingroup$ You have to define a distribution for the missing data, from the probability of missing to the fact that it is missing at random or not (then depending on the realisation). $\endgroup$– Xi'anCommented Feb 1, 2019 at 8:29
|
Show 2 more comments
1 Answer
$\begingroup$
$\endgroup$
Simulating from a Poisson distribution in R: use rpois(n, lambda), with lambda the mean of your process and n the desired length of the vector.