Skip to contents

\(\delta = E[f_X(X)\,\partial E(Y|X)/\partial X] = -2E[f_X'(X)Y]\). This is the DENSITY-WEIGHTED average derivative, not the plain \(E[\partial E(Y|X)/\partial X]\): for standard normal X with \(E(Y|X) = 2X\) the weighted estimand is \(2\int\phi^2 = 0.564\) while the unweighted one is 2. Integration by parts turns a derivative of an unknown regression into an expectation involving the DENSITY derivative, which is why this estimand is root-n estimable even though \(E(Y|X)\) is not. Mirrors morie.fn.hrzade.

Usage

morie_average_derivative(X, y, h = NULL, weighted = TRUE)

Arguments

X

numeric vector or matrix of covariates.

y

numeric response.

h

bandwidth for the density derivative; Silverman when NULL.

weighted

use the density-weighted form (kept for parity).

Value

list: delta, se, root_n, proportional_to_beta, bandwidth, n, d, method.

References

Horowitz, Ch. 2, Sec. 2.6.1.

Examples

set.seed(1)
x <- rnorm(300)
morie_average_derivative(x, 2 * x + rnorm(300, sd = 0.1))$delta
#> [1] 0.5461689