Testing for error invariance in separable instrumental variable models

The hypothesis of error invariance is central to the instrumental variable literature. It means that the error term of the model is the same across all potential outcomes. In other words, this assumption signifies that treatment effects are constant across all subjects. It allows to interpret instrumental variable estimates as average treatment effects over the whole population of the study. When this assumption does not hold, the bias of instrumental variable estimators can be larger than that of naive estimators ignoring endogeneity. This paper develops two tests for the assumption of error invariance when the treatment is endogenous, an instrumental variable is available and the model is separable. The first test assumes that the potential outcomes are linear in the regressors and is computationally simple. The second test is nonparametric and relies on Tikhonov regularization. The treatment can be either discrete or continuous. We show that the tests have asymptotically correct level and asymptotic power equal to one against a range of alternatives. Simulations demonstrate that the proposed tests attain excellent finite sample performances. The methodology is also applied to the evaluation of returns to schooling and the effect of price on demand in a fish market.


Introduction
We are interested in the effect of a (possibly continuous) random treatment Z (with support Z ⊂ R p ) on a scalar outcome outcome Y . Let Y (z) be the scalar potential outcome of the outcome Y under treatment status z ∈ Z. The potential outcomes are not observed, but Y = Y (Z) is part of the data. We write where U (z) is an error term such that E[U (z)] = 0. Letting U = U (Z), we have Y = ϕ(Z) + U . This is a separable model (as opposed to nonseperable quantile models, see e.g. Chernozhukov and Hansen (2005)). The goal is to identify the causal effect ϕ, which allows to obtain the average treatment effect of changing treatment level from z ∈ Z to z ∈ Z, We say that Z is endogenous when the causal effect ϕ is not characterized by the distribution of Y conditional on Z. Even in this setting, it is possible to identifiy ϕ thanks to an instrumental variable W with support W ⊂ R q . Loosely speaking, an instrumental variable satisfies three conditions. First, it is (in some sense specified in the paper) independent of {U (z)} z . Second, it affects (causally) Y only through Z. Third, it is sufficiently related to Z.
Our goal is to test the following hypothesis H 0 : U (z) = U for all z ∈ Z.
We call this assumption "error invariance" since it stipulates that the error term does not vary with the treatment level.
There are two reasons why one would be interested in testing H 0 . First, under the instrumental variable conditions, several works in the instrumental variable literature (Newey and Powell (2003a); Horowitz and Lee (2007); Darolles et al. (2011); Chen and Pouzo (2012) among others) show that the causal effect ϕ is identified if H 0 holds. When H 0 is not satisfied, instrumental variable estimators can be more biased than naive estimators ignoring confounding since the error term U = U (Z) of the model can be dependent of W (through Z). Second, if H 0 is true, the treatment effects are constant (that is Y (z ) − Y (z) is a deterministic variable). This allows to estimate all counterfactuals for each observation in the dataset (individualized predictions) using an estimator of ϕ. It also means that the treatment does not distort the ranks of potential outcomes, so that the inequalities between subjects are not modified by the treatment.
The contributions of the paper are as follows. We propose two tests for H 0 . The tests rely on a scalar covariate X, which satisfies certain conditions outlined in the paper. The first test relies on the assumption that the potential outcomes are linear in the regressors.
In a first step, it estimates U as the residual of a two stage least-squares regression. Then, it tests that the estimator of U is uncorrelated with X(W k − E[W k ]) (for some component W k of W ), which is an implication of rank invariance under our assumptions. The second test is nonparametric. In this case, the error term U is estimated by the residual of a Tikhonov regression. The second step of the test is then the same as that of the linear test. In both cases, the treatment can be discrete or continuous. We study the asymptotic distribution of the test statistic and the power of the test. We discuss how to choose X: to maximize the likelihood that the conditions on X are satisfied, we argue in the paper that X should be chosen so as to be independent of W . Finally, the empirical performance of the tests is assessed through simulations and illustrated thanks to applications on returns to schooling and price elasticity of demand in a fish market.
Related literature. Our paper is related to a large literature on testing for (various implications of) constant treatment effects: see Koenker and Xiao (2002); Crump et al. (2008); Chernozhukov and Fernández-Val (2005); Ding et al. (2016); Hsu (2017) ;Goldman and Kaplan (2018); Chung and Olivares (2021); Sant'Anna (2021); Dai and Stern (2022) among others. Apart from Sant'Anna (2021), none of these papers considers the case where there is endogeneity. Sant'Anna (2021) only studies the setting where both the treatment and the instrument are binary and a monotonicity assumption such as in the literature on local average treatment effects holds (see Angrist et al. (1996)). Instead, our paper allows for confounding and continuous treatments.
Another related literature is that on the hypothesis of rank invariance (see Chernozhukov and Hansen (2005)). This assumption is the counterpart of our error invariance condition in nonseparable instrumental variable models (in contrast with the present paper which studies separable models). Chernozhukov and Hansen (2005) notes that identifica-tion of ϕ can be obtained under a weaker (but less interpretable) form of rank invariance called rank similarity. We could define an assumption analogous to rank similarity in our case of separable models. Our tests would also work for this assumption. We chose to focus solely on error invariance to simplify the exposition. Moreover, Dong and Shen (2018) and Frandsen and Lefgren (2018) develop tests of the rank invariance assumption in nonseparable instrumental variable models in the case where the treatment and the instrument are binary. The case with continuous treatment is much more challenging because regularization is needed for nonparametric estimation. Note also that Dong and Shen (2018) relies on the usual monotonicity assumption from local average treatment effects literature (see Angrist et al. (1996)), while our approach does not require it. The test developed in Frandsen and Lefgren (2018) bears similarities with our test since they are based on equivalent single restrictions. However, our model and the first step of our test are different. Moreover, Frandsen and Lefgren (2018) lacks a coherent theoretical framework justifying the test.
For instance, no assumption on the covariable (X in the present paper) is formulated in Frandsen and Lefgren (2018), so that it is unclear under which conditions rank invariance implies the linear hypothesis tested by Frandsen and Lefgren (2018) and when the test has power. In fact, one can show that the approach of Frandsen and Lefgren (2018) is implicitly based on moment restrictions constraining the data generating process in a similar way as our Assumption 2.1 on X, but Frandsen and Lefgren (2018) does not mention these hypotheses. In contrast, the present paper proposes a more formal framework in which it is possible to understand when the test will or will not work.
Outline. Section 2 presents the linear test along with theory, simulations and an application to returns to schooling. Then, in Section 3, we introduce the nonparametric test, discuss its asymptotic properties, evaluate its finite sample performance through numerical experiments and illustrate the test with an application to demand estimation. All the proofs along with some examples regarding the analysis of the power of the nonparametric test can be found in the supplementary material.
2 Linear test

Model
In this section, we develop theory for a test assuming that the mapping ϕ is linear and the for all z ∈ Z. We also impose the usual relevance assumption for instrumental variables in the linear model, that is E[W Z ] has rank equal to p. The aim is to recover β, since the average treatment effect of changing treatment level from z ∈ Z to z ∈ Z can be expressed To test for H 0 , we leverage a scalar covariate X satisfying the following condition: Assumption 2.1 There exists k ∈ {1, . . . , q} such that, for all z ∈ Z, This condition means that one component W k of the instrument is uncorrelated with the product of the unobserved heterogeneity of the model U (z) and the covariable X.
The tests of H 0 that we propose depend crucially on Assumption 2.1. Contrarily to H 0 , hypothesis 2.1 can be heuristically justified. Indeed, Assumption 2.1 is implied by the stronger condition where the sign ⊥ ⊥ stands for statistical independence. Hence, the econometrician should try to select a covariable X which is likely to be (jointly with {U (z)} z ) independent of W k .
The fact that {U (z)} z is independent of W corresponds to what is expected from a "good" instrument. As a result, in applications, we recommend to pick a variable X independent of W k since this should make Assumption 2.1 more likely to hold (the joint independence in (1) is not much stronger than the marginal independence, {U (z)} z ⊥ ⊥ W and X ⊥ ⊥ W k ). Finally, remark also that X does not need to be an instrument. In particular, its dependence with {U (z)} z and Z is left unrestricted.
Let us now define the population analog of the two-stage least squares estimator (henceforth, TSLS) in this context: In this case, under H 0 , β can be estimated by TSLS, that is β T SLS = β. However, when H 0 does not hold, then the bias of the TSLS estimator can be larger than that of the ordinary least squares (henceforth, OLS) estimator as illustrated by the following example.

Testable implication
This is the testable implication of H 0 that we use to build our test.
Remark that the role of the covariable X appears clearly in (2). Indeed, when W contains an intercept, the equality always holds by definition of U T SLS , regardless of the validity of H 0 . Hence, a test based on (3) would have no power. The role of X is therefore to give power to our test.

Sample test
Let us formally outline the test. Consider an i.i.d. sample {Y i , Z i , W i , X i } n i=1 generated from the model of Section 2.1. Let β T SLS be the TSLS estimator in this sample, given by The test statistic is then We use bootstrap to obtain the p-value of the test, since the variance of the statistic has a tedious expression and variance estimators based on analytical formulas tend to perform poorly in the presence of heteroscedasticity (see e.g. MacKinnon and White (1985)). The procedure to compute the p-value is as follows.
1. Draw n observations with replacement from the sample 2. Compute the bootstrapped statistic T * n,b on the bootstrapped sample 3. Repeat steps 1-2 B times (with B large) so as to get the collection of bootstrapped If the p-value so obtained is smaller than α (the nominal size of the test), the null hypothesis is rejected at the α nominal level. Notice that in the above procedure we are computing a symmetric p-value. An alternative procedure is to compute an equal-tailed p-value, but in our simulations the symmetric one has a satisfying performance.

Power analysis
The test will have asymptotic power equal to 1 under alternative hypotheses for which Since We see that there are two reasons why the test would have power: (1) the variable W k is correlated with U (Z)X; (2) it holds that β = β T SLS and E[X(W k −E[W k ])Z ] = 0 for at least one in {1, . . . , p}.
We argue that (1) and (2)  Overall, although there are cases where the test does not have power, the above discussion suggests that the test has power against a wide range of alternative hypotheses. The following example illustrates this claim.
Example 2. Let (W, E, X) be a 3 × 1 Gaussian vector with mean zero and variance equal to the identity matrix. Let also Z = W + W E + ρW X, U (Z) = Z(E + ρX), where ρ ∈ R, and β = 0 so that Y = U (Z) = Z(E + ρX). In this case, we have In the present context, it is well- As a result, the test has no power only when X and U are independent, that is ρ = 0, which is a degenerate case.
In this parametric example, we see that the alternatives under which the test has no power have measure equal to 0 for the uniform measure. The example also shows the role of X in providing power to the test, since the latter does not have power only when X and (Z, {U (z)} z ) are independent.

Asymptotic theory
In this section, we state the asymptotic properties of the test statistic. We make the following assumption, which ensures the convergence of the TSLS estimator.
exists and has rank p and E[W W ] exists and has full rank.
We have the following theorem.
Theorem 2.1 Let Assumptions 2.1 and 2.2 hold. Then, T n converges to a zero mean Gaussian distribution under H 0 , while |T n |/ √ n → C = 0 when (4) holds.
The influence function representation of the test statistic is given in Lemma 1 in the supplementary material. The asymptotic variance of the test statistic can be derived from this result. Note that the fact that |T n |/ √ n → C = 0 when (4) holds implies that the power of the test goes to 1 as n goes to ∞ under alternative hypotheses satisfying (4).

Simulations
We study the following data generating process. Let (W 2 , E, X, Z 3 ) follow a standard 4-dimensional Gaussian distribution. We define The variable Z 2 suffers from confounding and is instrumented by where ρ ∈ R. The null hypothesis H 0 holds when ρ = 0. The outcome is Y = U (Z) so that the causal regression function of interest is ϕ = 0. We set k = 2, that is we use the second component of W to compute the test statistic We generate data with sample sizes n ∈ {100, 200, 500, 1000}. We investigate the empirical size of the test when ρ = 0 ( Table 1). The results are averages over 10000 replications using B = 1000 bootstrap resamples. We also study the empirical power of the test when ρ = −1, −0.9, . . . , 1, with a thousand replications and bootstrap resamples (See Figure 1).
The empirical size of the test is almost nominal even for low sample sizes. The power of the test increases as the deviation from the null (|ρ|), or the sample size, become larger. n 100 250 500 1000 Empirical size at 5% 0.0397 0.0512 0.0506 0.0506 Empirical size at 10% 0.1038 0.1050 0.1038 0.1014 Table 1: Empirical size of the test of theoretical size 5% and 10% for various sample sizes.

Application on returns to schooling
In this section, we test for error invariance in a famous application on returns to schooling from Card (1995). The database is available in the R package ivreg and is an extract from the 1976 National Longitudinal Survey (NLS) of young men. In this example Y = log(wage), Z = (1, education, experience, experience 2 , smsa, south, ethnicity) , where 1 denotes a constant, education and work experience are measured in years and smsa, south, ethnicity are controls whose definition can be found in the ivreg package. Education and experience are endogenous since they depend on individual's ability which is unobserved. The instrument is W = (1, nearcollege, age, age 2 , smsa, south, ethnicity) , where nearcollege is an indicator whose value is equal to 1 when the individual grew up near an accredited four-year college. The validity of the instrument is documented in Card (1995). This corresponds to one of the specifications in the original paper of Card (1995). The variable X is an indicator for being married. It is unlikely that being married is (jointly with the unobserved heterogeneity of the model) dependent from growing up near a four-year college. In fact, a χ 2 test does not reject hypothesis of independence of W 2 = nearcollege and X = married (p-value equal to 0.55). Hence, we can reasonably

Nonparametric test
In this section we extend the linear framework to consider a nonparametric treatment function. We keep the notation previously introduced and write The error term is now supposed to be mean independent of the instrument ( Let L 2 (Z) be the set of functions that are square integrable with respect to the distribution of Z. We maintain the following assumption which is also standard in the NPIV literature.
Assumption 3.1 The following holds: The first part of the assumption is the completeness condition standard in the NPIV literature. It means that W is sufficiently associated with Z. Under the null hypothesis H 0 , such a condition is necessary and sufficient for identifying ϕ (see, among others, Carrasco et al. (2007), Darolles et al. (2011), Newey andPowell (2003b), D'Haultfoeuille (2011)).
The second part states that the NPIV model in the above equation is well specified. We will discuss this assumption in Section 3.2.
Recall that the hypothesis that we want to test is Under the null hypothesis of error invariance the treatment function ϕ must satisfy the following equation Under the completeness condition (Assumption 3.1 (i)) the solution to the above equation is unique and can be consistently estimated (we introduce an estimator below). Thus, under the null hypothesis of error invariance we can consistently estimate the nonparametric treatment function ϕ. Differently, when H 0 does not hold, the solution to Equation (6) will be different, in general, from the treatment function of interest ϕ. This solution, denoted ϕ, is introduced in Assumption 3.1 (ii). So, if H 0 is not true, although we will be able to estimate consistently the solution to Equation (6), we will in general not obtain a consistent estimator of ϕ. It is therefore crucial to test for the error invariance hypothesis.
Similarly to the previous section, the testable implication of the error invariance assumption is and ϕ denotes the unique solution to Equation (6)  Let ϕ be an estimator for ϕ (below we define our estimator), and let us define the esti- Our statistic is the empirical counterpart of the above moment In the following section, we explain how to compute the above statistic and implement the test based on it. In Section 3.2, we present the assumptions and the results for the validity of the test. Next, in Section 3.3, we provide evidence about the finite sample performance of the test based on S n . Finally, we illustrate the procedure by an application to demand estimation in Section 3.4.

Construction of the statistic and implementation of the test
In this section, we outline the computation of the statistic S n and implement the test. To this end, we need (i) to compute ϕ(Z i ) for i = 1, . . . , n, and (ii) to obtain the p-value necessary for testing.
Computation of ϕ. Let π and τ be positive functions on R. We denote with L 2 π (R) the space of square integrable functions with respect to π, and let L 2 τ (R) be similarly defined. The functions π and τ are introduced for the aim of generality and for technical reasons.
In simulations they are set to Gaussian density functions. Let us briefly explain their roles.
First, from a technical point of view it would be ideal to work with the spaces L 2 (Z) and L 2 (W ), i.e. the spaces of square integrable functions with respect to the distribution of Z and W . However, since we do not know such distributions, it is convenient to replace L 2 (Z) and L 2 (W ) with L 2 τ (R) and L 2 π (R) and work with the latter spaces. Second, by working with L 2 τ (R) and L 2 π (R) we can obtain that the estimator of the dual of A (defined below) is actually the dual of the estimator of A. This is an important property for establishing the asymptotic normality of our statistic S n under H 0 . Let f W stand for the density of W with respect to the Lebesgue measure, and assume that τ (w) > 0 whenever f W (w) > 0.
Then, Equation (6) To build an estimator for ϕ we start from the above integral equation. Let us denote by f ZW the joint density of (Z, W ) with respect to the Lebesgue measure and introduce L 2 π⊗τ (R 2 ), which is the set of functions from R 2 to R square integrable with respect to the product measure π ⊗ τ (the measure generated by the product density π · τ ). By assuming .

Its Hilbert adjoint
We also define the "left hand side" of the integral equation (7) as We estimate A and A * by replacing f ZW with its kernel estimator where K Z and K W are two kernel functions while (h Z , h W ) denote two bandwidths converging to zero as the sample size increases. The mapping r is instead estimated by To estimate ϕ, i.e. the solution to Equation (7), we use a Tikhonov regularization scheme where I stands for the identity operator, while λ > 0 denotes the Tikhonov regularization parameter. See, e.g.,  and Darolles et al. (2011).
To compute ϕ we need to select two bandwidths (h Z , h W ) and a regularization parameter λ. We will explain below how to do it. For the moment, let us outline the computation of ϕ in the previous display for given (h Z , h W , λ). Although ϕ seems to have an abstract expression, its computation is straightforward as it reduces to matrix products. To see this, we first approximate A and A * by using a common bias computation similarly as in Centorrino et al. (2017) : The above approximations hold for h Z , h W → 0. Let M Z be the n × n matrix having on the ith row and jth column the element K((Z i − Z j )/h Z )/[π(Z i )nh Z ] and let M W be the n × n matrix having on the ith row and jth column the element K((W i − . Let − → r and − → Aφ (for a generic function φ) be similarly defined. By the expression of ϕ and the above approximations we get up to an approximation error. Thus, the computation of ϕ at the data points reduces to a simple matrix computation and the residuals can be easily computed as Let us turn now to the selection of the smoothing parameters (h Z , h W ) and the regularization parameter λ. The bandwidths h Z and h W are selected by the Silverman Rule of Thumb, so that h Z = σ Z n −1/5 and h W = σ W n −1/5 , where σ Z and σ W denote the sample standard deviations of Z and W . Finally, to select the Tikhonov regularization parameter, we use the Cross-Validation method developed in Centorrino et al. (2017). Thus, where Here A −i and A * −i denote the "leaveone-out" versions of A and A * that use the entire sample except the ith observation. By the approximations of A and A * previously outlined, the vector where diag(M W ) denotes the diagonal matrix having the same main diagonal as M W , and diag(M Z ) is similarly defined. The objective function in (9) has a U-shaped form as a function of λ and can be minimized in a simple way by numerical methods, see Centorrino et al. (2017).
For the sake of clarity, we sum up the steps needed for computing S n as follows: 1. Select λ according to the Cross-validation method in Equation (9) 2. Use λ to compute { ϕ(Z i ) : i = 1, . . . , n} as in (8) and compute the residuals as 3. Compute the statistic as Implementation of the test. To implement the test, we are just left with the computation of the p-value. As we show in the next section, under the null hypothesis the statistic S n is asymptotically normal but the asymptotic covariance has an intricate expression.
So, to obtain the p-value necessary for testing we rely on the pairwise bootstrap. The validity of the pairwise bootstrap is confirmed by our simulations and is not surprising given that we show asymptotic normality. In fact, under different conditions, Chen et al. (2003) show the validity of the bootstrap for a a real-valued estimator based on a first step infinite-dimensional estimator, as is ϕ in this paper.
The procedure goes as follows: 1. Draw n observations with replacement from the sample 2. Compute the bootstrapped statistic S * n,b on the bootstrapped sample using the same bandwidths (h Z , h W ) and regularization parameter λ as in the original sample 3. Repeat steps 1-2 B times (with B large) to obtain the collection of bootstrapped

Asymptotic behavior
In this section, we outline the assumptions under which we obtain the asymptotic properties of the test statistics. The following definition introduces some regularity features that the joint density f ZW and the NPIV function ϕ must satisfy.
Definition 1 For a given function γ and for α ≥ 0 , s > 0, the space B s,α γ (R ) is the class of functions g : R → R satisfying: g is everywhere (m − 1) -times partially differentiable for m − 1 < s ≤ m; for some R > 0 and for all x, the inequality holds true, where Q = 0 when m = 1 and Q is an (m − 1)th degree homogeneous polynomial in (y − x) with coefficients the partial derivatives of g at x of orders 1 through m − 1 when m > 1; ψ is uniformly bounded by a constant when α = 0 and the functions g and ψ have finite αth moments with respect to 1/γ when α > 0, i.e. |g(x)| α /γ(x) dx < ∞ and Let f Z denote the density of Z with respect to the Lebesgue measure and let us define Assumption 3.2 ϕ ∈ B ρ,0 1 (R) ∩ L 2 π (R) and f ZW /(π τ ) ∈ B ρ,0 Assumption 3.2 is a common regularity condition allowing for several degrees of integrability and differentiability . Under the above assumption A : L 2 π (R) → L 2 τ (R), A * : L 2 τ (R) → L 2 π (R), and r ∈ L 2 τ (R). Notice that A * is actually the Hilbert adjoint of A. This aspect is used multiple times in the proofs. Assumption 3.3 K Z and K W are symmetric kernels of order ρ with bounded support.
The kernel orders in Assumption 3.3 are assumed to be equal only for notational simplicity.
To simplify our theoretical exposition we further assume that h W = h Z and denote each bandwidth by h. However, our proofs also hold when such smoothing parameters are set to different values (and the kernel have different orders).
The order ρ of the kernels K Z and K W , the bandwidth h and the regularization parameter λ satisfy the following assumption.
Such conditions allow us to control the regularization bias and the variance of ϕ appearing in the expansion of S n . In particular, nh 2 λ 3/2 allows controlling the "variance term". nλ 2 and h ρ λ −3/4 allow us to obtain the negligibility of the regularization bias that appears in the expansion of S n and is due to the ill-posedness of the inverse problem.
Let us denote with ·, · the inner product of either L 2 π (R) or L 2 τ (R), and let · be the norm induced by such an inner product. The specific inner product or norm we refer to will be clear at each time from the context. Let (λ j , ϕ j , ψ j ) j be the Singular Value decomposition of the operator A, where (λ j ) j is the sequence of singular values in R, (ϕ j ) j is an orthonormal sequence in L 2 π (R), and (ψ j ) j is an orthonormal sequence in L 2 τ (R). The following assumptions introduces the usual source conditions. Assumption 3.5 Let ·, · denote the inner product on L 2 π (R).
Source conditions are standard in the NPIV literature (see  or Darolles et al. (2011)). In general, the source condition is imposed only on ϕ when the interest is on estimating ϕ. Here, we need a source condition on both ϕ and g to establish the asymptotic properties of the statistic based on the residuals from the nonparametric regression. To this end, we also need some regularity conditions on the estimator ϕ. So, let N [·] ( , Φ, || · || P ) be the bracketing number of size of a class of functions Φ, where || · || P denotes the L 2 norm with respect to the probability P, see .
Assumption 3.6 There exists a class of functions Φ such that The above condition is a high-level assumptions allowing us to handle an empirical process in the expansion of our statistic. It essentially introduces a Donsker feature for the function ϕ. Such an assumption has been used among others by Rothe (2009)   or Van der Vaart and Wellner (1996). We have also derived alternative proofs based on sample splitting or cross-fitting that avoid such a high-level condition. We have run simulations with cross-fitting and sample-splitting, but we did not notice any improvement in terms of finite sample performance. Thus, we choose to keep the above assumption and avoid sample splitting (or cross-fitting) for a simple implementation of the test. Alternatively such a high-level condition could be avoided by using a Sobolev penalized method for estimating ϕ. This however would produce much longer proofs and complicate the implementation of the test.
Let P n be the empirical mean operator. We have the following theorem.
Theorem 3.1 Let Assumptions 2.1 and 3.1 to 3.6 hold. Under H 0 , The proof of the Theorem is in Section B.1 of the supplementary material. Let us briefly comment on the asymptotic expansion (influence-function representation) of the statistic.
The first term on the right hand side is the version of our statistic that we could use had we observed the error U and E[W ]. The second term arises because the expectation E[W ] is unobserved and is replaced by its estimated counterpart. Similarly, the third term arises because the error U is unobserved and to estimate it we replace the true function ϕ 0 with its estimator ϕ. More in detail, such a term originates from a (nonparametric) bias involving the difference ϕ − ϕ that appears in the expansion of S n . This inflates the asymptotic variance of the statistic, as compared to the case where U is known, and hence represents the price to pay for not observing the error term. To handle this bias term, we rely on decompositions from Darolles et al. (2011) and Babii and Florens (2017). The expansion in Theorem 3.1 allows us to obtain the asymptotic normality of our statistic under the null hypothesis. To this end, notice that the first term has zero expectation under the null of error invariance. The second term has clearly a null expectation. Finally, since E[U |W ] = 0, the last term also has zero expectation. Therefore, a standard Central Limit Theorem implies the asymptotic normality of S n . As for the linear test, the fact that
To check the robustness of our test with respect to the choices of the smoothing and regularization parameters, we let them vary around the benchmark values. So, we set are the bandwidths set according to the Silverman's Rule of Thumb while λ * is the regularization parameter selected according to the Cross-Validation method, as seen in Section 3.1. C h and C λ are fixed constants.
We run simulations for C h , C λ ∈ {0.5, 1, 2} and we consider the modest sample sizes of n = 100, 250, 500. As a kernel we use the standard Gaussian density. We set π to the Gaussian density with mean equal to the sample mean of Z and variance equal to twice the sample variance of Z. Similarly, the measure τ is set to the Gaussian density with mean equal to the sample mean of W and variance equal to twice the sample variance of W .  used a similar strategy to select π and τ in their simulation setting. Intuitively, since π and τ have to be two densities and at the same time appear at the denominators in A and A * , we want them (i) to integrate to 1 and (ii) to converge towards zero sufficiently slowly on the tails. To speed up computations, we use the warpspeed method by Giacomini et al. (2013): for each Monte Carlo iteration we draw a single bootstrap sample, and we use the whole set of bootstrap statistics to compute the bootstrap p-values associated with each original statistic. We perform a very large number of Monte Carlos iterations equal to 10,000.
The results under the null hypothesis of error invariance (γ = 0) are reported in Table   2. The tests are implemented at 5 and 10 percent nominal levels. The result show that the test is reasonably stable with respect to the choices of λ, h Z , and h W and controls well the size under the null hypothesis. Also, as expected, the error in the rejection probability To sum up, these simulations show that (i) for the moderate sample sizes of n = 100, 250, 500 the tests display a good performance both in terms of size control and in terms of power, and (ii) the results are stable with respect to the choices of the smoothing and regularization parameters.

Application to real data
In this section we apply the test of error invariance to a fish demand equation. This describes the relationship between the demanded quantity of fish and its price. It is common practice in econometrics to assume that prices are endogenous and estimate demand equations by instrumental variable regressions.
The data we use come from Graddy (2006) and contain daily observations at the New York Fulton fish market about the log of the price, the sold quantity, an indicator for each day of the week, and the wind speed registered in the previous day. The dataset can be downloaded at "https://users.ox.ac.uk/ nuff0078/EconometricModeling/". The total number of observations is 111.
We study a demand equation. The outcome Y is equal to the logarithm of the quantity sold and Z is the logarithm of the market price. Market price is likely to be endogenous since it also depends on expected demand, which itself also affects the quantity. Following the literature (Graddy (2006)), we choose a variable related to weather as an instrument, so we set W equal to the wind speed recorded on the day corresponding to the observation.
Such a variable is viewed as sufficiently correlated with the price (Z), since the weather affects the ability to fish, and is at the same time exogenous with respect to the errors {U (z)} z since it is probably unrelated to demand shocks related to human factors.
The choice of the covariable X is crucial. We set X equal to the indicator for week days (Monday to Thursday). Such a variable should not be correlated with the wind speed since the weather does not depend on the day of the week. In fact, a Kolmogorov-Smirnov test does not reject the hypothesis of independence between X and W (p-value of 0.17).
Hence, we can reasonably assume that E[U (z)X(W − E[W ])] = 0 for all z ∈ Z, which corresponds to Assumption 2.1. Table 3 reports the p-values of the test. Similarly as in Section 3.3, to check the robustness of our findings we perturb the benchmark bandwidths (h * W , h * Z ) and the benchmark regularization parameter λ * . We use 1, 000 bootstrap resamplings. Our test rejects the null hypothesis of error invariance at the 5 percent nominal level for most configurations considered. So, we conclude that the causal intepretation of the separable NPIV regression should be doubted for this specific example.
It holds that Hence, (A.1) is a linear projection of Y on Z. Since this linear projection is unique (because

A.2 Proof of Theorem 1
Theorem 1 is a direct corollary of the following lemma, which gives the influence function representation of the test statistic.
Lemma A.1 Let Assumptions 2.1 and 2.2 in the main text hold. Then, we have We deal with the first term on the right-hand side of (A.2). We have Then, we handle the second term on the right-hand side of (A.2). It holds that Since β T SLS − β = O P (1/ √ n), and by the law of large numbers Moreover, by standard computations, we have which leads to the result.

2
B On the nonparametric test B.1 Proof of the results of Section 3 Recall that P n represents the empirical mean operator. Let us denote with P the population mean operator, so Pf (ξ) = Ef (ξ) for any random variable ξ. We finally denote with · π the norm of the L 2 π (R) space, i.e. f 2 π = |f (z)| 2 π(d z) for any f ∈ L 2 π (R).

B.1.1 Proof of Theorem 2
Let us decompose the statistic as follows: We start by showing that the last term on the RHS equals E[U X] · √ nP n (W − E[W ]) + o P (1). Notice that √ nP n U X(W − E[W ]) = P n U X · √ n(P n − P)W . By Assumption 3.6 in the main text, with probability approaching one It follows from the definition of bracketing . Assumption 3.6 ensures that the RHS of this inequality is finite for any . So, the class Υ is Glivenko-Cantelli and by Theorem 19.4 in  we get that (P n − P)φ = o P (1) uniformly in φ ∈ Υ. This and the previous display lead to P n U X = P U X + P (ϕ − ϕ) X + o P (1) .
To show the negligibility of the second term on the RHS, by the Law of Iterated Expectations and the Cauchy-Schwartz inequality we get where · π denotes the norm on L 2 π (R). The second factor on the RHS is finite by Assumption 3.2 in the main text. The first factor is instead o P (1) by Lemma B.5. By putting together these results, we find that We now show the negligibility of the second term on the RHS of Equation (B.1). Combining the Law of Iterated Expectations and Assumption 3.2 leads to with ϕ−ϕ 2 π = o P (1), as previously found. So, by Assumption 3.6 and the boundedness of To show the behavior of the statistic under the alternative, we can proceed as at the beginning of this proof to obtain where U = Y − ϕ(Z) and the first leading term is different from 0 under H 1 .

B.1.2 Auxiliary lemma
In this section we provide an auxiliary lemma we used in the proofs of Theorem 2. Let us denote with ·, · the inner product on either L 2 π (R) or L 2 τ (R), and let · denote the norm induced by such an inner product. Whether ·, · and · refer to either L 2 π (R) or L 2 τ (R) will be clear by their arguments. Also, given the operators A and A * we define Aφ 2 and A * 2 op := sup Since A and A * are linear bounded operators, both A 2 op and A * 2 op are finite. Also, since A * is the Hilbert adjoint of A, it holds that A 2 op and A * 2 op are equal.
Lemma B.1 Under Assumptions 3.1 to 3.6 in the main text, we have Proof. Let us start with the following decomposition The previous decomposition holds because where the second line follows from the Cauchy-Schwartz inequality and the continuity of A−A, while the third line follows from Assumption 3.5(i) and Lemma B.4(iv). Assumption 3.5(i) ensures that η ≥ 2. As already noticed before, || A − A|| op / √ λ = o P (1) and || r − A ϕ||/ √ λ = o P (1). So, by the above display and Assumption 3.4 we find We now handle the term √ n ϕ λ − ϕ, g . By Assumption 3.5(ii) and Lemma B.
By proceeding along the same lines we find that E 4th term RHS of (B.17) 2 ≤ Ch 4ρ n = o(1) .
We are now able to obtain the Influence function representation for √ n Ξ 1 , g in Equation (B.16). By the previous five displays and since (A * A) −1 g < ∞, the first term on the RHS of (B.16) equals To conclude the proof, notice first that Equation (B.17) and the four displays after it ensure that √ nA * ( r − A ϕ) = O P (1). So, the norm of the second term on the RHS of (B.16) is upperbounded as follows By recalling that we have set η = 2, we have (A * A) η/2 = A * A. Thus, by definition of f we get g = (A * A) η/2 f = A * A f and Since (λI + A * A) −1 A * is a regularization scheme, the RHS of the above display converges to 0 as λ → 0 (see Kress (1999)). This concludes the proof.

B.1.3 Auxiliary Results
The following lemma is borrowed from  (see their Lemma A.1(b)).
Lemma B.2 Under Assumptions 3.2 to 3.4 in the main text, we have The following lemma is well established in the literature on empirical process theory. A proof can be found in Andrews (1994). The lemma that follows gathers several useful results about inequalities of norms involving compact operators. Its proof can be found in Florens et al. (2011) and.