simDat9: Simulate data for Chapter 9: ANCOVA or general linear model

View source: R/dataSimulation.R

simDat9R Documentation

Simulate data for Chapter 9: ANCOVA or general linear model

Description

Simulate mass ~ length regressions in 3 populations of asp vipers

Usage

simDat9(
  nPops = 3,
  nSample = 10,
  beta.vec = c(80, -30, -20, 6, -3, -4),
  sigma = 10
)

Arguments

nPops

Number of populations

nSample

Samples from each population

beta.vec

Vector of regression parameter values

sigma

Value for the residual standard deviation

Value

A list of simulated data and parameters.

nPops

Number of populations

nSample

Number of samples per population

beta.vec

Regression parameter values

sigma

Residual SD

x

Indicator for population number

pop

Population name (factor)

lengthC

Centered body length for each viper

mass

Simulated body mass for each viper

Author(s)

Marc Kéry

Examples

# Implicit default arguments (with interaction of length and pop)
str(dat <- simDat9())

# Revert to main-effects model with parallel lines
str(dat <- simDat9(beta.vec = c(80, -30, -20, 6, 0, 0)))

# Revert to main-effects model with parallel lines 
# (larger sample size to better show patterns)
str(dat <- simDat9(nSample = 100, beta.vec = c(80, -30, -20, 6, 0, 0)))

# Revert to simple linear regression: no effect of population 
# (larger sample size to better show patterns)
str(dat <- simDat9(nSample = 100, beta.vec = c(80, 0, 0, 6, 0, 0)))

# Revert to one-way ANOVA model: no effect of body length 
# (larger sample size to better show patterns)
str(dat <- simDat9(nSample = 100, beta.vec = c(80, -30, -20, 0, 0, 0)))

# Revert to "model-of-the-mean": no effects of either body length or population)
str(dat <- simDat9(nSample = 100, beta.vec = c(80, 0, 0, 0, 0, 0)))


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

Related to simDat9 in ASMbook...