| dina | R Documentation |
dina() is the high-level user-facing wrapper around dina_fit().
It accepts a data frame plus column-name arguments, matching the
conventions used elsewhere in the forestsearch package, and
extracts the covariate matrix, response, and treatment indicator
before dispatching to dina_fit().
dina(
df,
outcome,
treatment,
covariates,
family = c("gaussian", "binomial", "poisson", "cox"),
status = NULL,
...
)
df |
data frame (or tibble / |
outcome |
character(1); the name of the response column in
|
treatment |
character(1); the name of the binary treatment
indicator column in |
covariates |
character vector of length |
family |
one of |
status |
character(1) or |
... |
further arguments forwarded to |
All other arguments are forwarded to dina_fit() via ...,
including propensity_method, baseline_method, cross_fitting,
n_folds, cens_type, cens_params, n_grid, eps, and seed.
See dina_fit() for their full documentation.
Covariate columns must be numeric (or integer). Convert factors to
dummy variables (e.g., with stats::model.matrix()) before calling
if needed. Rows with any NA value in the referenced columns are
rejected with an error; use stats::na.omit() or impute beforehand.
An object of class "dina", as returned by dina_fit().
The $call component is overwritten with the original dina()
call so that print() and summary() show the high-level
invocation rather than the internal matrix-based dispatch.
dina_fit() for the underlying matrix-based estimator;
dina_bagged() for the bagged version with infinitesimal-jackknife
variance.
set.seed(1)
n <- 400
df_demo <- data.frame(
y = NA,
w = stats::rbinom(n, 1, 0.5),
x1 = stats::runif(n, -1, 1),
x2 = stats::runif(n, -1, 1),
x3 = stats::runif(n, -1, 1)
)
tau_x <- 0.5 + 0.8 * df_demo$x1 - 0.3 * df_demo$x2
df_demo$y <- 1 + df_demo$x1 + df_demo$w * tau_x + stats::rnorm(n)
fit <- dina(
df = df_demo,
outcome = "y",
treatment = "w",
covariates = c("x1", "x2", "x3"),
family = "gaussian",
seed = 1L
)
coef(fit)
confint(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.