moderndid.npiv_est#
- moderndid.npiv_est(y, x, w, x_eval=None, basis='tensor', j_x_degree=3, j_x_segments=None, k_w_degree=4, k_w_segments=None, knots='uniform', deriv_index=1, deriv_order=1, check_is_fullrank=False, w_min=None, w_max=None, x_min=None, x_max=None, data_driven=False)[source]#
Core sieve TSLS estimation for the nonparametric IV model.
Computational backend for
npivthat constructs B-spline bases for \(X\) and \(W\), estimates the sieve coefficient vector \(\hat{c}_J\) by two-stage least squares, and evaluates the function estimate \(\hat{h}_J\) and its derivatives at the requested points.- Parameters:
- y
numpy.ndarrayofshape(n,) Outcome variable.
- x
numpy.ndarrayofshape(n,) or (n,p_x) Endogenous regressors.
- w
numpy.ndarrayofshape(n,) or (n,p_w) Instrumental variables.
- x_eval
numpy.ndarrayofshape(m,p_x), optional Evaluation points for \(\hat{h}\). If None, uses
x.- basis{“tensor”, “additive”, “glp”}, default=”tensor”
Multivariate basis construction for \(X\).
- j_x_degree
int, default=3 Degree of B-spline basis for \(X\).
- j_x_segments
int, optional Number of segments for \(X\) basis. If None, chosen automatically.
- k_w_degree
int, default=4 Degree of B-spline basis for \(W\).
- k_w_segments
int, optional Number of segments for \(W\) basis. If None, chosen automatically.
- knots{“uniform”, “quantiles”}, default=”uniform”
Knot placement method.
- deriv_index
int, default=1 Which component of \(X\) to differentiate (1-based).
- deriv_order
int, default=1 Order of derivative to compute.
- check_is_fullrankbool, default=False
Verify full column rank of basis matrices before estimation.
- w_min, w_max
float, optional Override support bounds for \(W\).
- x_min, x_max
float, optional Override support bounds for \(X\).
- y
- Returns:
NPIVResultNamed tuple containing estimation results.
See also
npivPublic API with data-driven selection and confidence bands.