Learn R Programming

ASMbook (version 1.0.2)

simDat13: Simulate data for Chapter 13: Poisson ANCOVA

Description

Simulate parasite load ~ size regressions in 3 populations of goldenring dragonflies

Usage

simDat13(nPops = 3, nSample = 100, beta.vec = c(-2, 1, 2, 4, -2, -5))

Value

A list of simulated data and parameters.

nPops

Number of populations

nSample

Number of samples per population

beta

Vector of regression coefficients

x

Indicator for population number

pop

Population name (factor)

orig.length

Wing length, non-centered

wing.length

Wing length, centered

load

Simulated parasite loads

Arguments

nPops

Number of populations

nSample

Number of samples per population

beta.vec

Vector of regression coefficients

Author

Marc Kéry

Examples

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

# Revert to main-effects model with parallel lines on the log link scale
str(dat <- simDat13(nSample = 100, beta.vec = c(-2, 1, 2, 4, 0, 0)))

# Same with less strong regression coefficient
str(dat <- simDat13(nSample = 100, beta.vec = c(-2, 1, 2, 3, 0, 0)))

# Revert to simple linear Poisson regression: no effect of population (and less strong coefficient)
str(dat <- simDat13(nSample = 100, beta.vec = c(-2, 0, 0, 3, 0, 0)))

# Revert to one-way ANOVA Poisson model: no effect of wing length
# (Choose larger sample size and greater differences in the intercepts to better show patterns)
str(dat <- simDat13(nSample = 100, beta.vec = c(-1, 3, 5, 0, 0, 0)))

# Revert to Poisson "model-of-the-mean": no effects of either wing length or population
# Intercept chosen such that average parasite load is 10
str(dat <- simDat13(nSample = 100, beta.vec = c(log(10), 0, 0, 0, 0, 0)))
mean(dat$load)        # Average is about 10

Run the code above in your browser using DataLab