Estimation and inference for regression models with endogenous regressors using a semiparametric projection approach. Instrumental variables are constructed internally from observed regressors by projecting out a space of basis functions used to represent the conditional mean of the structural error. A least absolute shrinkage and selection operator (LASSO) procedure selects basis functions for the projection. Tools are provided for simulation studies and empirical applications. The methods are based on Dong, Gao, Linton and Peng (2026)
SIVMethod provides a computational toolkit for Identification, Estimation and Inference Based on Structural Error Projection proposed by Dong, Gao, Linton, and Peng (2026). It is designed to address endogeneity in regression models by constructing instruments directly from observed regressors, entirely eliminating the reliance on externally supplied instruments.
Key features include:
Sim: A unified simulation engine to replicate Example B.2.1.
Sim_test: A unified simulation engine to replicate Example B.2.3.
SIV: The core implementation of the Semiparametric Instrumental Variable estimator.
You can install the released version from GitHub with:
# install.packages("pak")
pak::pak("Greatknee/SIVMethod")
Sim()
Sim_test()
Consider a linear model:
$$y=\mathbf{x}^\top \beta+\epsilon,$$
where $\text{E}[\epsilon]=0$ but $\ \text{E}[\mathbf{x}\epsilon]\neq 0$. We define the conditional expectation of the error and the subsequent error as:
$$ m(x)=E[\epsilon|x] \ \text{and} \ e=\epsilon−m(x)=y−x^\top\beta−m(x).$$
Assume $m(\mathbf{x})$ can be approximated using a vector of orthogonal series functions. Let $m(\mathbf{x}) = \mathbf{v}(\mathbf{x})^\top\boldsymbol{\gamma}$, where $\boldsymbol{\gamma} = (\gamma_1, \dots, \gamma_k)^\top$ is a vector of unknown coefficients, and $\mathbf{v}(\mathbf{x}) \equiv \mathbf{V}_k(\mathbf{x}) = (\psi_1(\mathbf{x}), \dots, \psi_k(\mathbf{x}))^\top$ is the basis vector with a fixed, finite truncation parameter $k$. The model can then be rewritten as:
$$y = \mathbf{x}^\top \beta + \mathbf{v}^\top\boldsymbol{\gamma} + e,$$
where $\mathbb{E}[e|\mathbf{x}] = 0$.
By projecting out the basis functions, the structural equation becomes:
$$w = \mathbf{z}^\top \beta_0 + e,$$
where the constructed instrument $\mathbf{z} = \mathbf{x} - \mathbb{E}[\mathbf{x}\mathbf{v}^\top] \mathbb{E}[\mathbf{v}\mathbf{v}^\top]^{-1} \mathbf{v}$ satisfies the exogeneity condition $\mathbb{E}[e|\mathbf{z}] = \mathbb{E}[\mathbb{E}[e|\mathbf{x}]|\mathbf{z}] = 0$. Provided that $\mathbb{E}[\mathbf{z}\mathbf{z}^\top] > 0$, $\mathbf{z}$ serves as a valid internal instrumental variable.