View source: R/dataSimulation.R
simDat8 | R Documentation |
Simulate wing length measurements of mourning cloak butterflies with two factors (habitat and population) including their interaction if so wished (simulation under a fixed-effects model)
simDat8(
nPops = 5,
nHab = 3,
nSample = 12,
baseline = 40,
pop.eff = c(-10, -5, 5, 10),
hab.eff = c(5, 10),
interaction.eff = c(-2, 3, 0, 4, 4, 0, 3, -2),
sigma = 3
)
nPops |
Number of populations |
nHab |
Number of habitats |
nSample |
Samples from each population-habitat combination |
baseline |
Grand mean length |
pop.eff |
Population effects, should be nPops - 1 values |
hab.eff |
Habitat effects, should be nHab - 1 values |
interaction.eff |
Interaction effects, should be (nPops-1)*(nHab-1) values |
sigma |
Value for the residual standard deviation |
A list of simulated data and parameters.
nPops |
Number of populations |
nSample |
Number of samples per population |
baseline |
Grand mean length |
pop.eff |
Population effects |
hab.eff |
Habitat effects |
interaction.eff |
Interaction effects |
sigma |
Residual SD |
all.eff |
All effects |
pop |
Indicator for population number |
hab |
Indicator for habitat number |
eps |
Simulated residuals |
wing |
Simulated wing lengths |
Marc Kéry
str(dat <- simDat8()) # Implicit default arguments (for the model with interactions)
# Model with main effects only (and very large sample size; to minimize sampling error
# and clarify structure of main effects in plot)
str(dat <- simDat8(nSample = 1000, interaction.eff = c(0,0,0,0, 0,0,0,0)))
str(dat <- simDat8(nSample = 10000, interaction.eff = rep(0, 8))) # same, even larger sample size
# Revert to one-way ANOVA model with only effects of pop (with much larger sample size)
str(dat <- simDat8(nSample = 10000, pop.eff = c(-10, -5, 5, 10),
hab.eff = c(0, 0), interaction.eff = rep(0, 8))) # note no effect of habitat
# Revert to one-way ANOVA model with only effects of hab
str(dat <- simDat8(nSample = 10000, pop.eff = c(0, 0, 0, 0),
hab.eff = c(5, 10), interaction.eff = rep(0, 8))) # note no effect of pop
# Revert to "model-of-the-mean"
str(dat <- simDat8(nSample = 10000, pop.eff = c(0, 0, 0, 0),
hab.eff = c(0, 0), interaction.eff = rep(0, 8))) # note no effect of pop nor of h
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.