Testing the CRE PackageSource:
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.
Getting the code
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:
- Directly from GitHub
- CRAN (not recommended)
- Forked Repository (recommended)
Installing the package directly from Github
In this project, we follow A
successful Git Branching Model. As a result, the
develop branch is the most updated branch for developers.
devtools::install_github to install the package. If you
do not specify the
ref, it will install the master (or
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)
?CRE. It should open the package description page
under the help tab (assuming you are using RStudio).
Installing the package from CRAN
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]
Installing the package from the source
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
Codetab and then click on the
Open one of the files using RStudio, then change the project directory to the project directory (
Session > Set Working Directory > To Project Directory).
devtoolslibrary and then load CRE.
Forking the package
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
@github.com:[your user name]/CRE.gitgit 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.
Testing the Package
Run the following command to test the package.
library(CRE) # Generate sample data set.seed(1358) dataset <- generate_cre_dataset(n = 1000, rho = 0, n_rules = 2, p = 10, effect_size = 2, binary_covariates = TRUE, binary_outcome = FALSE, confounding = "no") y <- dataset[["y"]] z <- dataset[["z"]] X <- dataset[["X"]] method_params <- list(ratio_dis = 0.25, ite_method_dis = "aipw", include_ps_dis = TRUE, ps_method_dis = "SL.xgboost", ps_method_inf = "SL.xgboost", oreg_method_dis = "SL.xgboost", oreg_method_inf = "SL.xgboost", ite_method_inf = "aipw", include_ps_inf = TRUE, offset = NULL) hyper_params <- list(intervention_vars = NULL, ntrees_rf = 200, ntrees_gbm = 200, node_size = 20, max_nodes = 5, max_depth = 15, replace = TRUE, max_decay = 0.025, type_decay = 2, t_ext = 0.01, t_corr = 1, t_pvalue = 0.05, stability_selection = TRUE, cutoff = 0.6, pfer = 1, penalty_rl = 1) # linreg CATE estimation with aipw ITE estimation cre_results <- cre(y, z, X, method_params, hyper_params) summary(cre_results) plot(cre_results)