Learn R Programming

lllcrc (version 1.2)

llm.sim: Simulate basic log-linear CRC experiments

Description

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

Usage

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
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.

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.

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.

Examples

Run this code
## 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)

Run the code above in your browser using DataLab