Learn R Programming

ddtlcm (version 0.2.1)

simulate_lcm_response: Simulate multivariate binary responses from a latent class model

Description

Generate multivariate binary responses from the following process: For individual i = 1, ..., N, draw \(Z_i\) from Categorical distribution with prior class probability (length K). For item j = 1, ..., J, given \(Z_i = k\), draw \(Y_{ij}\) from Binomial with class-item probability

Usage

simulate_lcm_response(N, response_prob, class_probability)

Value

a named list of the following elements:

response_matrix

a K by J matrix with entries between 0 and 1 for the item response probabilities.

class_probability

a K-vector with entries between 0 and 1 for the class probabilities. Entries should be nonzero and sum up to 1, or otherwise will be normalized

Arguments

N

number of individuals

response_prob

a K by J matrix, where the k,j-th element is the response probability of item j for individuals in class k

class_probability

a length K vector, where the k-th element is the probability of assigning an individual to class k. It does not have to sum up to 1

See Also

Other simulate DDT-LCM data: simulate_DDT_tree(), simulate_lcm_given_tree(), simulate_parameter_on_tree()

Examples

Run this code
# number of latent classes
K <- 6
# number of items
J <- 78
response_prob <- matrix(runif(K*J), nrow = K)
class_probability <- rep(1/K, K)
# number of individuals
N <- 100
response_matrix <- simulate_lcm_response(N, response_prob, class_probability)

Run the code above in your browser using DataLab