simulate_Q_dat: Randomly generate a Q matrix within the identifying condition...

Description Usage Arguments Value Examples

View source: R/sample_mcmc.R

Description

This function initializes Q (if unknown) during MCMC sampling chain within identifiability constraints. It is a warm start - because it will not assign an "1" to dimension "l" with few ones in the data. NB: harder to get 1 to zero? easy to get zero to one?

Usage

1
simulate_Q_dat(M, dat, p = 0.1, frac = 1/4)

Arguments

M

latent state dimension

dat

binary data matrix (rows for observations, columns for dimensions)

p

Bernoulli probability of 1 in the Q matrix (except two diagonal matrices)

frac

A threshold - this function only initializes the dimensions with at least frac*100 percent observed frequencies.

Value

a binary matrix of dimension M by L

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# simulate data:
L0 <- 100
options_sim0  <- list(N = 200,  # sample size.
                     M = 3,   # true number of machines.
                     L = L0,   # number of antibody landmarks.
                     K = 8,    # number of true components.,
                     theta = rep(0.8,L0), # true positive rates
                     psi   = rep(0.01,L0), # false positive rates
                     alpha1 = 1 # half of the people have the first machine.
)

#image(simulate_data(options_sim0,SETSEED = TRUE)$datmat)
simu     <- simulate_data(options_sim0, SETSEED=TRUE)
simu_dat <- simu$datmat
simulate_Q_dat(5,simu_dat)

zhenkewu/rewind documentation built on Sept. 9, 2020, 3:40 p.m.