Compute Conditional Probability of Each Observed Outcome Given Each True Outcome, for Every Subject
misclassification_prob.Rd
Compute the conditional probability of observing outcome \(Y^* \in \{1, 2 \}\) given
the latent true outcome \(Y \in \{1, 2 \}\) as
\(\frac{\text{exp}\{\gamma_{kj0} + \gamma_{kjZ} Z_i\}}{1 + \text{exp}\{\gamma_{kj0} + \gamma_{kjZ} Z_i\}}\)
for each of the \(i = 1, \dots,\) n
subjects.
Arguments
- gamma_matrix
A numeric matrix of estimated regression parameters for the observation mechanism,
Y* | Y
(observed outcome, given the true outcome) ~Z
(misclassification predictor matrix). Rows of the matrix correspond to parameters for theY* = 1
observed outcome, with the dimensions ofz_matrix
. Columns of the matrix correspond to the true outcome categories \(j = 1, \dots,\)n_cat
. The matrix should be obtained byCOMBO_EM
orCOMBO_MCMC
.- z_matrix
A numeric matrix of covariates in the observation mechanism.
z_matrix
should not contain an intercept.
Value
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, Y
, represents a true, latent outcome category \(Y \in \{1, 2 \}\).
The third column, Ystar
, represents an observed outcome category \(Y^* \in \{1, 2 \}\).
The last column, Probability
, is the value of the equation
\(\frac{\text{exp}\{\gamma_{kj0} + \gamma_{kjZ} Z_i\}}{1 + \text{exp}\{\gamma_{kj0} + \gamma_{kjZ} Z_i\}}\)
computed for each subject, observed outcome category, and true, latent outcome category.
Examples
set.seed(123)
sample_size <- 1000
cov1 <- rnorm(sample_size)
cov2 <- rnorm(sample_size, 1, 2)
z_matrix <- matrix(c(cov1, cov2), nrow = sample_size, byrow = FALSE)
estimated_gammas <- matrix(c(1, -1, .5, .2, -.6, 1.5), ncol = 2)
P_Ystar_Y <- misclassification_prob(estimated_gammas, z_matrix)
head(P_Ystar_Y)
#> Subject Y Ystar Probability
#> 1 1 1 1 0.7435833
#> 2 2 1 1 0.6660164
#> 3 3 1 1 0.4808373
#> 4 4 1 1 0.7853830
#> 5 5 1 1 0.2352985
#> 6 6 1 1 0.6954044