Compute Conditional Probability of Observed Mediator Given True Mediator, for Every Subject
Compute Conditional Probability of Observed Mediator Given True Mediator, for Every Subject
Compute the conditional probability of observing mediator M∗∈{1,2} given the latent true mediator M∈{1,2} as 1+exp{γkj0+γkjZZi}exp{γkj0+γkjZZi}
for each of the i=1,…,n subjects.
misclassification_prob(gamma_matrix, z_matrix)
Arguments
gamma_matrix: A numeric matrix of estimated regression parameters for the observation mechanism, M* | M (observed mediator, given the true mediator) ~ Z (misclassification predictor matrix). Rows of the matrix correspond to parameters for the M* = 1 observed mediator, with the dimensions of z_matrix. Columns of the matrix correspond to the true mediator categories j=1,…,n_cat. The matrix should be obtained by COMMA_EM, COMMA_PVW, or COMMA_OLS.
z_matrix: A numeric matrix of covariates in the observation mechanism. z_matrix should not contain an intercept.
Returns
misclassification_prob returns a dataframe containing four columns. The first column, Subject, represents the subject ID, from 1 to n, where n is the sample size, or equivalently, the number of rows in z_matrix. The second column, M, represents a true, latent mediator category M∈{1,2}. The third column, Mstar, represents an observed outcome category M∗∈{1,2}. The last column, Probability, is the value of the equation 1+exp{γkj0+γkjZZi}exp{γkj0+γkjZZi}
computed for each subject, observed mediator category, and true, latent mediator category.