View source: R/simulate-nplcm.R
simulate_nplcm | R Documentation |
Simulate data from nested partially-latent class model (npLCM) family
simulate_nplcm(set_parameter)
set_parameter |
True model parameters in an npLCM specification:
|
A list of diagnostic test measurements, true latent statues:
data_nplcm
a list of structured data (see nplcm()
for
description).
template
a matrix: rows for causes (may comprise a single or multiple causative agents), columns for measurements; generated as a lookup table to match disease-class specific parameters (true and false positive rates)
latent_cat
integer values to indicate the latent category. The integer
code corresponds to the order specified in set_parameter$etiology
.
Controls are coded as length(set_parameter$etiology)+1
.)
simulate_latent for simulating discrete latent status, given which simulate_brs simulates bronze-standard data.
K.true <- 2 # no. of latent subclasses in actual simulation.
# If eta = c(1,0), effectively, it is K.true=1.
J <- 21 # no. of pathogens.
N <- 600 # no. of cases/controls.
eta <- c(1,0)
# if it is c(1,0),then it is conditional independence model, and
# only the first column of parameters in PsiBS, ThetaBS matter!
seed_start <- 20150202
print(eta)
# set fixed simulation sequence:
set.seed(seed_start)
ThetaBS_withNA <- c(.75,rep(c(.75,.75,.75,NA),5))
PsiBS_withNA <- c(.15,rep(c(.05,.05,.05,NA),5))
ThetaSS_withNA <- c(NA,rep(c(0.15,NA,0.15,0.15),5))
PsiSS_withNA <- c(NA,rep(c(0,NA,0,0),5))
set_parameter <- list(
cause_list = c(LETTERS[1:J]),
etiology = c(c(0.36,0.1,0.1,0.1,0.1,0.05,0.05,0.05,
0.05,0.01,0.01,0.01,0.01),rep(0.00,8)),
#same length as cause_list.
pathogen_BrS = LETTERS[1:J][!is.na(ThetaBS_withNA)],
pathogen_SS = LETTERS[1:J][!is.na(ThetaSS_withNA)],
meas_nm = list(MBS = c("MBS1"),MSS="MSS1"),
Lambda = eta, #ctrl mix
Eta = t(replicate(J,eta)), #case mix, row number equal to Jcause.
PsiBS = cbind(PsiBS_withNA[!is.na(PsiBS_withNA)],
rep(0,sum(!is.na(PsiBS_withNA)))),
ThetaBS = cbind(ThetaBS_withNA[!is.na(ThetaBS_withNA)],
rep(0,sum(!is.na(ThetaBS_withNA)))),
PsiSS = PsiSS_withNA[!is.na(PsiSS_withNA)],
ThetaSS = ThetaSS_withNA[!is.na(ThetaSS_withNA)],
Nu = N, # control size.
Nd = N # case size.
)
simu_out <- simulate_nplcm(set_parameter)
data_nplcm <- simu_out$data_nplcm
pathogen_display <- rev(set_parameter$pathogen_BrS)
plot_logORmat(data_nplcm,pathogen_display)
# more examples are provided in the vignette, including settings with
# covariates.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.