Randomly choosing values ​​from a zero bloated distribution in R

Hi and thanks for the help!

And back, I asked a question about randomly choosing values ​​according to the probability distribution. This is connected, but I think he deserves his own post.

The vector I created in the last question was binary, now I would like to create a weighted vector (i.e. with bounded integers). I take a sample from a distribution with a zero or quasi-bulk distribution with a long tail, so there is a much higher probability of choosing zero than another value, but there is a finite probability of choosing a large value (for example, 63).

I can use rpois to select values ​​from a poisson distribution and create a vector of a given length. This is similar to what I would like to do, so I will use it as an example.

e=seq(0:63) vec<-c(0,0,0,1,1,1) ones <- which(vec == 1L) temp=rpois((sum(vec)),e) vec[ones]<-temp 

This works well for assigning a certain number of values ​​selected from a distribution of poissons to a vector. Is there a way to make it quasipoasson or zero inflated?

+1
source share
1 answer

There is a large list of different distributions here: http://cran.r-project.org/web/views/Distributions.html

For zero inflated Poisson ...

 install.packages("gamlss.dist") library(gamlss.dist) rZIP(n, mu, sigma) 

For quasi-poissons, it seems that there are some features in the VGAM package with quasipoissonff, but it looks like it fits, rather than generates. It looks like Arthur Charpentier was here, but you really need to know what you are looking for in order to distribute: http://freakonometrics.blog.free.fr/index.php?post/2010/10/21/How-to- genrerate-variables-from-a-quasi-Poisson-distribution

+4
source

All Articles