All distributions share the same latent variable \(\eta_{ij} = a + b_i\) with \(b_i = N(0, \sigma_r)\)

generate_data(a = 0, sigma_random = 0.5, n_random = 20,
  n_replicate = 10, nb_size = 1, b_size = 5, zero_inflation = 0.5)

Arguments

a

the intercept of the latent variable

sigma_random

The standard error for the random effect \(\sigma_r\)

n_random

the number of random effect levels (groups)

n_replicate

the number of observation per random effect level

nb_size

the size parameter of the negative binomial distribution. Passed to the size parameter of rnbinom

b_size

the size parameter of the binomial distribution. Passed to the size parameter of rbinom

zero_inflation

the probability the the observed value stems for the a point mass in zero

Value

A data.frame

  • ìd the id of the random effect

  • eta the latent variable

  • zero_inflation use the point mass in zero

  • poisson the Poisson distributed variable

  • zipoisson the zero-inflated Poisson distributed variable

  • negbin the negative binomial distributed variable

  • zinegbin the zero-inflated negative binomial distributed variable

  • binom the binomial distributed variable

Details

  • The Poisson distribution uses \(\lambda = e^{\eta_{ij}}\)

  • The negation binomial distribution uses \(\mu = e^{\eta_{ij}}\)

  • The binomial distribution uses \(\pi_{ij} = e^{\eta_{ij}}/(e^{\eta_{ij}}+ 1)\)

See also

Examples

set.seed(20181202) head(generate_data())
#> group_id observation_id eta zero_inflation poisson zipoisson negbin #> 1 1 1 0.5510209 FALSE 2 2 4 #> 2 2 2 1.0340814 FALSE 3 3 2 #> 3 3 3 -0.4308339 TRUE 0 0 3 #> 4 4 4 0.4349636 TRUE 1 0 3 #> 5 5 5 -0.2710201 FALSE 0 0 1 #> 6 6 6 -1.2489241 TRUE 0 0 0 #> zinegbin binom #> 1 4 5 #> 2 2 4 #> 3 0 0 #> 4 0 2 #> 5 1 1 #> 6 0 2