We encourage all developers to test the package in different conditions. Testing the package is the easiest way to get familiar with the package and its functionalities.
To test the package, please install the package on your system (R (>= 3.5.0)). You can install the package by following one of these approaches:
In this project, we follow A
successful Git Branching Model. As a result, the
develop
branch is the most updated branch for developers.
Use devtools::install_github
to install the package. If you
do not specify the ref
, it will install the master (or
main) branch.
library(devtools)
try(detach("package:CRE", unload = TRUE), silent = TRUE) # if already you have the package, detach and unload it, to have a new install.
install_github("NSAPH-Software/CRE", ref="develop")
library(CRE)
Try ?CRE
. It should open the package description page
under the help tab (assuming you are using RStudio).
Installing the package from CRAN for developing purposes is not recommended. Because most probably, the version on CRAN is not the latest version.
[Complete this section after submitting the package to CRAN]
In order to install the package from the source, you need to download the source code into your computer and install it from the source. Here are the steps:
Go to package Github repository and
from the drop-down menu change the branch to develop
. Then
click on the Code
tab and then click on the
Download Zip
tab.
Open one of the files using RStudio, then change the project
directory to the project directory
(Session > Set Working Directory > To Project Directory
).
Load devtools
library and then load CRE.
library(devtools)
load_all()
?CRE
Forking the package under your Github account is the best option if
you are planning on installing, testing, modifying, and contributing to
the project. Go to package Github repository and
click on the Fork
button at the top right corner. After
forking the package, Open your terminal (or Gitbash for Windows,
Anaconda prompt, …) and run the following command (brackets are not
included):
@github.com:[your user name]/CRE.git git clone git
Now, you can modify the codebase and track your modification. Navigate to the package folder and Install the package following the Installing the package from source steps. It is a good idea to create a new branch to work on the codebase. Read A successful Git Branching Model for branching convention.
Run the following command to test the package.
library(CRE)
# Generate sample data
set.seed(1358)
<- generate_cre_dataset(n = 1000,
dataset rho = 0,
n_rules = 2,
p = 10,
effect_size = 2,
binary_covariates = TRUE,
binary_outcome = FALSE,
confounding = "no")
<- dataset[["y"]]
y <- dataset[["z"]]
z <- dataset[["X"]]
X
<- list(ratio_dis = 0.5,
method_params ite_method = "aipw",
learner_ps = "SL.xgboost",
learner_y = "SL.xgboost",
offset = NULL)
<- list(intervention_vars = NULL,
hyper_params ntrees = 20,
node_size = 20,
max_rules = 50,
max_depth = 3,
t_decay = 0.025,
t_ext = 0.01,
t_corr = 1,
t_pvalue = 0.05,
stability_selection = "vanilla",
cutoff = 0.6,
pfer = 1,
B = 10,
subsample = 0.5)
# linreg CATE estimation with aipw ITE estimation
<- cre(y, z, X, method_params, hyper_params)
cre_results summary(cre_results)
plot(cre_results)
<- predict(cre_results, X) ite_pred