MCEM: MCEM Algorithm for Missing Response Variables

View source: R/MCEM.R

MCEMR Documentation

MCEM Algorithm for Missing Response Variables

Description

Implements the Monte Carlo EM algorithm for handling missing response data in linear regression models.

Usage

MCEM(data, d = 5, tol = 0.01, nb = 50)

Arguments

data

A data frame with the response variable in the first column and predictors in the remaining columns.

d

Initial convergence threshold. Defaults to 5.

tol

Termination tolerance. Defaults to 0.01.

nb

Maximum number of iterations. Defaults to 50.

Details

This function implements the Monte Carlo Expectation-Maximization (MCEM) algorithm to handle missing response variables in linear regression models. The algorithm iteratively imputes missing responses and updates regression coefficients until convergence.

Value

A list containing the following components:

Yhat

Imputed response vector with missing values filled in.

betahat

Final regression coefficients.

iterations

Number of iterations performed.

Examples

  # Create dataset with 20% missing responses
  set.seed(123)
  data <- data.frame(
    Y = c(rnorm(80), rep(NA, 20)),
    X1 = rnorm(100),
    X2 = runif(100)
  )
  result <- MCEM(data, d = 5, tol = 0.001, nb = 100)
  print(result$Yhat)  # Imputed response vector
  print(result$betahat)  # Final regression coefficients
  print(result$iterations)  # Number of iterations performed

DLMRMV documentation built on Aug. 8, 2025, 6:27 p.m.

Related to MCEM in DLMRMV...