gc.logistic: Marginal Effect for Binary Outcome by G-computation.

View source: R/gc.logistic.R

gc.logisticR Documentation

Marginal Effect for Binary Outcome by G-computation.

Description

This function allows to estimate the marginal effect of an exposure or a treatment by G-computation for binary outcomes.

Usage

gc.logistic(glm.obj, data, group, effect, var.method, iterations, n.cluster, cluster.type)

Arguments

glm.obj

A glm object obtained by using the function glm with the argument family = binomial(link=logit) to obtain a multivariate logistic regression. It shall be included the exposition/treatment of interest variable and at least one covariate.

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 glm.obj. The covariates' names have to be identical than the ones included in the logistic model.

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 glm.obj and "bootstrap" which consists in bootstrap resampling of the database data.

iterations

The number of iterations (simulations or resamples depending on the argument in var.method) to estimate of the variances and confidence intervals.

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).

Details

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.

Value

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: estimate is the estimated value, ci.lower and ci.upper represent the 95% confidence interval.

p1

A table related to the average proportion of events in the exposed/treated sample: estimate is the estimated value, ci.lower and ci.upper represent the 95% confidence interval.

delta

A table related to the difference between the average proportions of events in the exposed/treated sample minus in the unexposed/untreated sample: estimate is the estimated value, std.error is the corresponding standard error, ci.lower and ci.upper represent the 95% confidence interval.

logOR

A table related to the logarithm of the average Odds Ratio (OR): estimate is the estimated value, std.error is the corresponding standard error, ci.lower and ci.upper represent the 95% confidence interval.

p.value

The p-value of the bilateral test of the null hypothesis p0 = p1, i.e. OR = 1.

Author(s)

Yohann Foucher <Yohann.Foucher@univ-poitiers.fr>

Arthur Chatton <Arthur.Chatton@etu.univ-nantes.fr>

References

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>

Examples

#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]) )

RISCA documentation built on June 22, 2024, 12:22 p.m.