doubleLassoSelect | R Documentation |
This function implements Double Lasso Selection on a specified data frame, with specified treatment variables to be included in the final model and covariates to be tested via the selection process.
doubleLassoSelect(df, outcome, treatment, test, k = 15)
df |
Accepts |
outcome |
Accepts single |
treatment |
Accepts single |
test |
Accepts single empty |
k |
Accepts a |
This function returns a data frame (data.table
) with selected variables.
#Fetch data for demonstration data(mtcars) #Input example 1: #Character vectors as `treatment` and `test` input with an interaction term outcome <- "mpg" treatment <- c("cyl", "hp") test <- c("drat", "disp", "vs", "cyl:hp") #Input example 2: #Empty character as `treatment` and `test` input outcome <- "mpg" treatment <- "" test <- "" #Acquire the selected data frame DT_select <- doubleLassoSelect(df=mtcars, outcome=outcome, treatment=treatment, test=test) #Implement a linear model after the selection model_lm <- lm(as.formula(sprintf("`%s` ~ .", outcome)), data=DT_select) summary(model_lm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.