sim: Simulating Overdispersed and/or Zero-Inflated Count Data with...

View source: R/sim.R

simR Documentation

Simulating Overdispersed and/or Zero-Inflated Count Data with Random Effects

Description

This function is to simulate overdispersed and/or zero-inflated count data with random effects.

Usage

sim(n.ind = 100, n.measure = 10, 
    x.d, coef.d = 1, tau.d = 1.5, 
    x.z, coef.z = 0, tau.z = 0, p.zero = 0, 
    theta = 2)

Arguments

n.ind

number of individuals (or clusters).

n.measure

number of measures for each individual.

x.d

design matrix of fixed-effects in the count part (distribution part). If not given, x.d will be generated as a binary predictor internally.

coef.d

coefficients of x.d.

tau.d

standard deviation of random effect in the count part.

x.z

design matrix of fixed-effects in the zero-inflation part.

coef.z

coefficients of x.z.

tau.z

standard deviation of random effect in the zero-inflation part.

p.zero

proportion of zeros from the the point mass at zero (i.e., not from the negative binomial count distribution).

theta

shape parameter for negative binomial model of the count part.

Value

a list containing individual ID ind.ID, design matrices x.d and x.z, Total number T, and count response y.

Author(s)

Nengjun Yi, nyi@uab.edu

Examples


library(NBZIMM)

d = sim(n.ind = 100, n.measure = 10, coef.d = 1, tau.d = 1.5, 
        theta = 2, p.zero = 0)
ind = d$ind.ID
x = d$x.d
y = d$y
off = log(d$T)

f1 = glmm.nb(y ~ offset(off) + x, random = ~ 1|ind) 
summary(f1)
f1$theta

d = sim(n.ind = 100, n.measure = 10, coef.d = 1, tau.d = 1.5, 
        theta = 2, p.zero = 0.4)
ind = d$ind.ID
x = d$x.d
y = d$y
off = log(d$T)

f1 = glmm.zinb(y ~ offset(off) + x | 1, random = ~ 1|ind)
summary(f1)
f1$theta
unique(f1$zero.prob)


nyiuab/NBZIMM documentation built on June 14, 2024, 1:45 a.m.