llm.sim: Simulate basic log-linear CRC experiments

Description Usage Arguments Details Value Author(s) Examples

View source: R/llsimulate.R

Description

Replicate and summarize the generation and log-linear analysis of data sets that are consistent with arbitrary log-linear models

Usage

1
2
3
llm.sim(n.grid = c(100, 300, 900, 2700), n.reps = 100, u.vec, p0 = NULL,
  models = NULL, ic = "BICpi", cell.adj = TRUE, averaging = FALSE,
  fixed.sample.size = FALSE)

Arguments

n.grid

A vector of positive integers, by default c(100,300,900,2700). Each integer is the number of population units that are observed in a corresponding collection of simulations.

n.reps

The number of replicates for each integer in n.grid, i.e., for each population size of interest.

u.vec

A vector of log-linear parameters, excluding the intercept term. The length of the vector and the order of its terms must correspond to the column names of the design matrix produced by make.design.matrix(k), where k is the number of lists.

p0

Optional: a number in (0,1), the fraction of the population that is to be undetected. See details.

models

See lllcrc

ic

See lllcrc

cell.adj

See lllcrc

averaging

lllcrc

fixed.sample.size

Logical: If TRUE, the simulations fix the number of units that are detected, defining the true population size such that the number of units detected is equal to its expectation. If FALSE, the observed population size is variable, such that the integers in n.grid indicate only the expectations of the corresponding simulation sizes.

Details

u.vec, together with the constraint that the multinomial probabilities sum to 1, uniquely determines the unspecified intercept term. Specifying p0 overdetermines the intercept term. We rectify this overspecification by adjusting all main effects by the same additive adjustment a, where the unique value of a is approximated with numerical methods.

Once the log-linear terms are fully specified, we perform multinomial draws to simulate a CRC experiment. We include the zero cell in the multinomial draw only if fixed.sample.size = TRUE.

On each replicate, the data log-linear model search according to the parameters models, ic, cell.adj, and averaging produces an estimate of the missing cell. The main matrix res of simulation results stores the ratios of the estimated missing cell over the 'true' missing cell.

Value

A list of class llsim, for "log-linear simulations". The list contains the set of multinomial capture pattern probabilities p, the matrix res of simulation results, and many of the arguments to the llm.sim.

Author(s)

Zach Kurtz

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
## A basic simulation with four lists.
#	Begin by specifying the vector of log-linear parameters.
#	The parameters must match the design matrix:
names(make.design.matrix(k=4))
u.vec = initialize.u.vec(k=4)
u.vec[5:10] = 2
## Run the simulation with an adjustment to the main effects in
#	u.vec such that the probability of nondetection is 0.5.
sim = llm.sim(n.grid = c(100,300,900,2700), n.reps = 10, u.vec,
	p0 = 0.5, ic = "BIC", cell.adj = FALSE)
# View the results
plot(sim)

## End(Not run)

Example output

 [1] "c1"   "c2"   "c3"   "c4"   "c12"  "c13"  "c14"  "c23"  "c24"  "c34" 
[11] "c123" "c124" "c134" "c234"

lllcrc documentation built on May 2, 2019, 3:34 p.m.