An R package that implemnts the method proposed by Danieli, Devi and Fryer (2019), to identify the factors with the greatest potential to increase a pre-specified outcome, using observational data.
Currently, the package can be installed through GitHub:
#install.packages("devtools")
::install_github("eladg9/optinterv") devtools
library(optinterv)
#generate data
<- 1000
n <- 10
p <- matrix(rnorm(n*p), ncol = p)
features <- matrix(rbinom(n, 1, 0.5), nrow = n)
men <- 2*(features[,1] > 1) + men*pmax(features[,2], 0) + rnorm(n)
outcome <- as.vector(outcome)
outcome #find the optimal intervention using the non-parametric method:
<- optint(Y = outcome, X = features, control = men,
imp_feat method = "non-parametric", lambda = 10, plot = TRUE)
#by default, only the significant features are displayed
#(see ?plot.optint for further details).
#for customized variable importance plot, use plot():
plot(imp_feat, plot.vars = 10)
#show summary of the results using summary():
summary(imp_feat)
#we can look on the new features distribution more deeply, using plot_change():
plot_change(imp_feat, plot.vars = "sig")
#we can explore how the optimal intervention varies between genders using optint_by_group():
<- as.vector(men)
men <- optint_by_group(Y = outcome, X = features,
imp_feat_by_gender group = men,
method = "non-parametric",
lambda = 10)
#by default, only the significant features are displayed
#(see ?plot.optint_by_group for further details).
#for customized variable importance plot, use plot():
plot(imp_feat_by_gender, plot.vars = 10)