DCSLMI | R Documentation |
Performs multiple imputation for missing response variables in linear regression models. This method iteratively updates parameter estimates using ordinary least squares (OLS) and generates M complete datasets by imputing missing values with different parameter draws.
DCSLMI(data, R = 1000, M = 20)
data |
A data frame or matrix. The first column contains the response variable 'y' (which may include NA values), and the remaining columns are predictors 'X'. |
R |
Number of internal iterations for parameter estimation per imputation. |
M |
Number of multiple imputations to generate. |
A list containing:
A matrix of size n x M, where each column is a completed response vector.
A matrix of size (p+1) x M, where each column contains the estimated regression coefficients.
The number of missing values in the original response variable.
# Simulate data with missing responses
set.seed(123)
data <- data.frame(
y = c(rnorm(50), rep(NA, 10)),
x1 = rnorm(60),
x2 = rnorm(60)
)
# Perform multiple imputation
result <- DCSLMI(data, R = 500, M = 10)
# View imputed response values
head(result$Yhat)
# View coefficient estimates
apply(result$betahat, 1, mean) # average estimates
apply(result$betahat, 1, sd) # uncertainty across imputations
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.