The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
This vignette (synthetic data) shows the two estimating-equation
interfaces. Both compute influence contributions and pass them to the
same core construction, aersn().
For OLS with regressors \(z_t\) and residuals \(\hat u_t\), the influence contribution of observation \(t\) to the coefficient vector is \(\hat Q^{-1} z_t \hat u_t\) with \(\hat Q = n^{-1}\sum_t z_t z_t^\top\). The intercept and any control coefficients are estimated jointly; their effect on the contributions of the coefficients of interest is retained.
library(aersn)
set.seed(21)
n <- 300
x1 <- as.numeric(arima.sim(list(ar = 0.6), n))
x2 <- as.numeric(arima.sim(list(ar = 0.3), n))
u <- as.numeric(arima.sim(list(ar = 0.5), n))
y <- 1 + 0.8 * x1 - 0.4 * x2 + u
fit <- aersn_lm(y ~ x1 + x2, target = c("x1", "x2"))
fit
#> Affine-equivariant adjusted-range self-normalization (increment hull)
#> model: linear regression by OLS (300 observations; psi_t = h' Q^{-1} z_t u_t)
#> n = 300 observations; q = 2 parameters
#> centering: calendar time, tau(r) = r
#> estimate:
#> x1 x2
#> 0.7604 -0.2256
#> hull diagnostics: numerical rank 2 of 2 ; condition 1.865 ; min projected range 0.8474 ; spread 2.557
#> Use aersn_test(), confint(), aersn_contrast(), aersn_region(), plot().
ref <- aersn_reference(fit, draws = 4000, seed = 1)
aersn_test(fit, null = c(0.8, -0.4), reference = ref)
#>
#> Adjusted-range increment hull test, q = 2
#>
#> data: fit
#> T = 2.505, q = 2, n = 300
#> alternative hypothesis: true parameter is not equal to the null value
#> null value: x1 = 0.8000, x2 = -0.4000
#> estimate: x1 = 0.7604, x2 = -0.2256
#> critical value at level 0.95: 2.534 (do not reject)
#> p-value = 0.0537 (Monte Carlo s.e. 0.0036, resolution 0.00025)
#> reference: matched-grid Monte Carlo law for increment-hull gauge: q = 2, uniform grid with n = 300 intervals, 4000 draws, seed 1
confint(fit, reference = ref)
#> Simultaneous (joint-region projection) Adjusted-range increment hull confidence intervals, level 0.95
#> lower upper
#> x1 0.5038 1.01700
#> x2 -0.4263 -0.02481
#> critical value 2.534 (reference dimension 2); matched-grid Monte Carlo law for increment-hull gauge: q = 2, uniform grid with n = 300 intervals, 4000 draws, seed 1
plot(fit, reference = ref, null = c(0.8, -0.4))A fitted lm object can be passed instead of a formula.
Weighted least squares and aliased coefficients are not supported.
aersn_gmm() takes the moment contributions \(m_t(\hat\beta_n)\), the average Jacobian
\(\hat D = n^{-1}\sum_t \partial
m_t(\hat\beta_n)/\partial\beta^\top\), the weighting matrix \(\hat W\), and the estimate. It forms \(\hat M = (\hat D^\top\hat W\hat D)^{-1}\hat
D^\top\hat W\) and the contributions \(\hat\psi_{n,t} = -\hat{\dot h}_n\hat M
m_t(\hat\beta_n)\) for the target \(h(\beta)\). The function warns when the
first-order condition \(\hat D^\top\hat W\bar
m_n\) is not close to zero, which indicates that the supplied
estimate does not solve the GMM problem.
Two-stage least squares with two instruments for one endogenous regressor:
set.seed(22)
z1 <- rnorm(n); z2 <- rnorm(n); v <- rnorm(n)
x <- z1 + 0.5 * z2 + v
y <- 1 + x + 0.6 * v + rnorm(n)
Z <- cbind(1, z1, z2); X <- cbind(1, x)
W <- solve(crossprod(Z) / n)
Dm <- -crossprod(Z, X) / n
gZy <- crossprod(Z, y) / n
beta <- -solve(t(Dm) %*% W %*% Dm, t(Dm) %*% W %*% gZy) # 2SLS
moments <- Z * as.numeric(y - X %*% beta)
gmm <- aersn_gmm(moments, Dm, beta, weight = W, target = 2, names = "slope")
gmm
#> Affine-equivariant adjusted-range self-normalization (increment hull)
#> model: smooth GMM (3 moments, 2 parameters; psi_t = -h' M m_t)
#> n = 300 observations; q = 1 parameter
#> centering: calendar time, tau(r) = r
#> estimate:
#> slope
#> 0.9915
#> hull diagnostics: numerical rank 1 of 1 ; condition 1.000 ; min projected range 1.328 ; spread 1.000
#> Use aersn_test(), confint(), aersn_contrast(), aersn_region(), plot().
aersn_test(gmm, null = 1, draws = 20000, seed = 1)
#>
#> Adjusted-range increment hull test, q = 1
#>
#> data: gmm
#> T = 0.1112, q = 1, n = 300
#> alternative hypothesis: true parameter is not equal to the null value
#> null value: slope = 1.000
#> estimate: slope = 0.9915
#> critical value at level 0.95: 1.837 (do not reject)
#> p-value = 0.895 (Monte Carlo s.e. 0.0022, resolution 0.000050)
#> reference: matched-grid Monte Carlo law for increment-hull gauge: q = 1, uniform grid with n = 300 intervals, 20000 draws, seed 1The sufficient conditions are those of the manuscript’s Assumption “Sufficient conditions for smooth GMM”: a stationary ergodic moment process, \(\sqrt n\)-consistency, full column rank of the population Jacobian, consistent Jacobian and weighting matrix, smooth moments, and a joint functional central limit theorem for the moments and their Jacobian. Under these conditions the path based on the estimated contributions is uniformly equivalent to the path based on the true influence function, so the hull-based inference is valid. Non-smooth moments (quantile regression) and nonstandard rates are outside this scope.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.