param_current: A numeric vector of regression parameters, in the order β,γ,θ. The γ vector is obtained from the matrix form. In matrix form, the gamma parameter matrix rows correspond to parameters for the M* = 1
observed mediator, with the dimensions of Z. In matrix form, the gamma parameter matrix columns correspond to the true mediator categories j=1,…,n_cat. The numeric vector gamma_v is obtained by concatenating the gamma matrix, i.e. gamma_v <- c(gamma_matrix).
obs_mediator: A numeric vector of indicator variables (1, 2) for the observed mediator M*. There should be no NA terms. The reference category is 2.
obs_outcome: A vector containing the outcome variables of interest. There should be no NA terms.
X: A numeric design matrix for the true mediator mechanism.
Z: A numeric design matrix for the observation mechanism.
c_matrix: A numeric matrix of covariates in the true mediator and outcome mechanisms. c_matrix should not contain an intercept and no values should be NA.
sample_size: An integer value specifying the number of observations in the sample. This value should be equal to the number of rows of the design matrix, X or Z.
n_cat: The number of categorical values that the true outcome, M, and the observed outcome, M* can take.
Returns
EM_function_bernoulliY returns a numeric vector of updated parameter estimates from one iteration of the EM-algorithm.