gc.logistic | R Documentation |
This function allows to estimate the marginal effect of an exposure or a treatment by G-computation for binary outcomes.
gc.logistic(glm.obj, data, group, effect, var.method, iterations, n.cluster, cluster.type)
glm.obj |
A glm object obtained by using the function glm with the argument |
data |
A data frame in which to look for the variable related to the outcome, the treatment/exposure and the covariables included in the previous logistic regression |
group |
The name or the variable related to the exposure/treatment variable. This variable shall have only two modalities encoded 0 for the untreated/unexposed patients and 1 for the treated/exposed patients. |
effect |
The type of the marginal effect to be estimated. Three types are possible (see details): "ATE" (by default), "ATT" and "ATU". |
var.method |
The method to estimate the variances and the confidence intervals. Two methods are possible: "simulations" (by default) which consists in parametric simulation based on the maximum likelihood estimates of the multivariate logistic regression |
iterations |
The number of iterations (simulations or resamples depending on the argument in |
n.cluster |
The number of cores to use, i.e., the upper limit for the number of child processes that run simultaneously (1 by default). |
cluster.type |
A character string with the type of parallelization. The default type is "PSOCK" (it calls makePSOCKcluster, faster on MacOS or Linux platforms). An alternative is "FORK" (it calls makeForkCluster, it does not work on Windows platforms). |
The ATE corresponds to Average Treatment effect on the Entire population, i.e. the marginal effect if all the sample is treated versus all the sample is untreated. The ATT corresponds to Average Treatment effect on the Treated, i.e. the marginal effect if the treated patients (group = 1
) would have been untreated. The ATU corresponds to Average Treatment effect on the Untreated , i.e. the marginal effect if the untreated patients (group = 0
) would have been treated. Simulation method for variance estimation has a shorter computing time than the boostrap method, but bootstrap is more accurate.
effect |
A character string with the type of the marginal effect. |
p0 |
A table related to the average proportion of events in the unexposed/untreated sample: |
p1 |
A table related to the average proportion of events in the exposed/treated sample: |
delta |
A table related to the difference between the average proportions of events in the exposed/treated sample minus in the unexposed/untreated sample: |
logOR |
A table related to the logarithm of the average Odds Ratio (OR): |
p.value |
The p-value of the bilateral test of the null hypothesis |
Yohann Foucher <Yohann.Foucher@univ-poitiers.fr>
Arthur Chatton <Arthur.Chatton@etu.univ-nantes.fr>
Le Borgne et al. G-computation and machine learning for estimating the causal effects of binary exposure statuses on binary outcomes. Scientific Reports. 11(1):1435. 2021. <doi: 10.1038/s41598-021-81110-0>
#data simulation
#treatment = 1 if the patients have been the exposure or treatment of interest and 0 otherwise
treatment <- rbinom(600, 1, prob=0.5)
covariate <- rnorm(600, 0, 1)
covariate[treatment==1] <- rnorm(sum(treatment==1), 0.3, 1)
outcome <- rbinom(600, 1, prob=
exp(-2+0.26*treatment+0.7*covariate)/(1+exp(-2+0.26*treatment+0.7*covariate)))
tab <- data.frame(outcome, treatment, covariate)
#Raw effect of the treatment
glm.raw <- glm(outcome ~ treatment, data=tab, family = binomial(link=logit))
summary(glm.raw)
#Conditional effect of the treatment
glm.multi <- glm(outcome ~ treatment + covariate, data=tab, family = binomial(link=logit))
summary(glm.multi)
#Marginal effects of the treatment (ATE)
gc.ate <- gc.logistic(glm.obj=glm.multi, data=tab, group="treatment", effect="ATE",
var.method="simulations", iterations=1000, n.cluster=1)
#Sum-up of the 3 ORs
data.frame( raw=exp(glm.raw$coefficients[2]),
conditional=exp(glm.multi$coefficients[2]),
marginal.ate=exp(gc.ate$logOR[,1]) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.