Estimates a local parameter by solving a two-step GMM problem after localizing observations with DNN rank weights. The first step uses an identity moment weighting matrix; the second step uses the local moment covariance estimated at the first-step solution.
Usage
gmm_dnn(
data = NULL,
x_cols = NULL,
X = NULL,
X0 = NULL,
x0 = NULL,
model,
model_data = NULL,
distance = "l2",
method = c("exact", "asymp"),
k = 1L,
s = NULL,
tuning = NULL,
normalize = TRUE,
start = NULL,
optimizer = c("BFGS", "Nelder-Mead", "L-BFGS-B"),
jacobian = c("auto", "analytic", "fd"),
omega_ridge = 1e-08,
fd_step = 1e-05,
se = TRUE,
ctx = NULL,
return = c("W")
)Arguments
- data
Optional data frame containing covariates and model variables. Column names must be non-missing, non-empty, and unique.
- x_cols
Names or indices of covariate columns in
data.- X
Numeric
n x pcovariate matrix for the matrix interface.- X0
Numeric matrix of target points; mutually exclusive with
x0.- x0
Numeric vector for one target point.
- model
A
new_gmm_model()object.- model_data
Optional model data used with the matrix interface.
- distance
Distance name or specification.
- method
One of
"exact"or"asymp"for DNN weights.- k
Integer DNN neighbour count inside each size-
ssubsample. The paper theory usesk = 1(the default).- s
Integer kernel order (undersmoothing parameter), or
NULL. When bothsandtuningareNULL(the default),sis resolved from the paper undersmoothing ruletuning_dnn_paper(), \(s = \lfloor 0.4 n^{(k_x+1)/(k_x+2)} \rfloor\). Note that small fixed values such ass = 1(ork = s) yield uniform weights and hence no localization; a warning is emitted in that case.- tuning
Optional kernel-order tuning specification. When supplied,
smust be omitted.- normalize
Logical; normalize weight columns to sum to one.
- start
Optional numeric vector of length
p_theta, orp_theta x mmatrix, used as optimizer starts.- optimizer
Optimizer method passed to
stats::optim().- jacobian
One of
"auto","analytic", or"fd".- omega_ridge
Non-negative ridge multiplier for local moment covariance.
- fd_step
Positive finite finite-difference step multiplier.
- se
Logical; compute sandwich standard errors.
- ctx
Optional context passed to distance and ranking components.
- return
Optional extras:
c("W", "ranks", "ord", "dx", "g_obs", "omega", "jacobian", "ess", "neighbors", "tuning"). Theneighborsextra returns the firstknearest observations used inside each size-ssubsample, not the full DNN weight support.
Value
A gmm_result object with estimates, diagnostics, metadata, the
m x p evaluation-point matrix x0 (with covariate column names
propagated from the training data when available), and requested extras.
Details
Two interfaces are supported.
Data-frame interface: pass
data,x_cols, and agmm_model.Matrix interface: pass
X, one ofX0orx0, agmm_model, andmodel_datawhen the model needs observation-level variables.
Nuisance quantities are not fit internally. They must be supplied to the
model through data or model_data.
Exact DNN localization uses the full rank permutation at each target rather
than an s-nearest-neighbor truncation. For exact DNN fits, the
finite-population support edge is rank n - s + k, not rank s.
Examples
dgp <- sim_iv_data("dgp2_iv_homog_overid", n = 120, kx = 2, q = 2, seed = 1)
model <- gmm_model_dr_iv(
z_cols = c("Z1", "Z2"),
pi_cols = c("piZ1_oracle", "piZ2_oracle"),
muY_col = "muY_oracle",
muD_col = "muD_oracle"
)
fit <- gmm_dnn(
data = dgp$data,
x_cols = c("X1", "X2"),
x0 = dgp$x0,
model = model,
k = 1, s = 10,
return = "ess"
)
fit$theta
#> target_1
#> theta 1.196561