Learn R Programming

ASMbook (version 1.0.2)

simDat123: Simulate data for Chapter 12.3: Zero-inflated counts

Description

Generate counts of hares in two landuse types when there may be zero-inflation (this is a simple general hierarchical model, see Chapters 19 and 19B in the book)

Usage

simDat123(nSites = 50, alpha = log(2), beta = log(5) - log(2), psi = 0.2)

Value

A list of simulated data and parameters.

nSites

Number of sites

alpha

Intercept

beta

Slope for land use

psi

Zero inflation parameter

w

Indicator that count is not a structural 0

C

Simulated hare counts with zero inflation

Arguments

nSites

Number of sites

alpha

Intercept

beta

Slope for land use

psi

Zero inflation parameter (probability of structural 0)

Author

Marc Kéry

Examples

Run this code
str(dat <- simDat123())      # Implicit default arguments

# Drop zero inflation (and make sample sizes bigger)
str(dat <- simDat123(nSites = 1000, psi = 0))     # Note 0 % of the sites have structural zeroes now

# Half of all sites have structural zeroes
str(dat <- simDat123(nSites = 1000, psi = 0.5))

# Revert to "model-of-the-mean" without zero inflation
# 0 % of the sites have structural zeroes
str(dat <- simDat123(nSites = 1000, beta = 0, psi = 0))

# Revert to "model-of-the-mean" with zero inflation
# 50 % of the sites have structural zeroes
str(dat <- simDat123(nSites = 1000, beta = 0, psi = 0.5))

Run the code above in your browser using DataLab