Skip to content

syntCF is an R package that provides a set of tools to estimate the effect of a program or a policy using a robust time series synthetic counterfactual approach coupled with the double difference estimator within a Machine Learning framework.

Notifications You must be signed in to change notification settings

athammad/syntCF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

syntCF

Version 0.0.0.9000

img License

Overview

syntCF is an R package that provides a set of tools to estimate the effect of a program or a policy using a robust time series synthetic counterfactual approach coupled with the double difference estimator within a Machine Learning framework. The package is inspired by the methods proposed in following contributions:

The library uses a modified version of the robust random forest algorithm designed to take time dependency of the data into account trough block bootstrapping as developed in the library rangerts. To account to uncertainty in the predicted counterfactual time series, the library uses quantile regression forests (Meinshausen, 2006).

Classic ML metrics such as RMSE,MAPE and R2, are accompanied with additional metrics specifically designed to evaluate the goodness of the prediction intervals based on the work of Gneiting, T., & Raftery, A. E. (2007).

The final effect estimation is based on a difference-in-difference (DID) to account for any systematic error in the trained model.

The library is built around caret and ranger to provide the user with a wide variety of options and speeding up training time.

Features

Train, Test & Evaluate in one go

Use syntCFtrain() and syntCFmetrics() to quickly train quantile Random forests with block bootstrapping and compute several evaluation metrics (RMSPE, MAPE,R2) including scoring rules metrics (interval score,sharpness, underprediction, overprediction).

Estimation

Estimate the effect of the treatment with syntCFest() using difference-in-difference (DID) to account for any systematic error in the trained model.

Plotting

syntCFplot() creates beautiful and easily customizable ggplot2 plot to visualize to visually compare the factual and the counterfactual time series.

Installation

To install the development version of the syntCF package, you need to install the remotes package then the syntCF package.

install.packages("remotes")
remotes::install_github("athammad/syntCF")

Vignettes

After installing the package you can view vignettes by typing browseVignettes("syntCF") in your R session.

Getting Help or Reporting an Issue

To report bugs/issues/feature requests, please file an issue.

Next Steps and TO DO list

  • Include ensembles of caret models with caretStack from caretEnsemble.

References

About

syntCF is an R package that provides a set of tools to estimate the effect of a program or a policy using a robust time series synthetic counterfactual approach coupled with the double difference estimator within a Machine Learning framework.

Topics

Resources

Stars

Watchers

Forks

Languages