BWselection is a function to do the backward selection in R based on AIC and F-test P-values. For the linear regression, the function use lm
to call linear regression. For Logistic regression, the function use glm
with family="Binomial"
to call logistic regression. Currently, the function support the linear regression and the logistic regression. Just call the function by BWselection()
with the arguments. For more resource of how to use the package, please refer to the help page and vignettes.
#Install the package, need to install the devtools packages:
install.packages("devtools")
devtools::install_github("xuetao666/BWselection")
#To install with Vignettes:
install.packages("devtools")
devtools::install_github("xuetao666/BWselection",build_vignettes =T)
Here, we are using the NHANES data as example:
library(BWselection)
#Load NHANES DATA
library(NHANES)
data("NHANES")
data=NHANES
#Created variable lists for the model selection
qvarlist<-c("BPSysAve","SleepHrsNight","TotChol")
lvarlist<-c("Age","BPDiaAve","Weight","Height")
spvarlist<-c("Pulse","DirectChol")
spclist<-c(70,1.2)
catvarlist<-c("Depressed","Marijuana","Gender")
BWselection(data=NHANES,qvarlist=qvarlist,lvarlist=lvarlist,spvarlist=spvarlist,
spclist=spclist,catvarlist=catvarlist,outcome="BMI",type="lm",sig=0.05,complete_case=TRUE)
If you encounter any problems or bugs, please contact me at xuetao@umich.edu
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.