> [!tldr] Zero-Inflated Distribution > A **zero-inflated distribution** is the mixture between a point mass at $0$ and another (more regular) distribution. For example, a mixture with $\mathrm{Gamma}(3, 0.5)$ looks like > > ![[ZeroInflatedDistributionExample.png#invert|w60|center]] > Here the point-mass has a weight of $p=1 / 6$. > >--- > > This kind of distribution is common in real life, where there are two groups in a population: for example, if the variable is the number of kilometers driven in a car, > - One group always have a response of $0$, e.g. children under 16; > - Another group has a continuous distribution, e.g. the adults. This kind of distribution can be modeled using [[Hurdle Models]]. ```R fold title:"R code for generating the plot" observations = c(rgamma(1000, shape = 3, rate = 0.5), rep(0, 100)) data = data.frame(observations) x = seq(0, 25, by = 0.01) gamma_density = data.frame(x = x, y = dgamma(x, 3, 0.5) * 1000) ggplot() + geom_histogram(data = data, aes(observations, fill = "Zero-Inflated Data"), binwidth = 1) + geom_line(data = gamma_density, aes(x = x, y = y, color = "Gamma Distribution")) + scale_color_manual(name = "", values = c("Gamma Distribution" = "#444444")) + scale_fill_manual(name = "", values = c("Zero-Inflated Data" = "#AAAAAA"))+ labs(x = "Value", y = "Count") + my_theme ```