8.2 Zero-inflated Poisson
squidSim doesn’t generate zero-inflated data directly, but it can be easily made. For example, we can simulate a Poisson variable and a binomial variable, and multiply them together to get our zero-inflated response.
<- simulate_population(
squid_data make_structure(structure = "mother(100)",repeat_obs=5),
n_response = 2,
response_names = c("reproduction","survival"),
parameters=list(
intercept = c(1,0),
mother = list(
vcov = matrix(c(
0.25,0.15,
0.15,1
nrow=2,ncol=2,byrow=TRUE)
),
), residual = list(
vcov = matrix(c(
0.25,0.15,
0.15,1
nrow = 2,ncol = 2,byrow=TRUE),
),beta = matrix(c(
1,0,
0,0
nrow = 2,ncol = 2,byrow=TRUE)
),
)
),family=c("poisson","binomial"),
link=c("log","probit")
)
<- get_population_data(squid_data)
data $y <- data$survival * data$reproduction
data
head(data,10)
## reproduction survival mother_effect1 mother_effect2 residual1 residual2
## 1 4 1 0.9589855 0.3766668 -0.101258109 -1.1813681
## 2 6 1 0.9589855 0.3766668 -0.677575423 -0.1428024
## 3 5 0 0.9589855 0.3766668 0.170956330 -0.8288192
## 4 10 1 0.9589855 0.3766668 -0.338957058 1.2039968
## 5 5 0 0.9589855 0.3766668 -0.538933535 -0.2629109
## 6 2 0 -0.5529803 -0.8500533 0.389632791 -0.9633320
## 7 2 0 -0.5529803 -0.8500533 1.223938421 -0.5031933
## 8 1 1 -0.5529803 -0.8500533 -0.095311820 0.3464985
## 9 1 0 -0.5529803 -0.8500533 -0.005642962 -0.3820496
## 10 1 0 -0.5529803 -0.8500533 -0.055796092 1.3805831
## mother squid_pop y
## 1 1 1 4
## 2 1 1 6
## 3 1 1 0
## 4 1 1 10
## 5 1 1 0
## 6 2 1 0
## 7 2 1 0
## 8 2 1 1
## 9 2 1 0
## 10 2 1 0
plot(table(data$y))