estimate: Causal effect estimation via plug-in g-computation.

View source: R/estimate.R

estimateR Documentation

Causal effect estimation via plug-in g-computation.

Description

Causal effect estimation via plug-in g-computation.

Usage

estimate(
  data,
  formula,
  model = NULL,
  treatment = NULL,
  estimand = c("ATE", "ATT", "CATE", "IATE"),
  newdata = NULL,
  treatment_level = NULL,
  control_level = NULL,
  spec = NULL,
  type = NULL,
  interval = c("normal", "bootstrap"),
  conf_level = 0.95,
  n_boot = 200,
  seed = NULL,
  fit = NULL,
  ...
)

Arguments

data

Data frame.

formula

Outcome model formula. The first term on the right-hand side is treated as the treatment variable unless treatment is supplied.

model

Learner id (ignored if fit supplied).

treatment

Optional treatment variable name.

estimand

One of "ATE", "ATT", "CATE", or "IATE".

newdata

Optional target population for estimand = "CATE" or "IATE".

treatment_level

Optional treated level for binary treatment.

control_level

Optional control level for binary treatment.

spec

Hyperparameter list passed to fit().

type

Prediction type override for the outcome model.

interval

Interval method: "normal" or "bootstrap".

conf_level

Confidence level for uncertainty intervals.

n_boot

Number of bootstrap resamples used when interval = "bootstrap".

seed

Optional seed.

fit

Optional preconfigured funcml_fit object.

...

Passed to fit().

Value

A funcml_estimand object.

Examples

causal_data <- mtcars
causal_data$am <- factor(causal_data$am, labels = c("auto", "manual"))
ate <- estimate(
  data = causal_data,
  formula = mpg ~ am + wt + hp,
  model = "glm",
  treatment = "am",
  estimand = "ATE"
)
ate$estimate

funcml documentation built on Aug. 22, 2026, 5:08 p.m.