Constructs a standardized parameter object that serves as the interface
between model estimation and variance decomposition. This decouples the
two stages: users can construct ineqx_params from any estimation
method (GAMLSS, Bayesian models, simulation, or manual specification).
Usage
ineqx_params(
data,
model = NULL,
treat = NULL,
group = NULL,
time = NULL,
post = NULL,
ystat = "Var",
vcov = NULL,
verbose = TRUE
)Arguments
- data
For descriptive mode: a data.frame with columns
group,pi,mu,sigma. For causal manual mode: a data.frame with columnsgroup,pi,mu0,sigma0,beta,lambda(and optionallytime). For model mode: the data.frame used to fit the model.- model
A fitted
gamlssobject. If provided, parameters are extracted from the model via counterfactual predictions. Default: NULL (manual specification).- treat
Character, name of the treatment variable in
data. Required whenmodelis provided. Must be coded as 0 (untreated) and 1 (treated), or with multiple non-zero treatment levels.- group
Character, name of the grouping variable in
data. Required whenmodelis provided.- time
Character, name of the time variable. NULL for cross-sectional. Used in both manual mode (if
datacontains atimecolumn) and model mode.- post
Character, name of the pre/post indicator for DiD designs. Only used in model mode. NULL for simple difference estimator.
- ystat
Character, either
"Var"(variance) or"CV2"(squared coefficient of variation). Default:"Var".- vcov
For manual mode: an optional variance-covariance matrix (or named list of matrices for longitudinal data). For model mode: logical, whether to extract the vcov via numerical Jacobian (default: TRUE). Set to FALSE for faster computation without SEs.
Details
There are three usage modes:
- Descriptive (manual)
Pass a data.frame with columns
group,pi,mu,sigma. Returns anineqx_desc_paramsobject representing a counterfactual reference for descriptive decomposition.- Causal (manual)
Pass a data.frame with columns
group,pi,mu0,sigma0,beta,lambda(and optionallytime). Returns anineqx_paramsobject.- Causal (from fitted gamlss)
Pass a fitted
gamlssobject viamodel, along with the raw data and variable names. The function extracts treatment effects via counterfactual predictions.
The mode is auto-detected from the columns in data: if mu
and sigma are present (without mu0, sigma0), the
descriptive path is used; otherwise the causal path is used.
When model is provided, the function generates predictions under
counterfactual treatment assignments. For each observation, it predicts
the outcome under treat=0 (baseline) and treat=1 (treated), for both the
mean (mu) and standard deviation (sigma) equations. The average marginal
effects are computed within each group-time cell.
For the simple difference estimator, the ATT is: $$\beta_{D,j} = E[\hat{\mu}(D=1) - \hat{\mu}(D=0) | G=j]$$
Examples
# Descriptive counterfactual reference (equal groups, no inequality)
desc_ref <- ineqx_params(
data = data.frame(
group = c("workers", "managers"),
pi = c(0.5, 0.5),
mu = c(0, 0),
sigma = c(0, 0)
)
)
# Causal manual specification for a two-group example
params <- ineqx_params(
data = data.frame(
group = c("workers", "managers"),
pi = c(0.5, 0.5),
mu0 = c(500, 1000),
sigma0 = c(200, 400),
beta = c(60, 100),
lambda = c(-0.1, -0.2)
)
)
if (FALSE) { # \dontrun{
# From a fitted gamlss model
params <- ineqx_params(
model = my_gamlss, data = mydata,
treat = "x", group = "SES",
ystat = "Var", vcov = TRUE
)
} # }