1
$\begingroup$

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.

$\endgroup$
7
  • 1
    $\begingroup$ So, most statistical software has built in functions for this. What software would you like to use? $\endgroup$
    – J. Dekker
    Commented Feb 1, 2019 at 6:59
  • 1
    $\begingroup$ Wait... You want to simulate missing data? $\endgroup$
    – J. Dekker
    Commented Feb 1, 2019 at 7:03
  • 1
    $\begingroup$ Yes, I want to simulate missing data. $\endgroup$
    – Bee
    Commented 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. Dekker
    Commented 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'an
    Commented Feb 1, 2019 at 8:29

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.