Skip to contents

crsivderiv uses the approach of Florens and Racine (2012) to compute the partial derivative of a nonparametric estimation of an instrumental regression function \(\varphi\) defined by conditional moment restrictions stemming from a structural econometric model: \(E [Y - \varphi (Z,X) | W ] = 0\), and involving endogenous variables \(Y\) and \(Z\) and exogenous variables \(X\) and instruments \(W\). The derivative function \(\varphi'\) is the solution of an ill-posed inverse problem, and is computed using Landweber-Fridman regularization.

Usage

crsivderiv(y, ...)

# S3 method for class 'formula'
crsivderiv(y, data = NULL, subset, na.action, ...)

# Default S3 method
crsivderiv(y,
           z,
           w,
           x = NULL,
           zeval = NULL,
           weval = NULL,
           xeval = NULL,
           constant = 0.5,
           display.nomad.progress = TRUE,
           display.warnings = TRUE,
           iterate.diff.tol = 1.0e-08,
           iterate.max = 1000,
           opts = list("MAX_BB_EVAL"=10000,
                       "EPSILON"=.Machine$double.eps,
                       "INITIAL_MESH_SIZE"="r1.0e-01",
                       "MIN_MESH_SIZE"=paste("r",sqrt(.Machine$double.eps),sep=""),
                       "MIN_FRAME_SIZE"=paste("r",1,sep=""),
                       "DISPLAY_DEGREE"=0),
           penalize.iteration = TRUE,
           smooth.residuals = TRUE,
           start.from = c("Eyz","EEywz"),
           starting.values = NULL,
           stop.on.increase = TRUE,
           ...)

Arguments

Data, Model Inputs And Formula Interface

These arguments identify the response, endogenous variable, instruments, and exogenous covariates. The formula interface uses y ~ z | w or y ~ z | w | x. Each partition may contain multiple additive terms and scalar transformations. Dot notation, interaction operators, offsets, and matrix-valued terms are not supported.

data

an optional data frame, list, or environment containing the variables in the IV formula. When data is supplied, every formula variable must be present in it; ambient variables do not fill missing columns

subset

an optional specification of observations to retain when using the formula interface

na.action

a function specifying the action for missing observations when using the formula interface. With na.exclude, fitted() and residuals() restore omitted rows as NA

w

a \(q\)-variate data frame of instruments. The data types may be continuous, discrete (unordered and ordered factors), or some combination thereof

x

an \(r\)-variate data frame of exogenous predictors. The data types may be continuous, discrete (unordered and ordered factors), or some combination thereof

y

either a one-dimensional numeric or integer response vector, with element \(i\) corresponding to row \(i\) of z, or an IV formula of the form y ~ z | w or y ~ z | w | x

z

a one-column data frame of continuous endogenous predictors. The current implementation of crsivderiv supports univariate continuous \(z\) only

Evaluation Inputs

These arguments identify evaluation data for the derivative fit.

weval

a \(q\)-variate data frame of instruments on which the regression will be estimated (evaluation data). By default, evaluation takes place on the data provided by w

xeval

an \(r\)-variate data frame of exogenous predictors on which the regression will be estimated (evaluation data). By default, evaluation takes place on the data provided by x

zeval

a one-column data frame of continuous endogenous predictors on which the regression will be estimated (evaluation data). By default, evaluation takes place on the data provided by z

Landweber-Fridman Iteration Controls

These arguments control iteration, residual smoothing, starting values, and stopping behavior.

constant

the constant to use when using Landweber-Fridman iteration

iterate.diff.tol

the search tolerance for the difference in the stopping rule from iteration to iteration when using Landweber-Fridman (disable by setting to zero)

iterate.max

an integer indicating the maximum number of complete positive-index Landweber-Fridman states that may be evaluated. The initialization state \(N=0\) is not counted

penalize.iteration

a logical value indicating whether to penalize the norm by the number of iterations or not (default TRUE)

smooth.residuals

a logical value (defaults to TRUE) indicating whether to optimize bandwidths for the regression of \(y-\varphi(z)\) on \(w\) or for the regression of \(\varphi(z)\) on \(w\) during iteration

start.from

a character string indicating whether to start from \(E(Y|z)\) (default, "Eyz") or from \(E(E(Y|z)|z)\) (this can be overridden by providing starting.values below)

starting.values

optional derivative values for the initialization state \(\varphi'_0\). They are used directly before the first reported update; no hidden \(-1\) to \(0\) update is performed. When NULL, the initialization is obtained from \(E(y|z)\) according to start.from (see details below)

stop.on.increase

a logical value (defaults to TRUE) indicating whether to halt iteration if the stopping criterion (see below) increases over the course of one iteration (i.e. it may be above the iteration tolerance but increased)

Warnings And Progress

These arguments control warnings and displayed optimizer progress.

display.nomad.progress

a logical value indicating whether to display the progress of the NOMAD solver (default display.nomad.progress=TRUE)

display.warnings

a logical value indicating whether to display warnings (default display.warnings=TRUE)

Additional Arguments

Further NOMAD and CRS controls are passed through to lower-level routines.

...

additional arguments supplied to crs. In formula calls, weights and observation-indexed starting.values are aligned through the same model frame as the response and IV roles. Formula-time evaluation arguments (newdata, zeval, weval, and xeval) are deliberately not supported; use the native vector interface for evaluation-grid fitting

opts

arguments passed to the NOMAD solver (see snomadr for further details)

Details

The formula method is a training-grid interface. It constructs one model frame for the response, endogenous variable, instruments, optional exogenous variables, weights, and observation-indexed starting values, then calls the established native estimator once. Thus subset, missing values, and row-indexed controls cannot acquire different row maps. Formula fits support fitted(), residuals(), predict() without newdata, predict(..., deriv=1) for the selected derivative, summary(), and plot(). Arbitrary formula newdata is deferred because evaluating a retained spline projection is not generally the same operation as resolving the IV problem on a new grid. Native objects retain their established post-fit CRS projection route.

The iteration index has a single meaning throughout the returned object. The initialization consists of \(\varphi'_0\) and its centered integral \(\varphi_0\). For \(N=1,2,\ldots\), one adjoint update produces \(\varphi'_N\), integration and centering produce \(\varphi_N\), and the residual at that same curve produces the stopping value for state \(N\). Thus column \(N\) of phi.prime.mat and phi.mat, and element \(N\) of norm.stop, always describe one coherent state. With penalize.iteration=TRUE, that element is \(N q_N\), where \(q_N\) is the normalized squared residual criterion at \(\varphi_N\).

For Landweber-Fridman iteration, an optimal stopping rule based upon \(||E(y|w)-E(\varphi_k(z,x)|w)||^2 \) is used to terminate iteration. However, if local rather than global optima are encountered the resulting estimates can be overly noisy. To best guard against this eventuality set nmulti to a larger number than the default nmulti=2 for crs when using cv="nomad" or instead use cv="exhaustive" if possible (this may not be feasible for non-trivial problems).

Note that for subsequent Landweber-Fridman iterations, a “warm start” strategy is employed. The optimal parameters (spline degree, number of segments, and bandwidths or inclusion indicators) from the previous iteration are used as starting values for the current iteration. The user-supplied nmulti is respected for all iterations. For iterations after the first successful one, these optimal parameters serve as the first of the multiple initial points (a warm start), while any remaining restarts are cold starts. If nmulti is not explicitly supplied by the user, it defaults to the crs default (2) for the first iteration and to 1 for all subsequent iterations. This strategy provides a balance between computational efficiency and robustness, allowing the NOMAD solver to refine the structural parameters as the residuals evolve incrementally while still guarding against local optima.

When using Landweber-Fridman iteration, iteration will terminate when either the change in the value of \(||(E(y|w)-E(\varphi_k(z,x)|w))/E(y|w)||^2 \) from iteration to iteration is less than iterate.diff.tol or we hit iterate.max or \(||(E(y|w)-E(\varphi_k(z,x)|w))/E(y|w)||^2 \) stops falling in value and starts rising.

When your problem is a simple one (e.g. univariate \(Z\), \(W\), and \(X\)) you might want to avoid cv="nomad" and instead use cv="exhaustive" since exhaustive search may be feasible (for degree.max and segments.max not overly large). This will guarantee an exact solution for each iteration (i.e. there will be no errors arising due to numerical search).

The current implementation supports a single continuous endogenous regressor only. Instrument and exogenous regressor data may still be mixed continuous and categorical.

Value

crsivderiv returns a crsivderiv object (which inherits from the crs class). The generic functions print, summary, fitted, residuals, predict, and plot support objects of this type.

For the plot function, the options are plot.data=FALSE or data_overlay=FALSE (logical values indicating whether to plot the data as a scatter plot), phi=FALSE (a logical value indicating whether to plot the reconstructed structural function rather than its derivative), and output=c("plot","data","plot-data") or behavior (whether to draw, return the plot data, or both). Bootstrap, asymptotic interval, surface-rendering, rug, legend, and regression gradient plot controls are not supported for this curve route and fail fast when supplied. See plot.crs for the shared CRS plot-output and data-overlay conventions. Note that the plot method for crsivderiv objects currently only supports a univariate continuous endogenous predictor \(z\).

See crs for details on the return object components.

In addition to the standard crs components, crsivderiv returns components phi.prime, phi, phi.prime.mat, phi.mat, num.iterations, norm.stop, norm.value and convergence. num.iterations is the selected positive-index state, and phi.prime and phi are taken from that same column of their respective matrices. The matrices and norm.stop contain all evaluated states, so their common length can exceed num.iterations when a later evaluated state triggers stopping or the stopping-rule selector chooses an earlier state.

fitted() and predict() without newdata return the selected structural state phi; predict(..., deriv=1) without newdata returns the matching selected phi.prime. On a training-grid fit, residuals() returns the original response minus that same selected structural state. summary() returns a structured summary.crsivderiv object. New objects also contain a namespaced iv component recording the public IV call, role labels, row map, original response, evaluation grid, and selected-state metadata; inherited CRS fields are retained unchanged.

References

Carrasco, M. and J.P. Florens and E. Renault (2007), “Linear Inverse Problems in Structural Econometrics Estimation Based on Spectral Decomposition and Regularization,” In: James J. Heckman and Edward E. Leamer, Editor(s), Handbook of Econometrics, Elsevier, 2007, Volume 6, Part 2, Chapter 77, Pages 5633-5751

Darolles, S. and Y. Fan and J.P. Florens and E. Renault (2011), “Nonparametric Instrumental Regression,” Econometrica, 79, 1541-1565.

Feve, F. and J.P. Florens (2010), “The Practice of Non-parametric Estimation by Solving Inverse Problems: The Example of Transformation Models,” Econometrics Journal, 13, S1-S27.

Florens, J.P. and J.S. Racine (2012), “Nonparametric Instrumental Derivatives,” Working Paper.

Fridman, V. M. (1956), “A Method of Successive Approximations for Fredholm Integral Equations of the First Kind,” Uspeskhi, Math. Nauk., 11, 233-334, in Russian.

Horowitz, J.L. (2011), “Applied Nonparametric Instrumental Variables Estimation,” Econometrica, 79, 347-394.

Landweber, L. (1951), “An Iterative Formula for Fredholm Integral Equations of the First Kind,” American Journal of Mathematics, 73, 615-24.

Li, Q. and J.S. Racine (2007), Nonparametric Econometrics: Theory and Practice, Princeton University Press.

Author

Jeffrey S. Racine racinej@mcmaster.ca

Note

This function currently supports univariate z only. This function should be considered to be in ‘beta test’ status until further notice.

See also

npreg, crsiv, crs, plot.crs

Examples

if (FALSE) { # \dontrun{
## This illustration was made possible by Samuele Centorrino
## <samuele.centorrino@univ-tlse1.fr>

set.seed(42)
n <- 500

## For trimming the plot (trim .5% from each tail)

trim <- 0.005

## The DGP is as follows:

## 1) y = phi(z) + u

## 2) E(u|z) != 0 (endogeneity present)

## 3) Suppose there exists an instrument w such that z = f(w) + v and
## E(u|w) = 0

## 4) We generate v, w, and generate u such that u and z are
## correlated. To achieve this we express u as a function of v (i.e. u =
## gamma v + eps)

v <- rnorm(n,mean=0,sd=0.27)
eps <- rnorm(n,mean=0,sd=0.05)
u <- -0.5*v + eps
w <- rnorm(n,mean=0,sd=1)

## In Darolles et al (2011) there exist two DGPs. The first is
## phi(z)=z^2 and the second is phi(z)=exp(-abs(z)) (which is
## discontinuous and has a kink at zero).

fun1 <- function(z) { z^2 }
fun2 <- function(z) { exp(-abs(z)) }

z <- 0.2*w + v

## Generate two y vectors for each function.

y1 <- fun1(z) + u
y2 <- fun2(z) + u

## You set y to be either y1 or y2 (ditto for phi) depending on which
## DGP you are considering:

y <- y1
phi <- fun1

## Sort on z (for plotting)

ivdata <- data.frame(y,z,w,u,v)
ivdata <- ivdata[order(ivdata$z),]
rm(y,z,w,u,v)

model.ivderiv <- crsivderiv(y ~ z | w, data=ivdata)

plot(ivdata$z,model.ivderiv$phi.prime,
     xlim=quantile(ivdata$z,c(trim,1-trim)),
     main="",
     xlab="Z",
     ylab="Derivative",
     type="l",
     lwd=2)

rug(ivdata$z)
} # }