knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
First, we load the 'ILSE' package and the real data which can be loaded by following command.
library("ILSE") data("nhanes")
We fit the linear regression model using 'ILSE' function, and then compare with CC method and FIML method.
ncomp <- sum(complete.cases(nhanes)) message("Number of complete cases is ", ncomp, '\n') ilse2 <- ilse(age~., data=nhanes, verbose=T) print(ilse2)
Next, Bootstrap is applied to evaluate the standard error and p-values of each coefficients estimated by ILSE. We observe four significant coefficients.
set.seed(1) s2 <- summary(ilse2, Nbt=20) s2
First, we conduct CC analysis.
lm1 <- lm(age~., data=nhanes) s_cc <- summary.lm(lm1) s_cc
We fit linear regression model using FIML method.
fimllm <- fimlreg(age~., data=nhanes) print(fimllm)
We also use bootstrap to evaluate the standard error and p-values of each coefficients estimated by ILSE. We observe only one significant coefficients.
s_fiml <- summary(fimllm, Nbt=20) s_fiml
We visualize the p-vaules of each methods, where red line denotes 0.05 in y-axis and blue line 0.1 in y-axis.
library(ggplot2) library(ggthemes) pMat <- cbind(CC=s_cc$coefficients[,4], ILSE=s2[,4], FIML=s_fiml[,4]) df1 <- data.frame(Pval= as.vector(pMat[-1,]), Method =factor(rep(c('CC', "ILSE", "FIML"),each=3)), covariate= factor(rep(row.names(pMat[-1,]), times=3))) ggplot(data=df1, aes(x=covariate, y=Pval, fill=Method)) + geom_bar(position = "dodge", stat="identity",width = 0.5) + geom_hline(yintercept = 0.05, color='red') + geom_hline(yintercept = 0.1, color='blue') + scale_fill_economist()
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.