simDat18: Simulate data for Chapter 18: model selection

View source: R/dataSimulation.R

simDat18R Documentation

Simulate data for Chapter 18: model selection

Description

Simulate counts of rattlesnakes in Virginia

Usage

simDat18(
  nSites = 100,
  beta1.vec = c(1, 0.2, 0.5, 1, -1),
  ncov2 = 50,
  beta2.vec = rnorm(50, 0, 0),
  show.plot = TRUE
)

Arguments

nSites

Sample size (number of snakes)

beta1.vec

Values of log-linear intercept and coefs of rock, oak, and chip (linear and squared), in this order

ncov2

Number of 'other' covariates

beta2.vec

Values of coefs of the 'other' covariates (all continuous). All at zero by default

show.plot

Switch to turn on or off plotting. Set to 'FALSE' when running sims

Value

A list of simulated data and parameters.

nSites

Sample size

rock

Rock covariate vector

oak

Oak covariate vector

chip1

Chip covariate vector

chip2

Chip^2 covariate vector

Xrest

Array of "other" covariate values

beta1.vec

Parameter values for intercept, rock, oak, chip, chip^2

ncov2

Number of "other" covariates

beta2.vec

Vector of coefficient values for "other" covariates

C

Simulated rattlesnake counts

Author(s)

Marc Kéry

Examples

str(dat <- simDat18())  # With default arguments

#### First variant of data simulation: beta1.vec is identical, beta2.vec is not
# Variant B: execute when you want to play with a small data set
set.seed(18)
trainDat <- simDat18(nSites = 50, beta1.vec = c(1, 0.2, 0.5, 1, -1), ncov2 = 10,
                     beta2.vec = rnorm(10, 0, 0.1), show.plot = TRUE)
testDat <- simDat18(nSites = 50, beta1.vec = c(1, 0.2, 0.5, 1, -1), ncov2 = 10,
                    beta2.vec = rnorm(10, 0, 0.1), show.plot = TRUE)
# Note how relatively different the two realizations of the SAME process are  

#### Second variant of data simulation: both beta1.vec and beta2.vec are identical

# Variant B: execute when you want to play with a small data set
set.seed(18)
beta2.vec <- rnorm(10, 0, 0.1)
trainDat <- simDat18(nSites = 50, beta1.vec = c(2, 0.2, 0.5, 1, -1), ncov2 = 10,
                     beta2.vec = beta2.vec, show.plot = TRUE)
testDat <- simDat18(nSites = 50, beta1.vec = c(2, 0.2, 0.5, 1, -1), ncov2 = 10,
                    beta2.vec = beta2.vec, show.plot = TRUE)
# Note how relatively different the two realizations of the SAME process are


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

Related to simDat18 in ASMbook...