IMI | R Documentation |
This function performs Improved Multiple Imputation (IMI) estimation for grouped data with missing values.
It iteratively imputes missing values using the LS
function and estimates regression coefficients using the PPLS
function.
The final regression coefficients are averaged across multiple imputations.
IMI(d, M, midx, n)
d |
|
M |
Number of multiple imputations to perform. |
midx |
Column indices of the missing variables in |
n |
Vector of sample sizes for each group. |
The function assumes the data is grouped and contains missing values in specified columns (midx
).
It uses the LS
function to impute missing values and the PPLS
function to estimate regression coefficients.
The process is repeated M
times, and the final regression coefficients are averaged.
A list containing the following elements:
betahat |
Average regression coefficients across all imputations. |
comm |
Indicator variable (0 for single group, 1 for multiple groups). |
# Example data
set.seed(123)
n <- c(300, 300, 400) # Sample sizes for each group
p <- 5 # Number of independent variables
Y <- rnorm(sum(n)) # Dependent variable
X0 <- matrix(rnorm(sum(n) * p), ncol = p) # Independent variables matrix
d <- list(p = p, Y = Y, X0 = X0) # Data list
d$all <- cbind(Y, X0)
# Indices of missing variables (assuming some variables are missing)
midx <- c(2, 3) # For example, the second and third variables are missing
# Call IMI function
result <- IMI(d, M = 5, midx = midx, n = n)
# View results
print(result$betahat) # Average regression coefficients
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.