EMRE | R Documentation |
EM Algorithm for Linear Regression with Missing Data
EMRE(data, d = 1, tol = 1e-06, nb = 100, niter = 1)
data |
Dataframe with first column as response (Y) and others as predictors (X) |
d |
Initial convergence threshold (default=1) |
tol |
Termination tolerance (default=1e-6) |
nb |
Maximum iterations (default=100) |
niter |
Starting iteration counter (default=1) |
List containing:
Yhat |
Imputed response vector |
betahat |
Estimated coefficients |
# Generate data with 20% missing Y values
set.seed(123)
data <- data.frame(Y=c(rnorm(80),rep(NA,20)), X1=rnorm(100), X2=rnorm(100))
# Run EM algorithm
result <- EMRE(data, d=1, tol=1e-5, nb=50)
print(result$betahat) # View coefficients
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.