Learn R Programming

gfoRmula: Parametric G-Formula

Installation

You can install the released version of gfoRmula from CRAN with:

install.packages("gfoRmula")

After installing the devtools package (i.e., calling install.packages(devtools)), the development version of gfoRmula can be installed from GitHub with:

devtools::install_github("CausalInference/gfoRmula")

Usage

Please refer to McGrath et al. (2020) for a detailed guide to the gfoRmula package. Also, see the following vignettes regarding updates since McGrath et al. (2020):

  • “A Simplified Approach for Specifying Interventions in gfoRmula”
  • “Using Custom Outcome Models in gfoRmula”

Copy Link

Version

Install

install.packages('gfoRmula')

Monthly Downloads

624

Version

1.1.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Sean McGrath

Last Published

March 24th, 2025

Functions in gfoRmula (1.1.1)

get_plot_info

Get Plotting Information
gformula

Estimation of Survival Outcome, Continuous End-of-Follow-Up Outcome, or Binary End-of-Follow-Up Outcome Under the Parametric G-Formula
fit_zeroinfl_normal

Fit Zero-Inflated Normal Model on Covariate
gformula_binary_eof

Estimation of Binary End-of-Follow-Up Outcome Under the Parametric G-Formula
get_cvgrphs

Get Covariate Plots
get_outgrphs

Get Risk and Survival Plots
fit_trunc_normal

Fit Truncated Normal Model on Covariate
fit_multinomial

Fit Multinomial Model on Covariate
fit_bounded_continuous

Fit Bounded Normal Model on Covariate
fit_glm

Fit GLM on Covariate
plot.gformula_continuous_eof

Plot method for objects of class "gformula_continuous_eof"
obs_calculate

Calculate Observed Covariate Means and Risk
gformula_continuous_eof

Estimation of Continuous End-of-Follow-Up Outcome Under the Parametric G-Formula
plot.gformula_binary_eof

Plot method for objects of class "gformula_binary_eof"
gformula_survival

Estimation of Survival Outcome Under the Parametric G-Formula
lagged

History functions
hr_helper

Format Simulated Dataset for Hazard Ratio Calculation
intfunc

Execute Intervention
natural

Natural Course Intervention
make_histories

Generates Functions of History of Existing Covariates
rmse_calculate

Calculate RMSE for Covariate, Outcome, and Competing Risk Models
pred_fun_Y

Fit Outcome Model
predict_binomial

Simulate Binary Values
predict_trunc_normal

Simulate Truncated Normal Values
print.gformula_survival

Print and summary methods for "gformula" objects
plot.gformula_survival

Plot method for objects of class "gformula_survival"
pred_fun_D

Fit Competing Event Model
visit_sum

Create Visit Sum Covariate
predict_normal

Simulate Normal Values
vcov.gformula

Variance-covariance method for objects of class "gformula"
threshold

Threshold Intervention
simple_restriction

Simple Restriction
pred_fun_cov

Fit Covariate Models
static

Static Intervention
simulate

Simulate Counterfactual Outcomes Under Intervention
basicdata

Example Dataset for a Survival Outcome with Censoring
carry_forward

Carry Forward
coef.gformula

Coefficient method for objects of class "gformula"
censor_data

Example Dataset for a Survival Outcome with an Indicator of Censoring Variable
bootstrap_helper

Bootstrap Observed Data and Simulate Under All Interventions
binary_eofdata

Example Dataset for a Binary Outcome at End of Follow-Up
basicdata_nocomp

Example Dataset for a Survival Outcome without Censoring
continuous_eofdata

Example Dataset for a Continuous Outcome at End of Follow-Up
continuous_eofdata_pb

Example Dataset for a Continuous Outcome at End of Follow-Up with Pre-Baseline Times
error_catch

General Error Catching