simDat14: Simulate data for Chapter 14: Poisson GLMM

View source: R/dataSimulation.R

simDat14R Documentation

Simulate data for Chapter 14: Poisson GLMM

Description

Simulate count ~ year regressions in 16 populations of red-backed shrikes

Usage

simDat14(
  nPops = 16,
  nYears = 30,
  mu.alpha = 3,
  sigma.alpha = 1,
  mu.beta = -2,
  sigma.beta = 0.6
)

Arguments

nPops

Number of populations

nYears

Number of years sampled in each population

mu.alpha

Mean of random intercepts

sigma.alpha

SD of random intercepts

mu.beta

Mean of random slopes

sigma.beta

SD of random slopes

Value

A list of simulated data and parameters.

nPops

Number of populations

nYears

Number of years sampled

mu.alpha

Mean of random intercepts

sigma.alpha

SD of random intercepts

mu.beta

Mean of random slopes

sigma.beta

SD of random slopes

pop

Population index

orig.year

Year values, non-scaled

year

Year values, scaled to be between 0 and 1

alpha

Random intercepts

beta

Random slopes

C

Simulated shrike counts

Author(s)

Marc Kéry

Examples

library(lattice)
str(dat <- simDat14())
xyplot(dat$C ~ dat$orig.year | dat$pop, ylab = "Red-backed shrike counts", xlab = "Year", pch = 16,
       cex = 1.2, col = rgb(0, 0, 0, 0.4), 
       main = 'Realized population trends\n(random-coefficients model)') # works

# Revert to random intercept model. Increased sigma.alpha to emphasize the random intercepts part
str(dat <- simDat14(nPops = 16, sigma.alpha = 1, sigma.beta = 0))
xyplot(dat$C ~ dat$orig.year | dat$pop, ylab = "Red-backed shrike counts", xlab = "Year",
       pch = 16, cex = 1.2, col = rgb(0, 0, 0, 0.4), 
       main = 'Realized population trends (random-intercepts model)')

# Revert to random-effects one-way Poisson ANOVA model: random intercepts, but zero slopes
str(dat <- simDat14(nPops = 16, sigma.alpha = 1, mu.beta = 0, sigma.beta = 0))
xyplot(dat$C ~ dat$orig.year | dat$pop, ylab = "Red-backed shrike counts", xlab = "Year",
       pch = 16, cex = 1.2, col = rgb(0, 0, 0, 0.4), 
       main = 'Realized population trends
       (random-effects, one-way Poisson ANOVA model)')

# Revert to simple log-linear Poisson regression (no effects of pop on intercepts or slopes)
str(dat <- simDat14(nPops = 16, sigma.alpha = 0, sigma.beta = 0))
xyplot(dat$C ~ dat$orig.year | dat$pop, ylab = "Red-backed shrike counts", 
       xlab = "Year", pch = 16, cex = 1.2, col = rgb(0, 0, 0, 0.4), 
       main = 'Realized population trends\n(simple log-linear Poisson regression)')

# Revert to Poisson "model-of-the-mean": no effects of either population or body length
str(dat <- simDat14(nPops = 16, sigma.alpha = 0, mu.beta = 0, sigma.beta = 0))
xyplot(dat$C ~ dat$orig.year | dat$pop, ylab = "Red-backed shrike counts", 
       xlab = "Year", pch = 16, cex = 1.2, col = rgb(0, 0, 0, 0.4), 
       main = 'Realized population trends\n(Poisson "model-of-the-mean")')


ASMbook documentation built on Sept. 11, 2024, 5:38 p.m.

Related to simDat14 in ASMbook...