Simulation & Power Analysis

Six data-generating processes, Monte Carlo experiments and power curves.

SpatialEconometrics.SpatialSimulation.MonteCarloResult — Type
MonteCarloResult

Output of monte_carlo_spatial: sampling behaviour of an estimator over repeated draws from a known process.

Fields

  • param_means, param_stds: mean and standard deviation of the estimates across replications.
  • param_bias: mean estimate minus the true value.
  • param_rmse: root mean squared error, the summary that trades bias against variance.
  • param_names: row labels, taken from the DGP.
  • rejection_rates: empirical rejection rate per test — size when the null holds, power when it does not.
  • n_successful, n_replications: replications that produced an estimate, and replications attempted. Failures are excluded rather than averaged in, so a gap between these two is itself a finding.
Warning

param_names describes the DGP, not the estimator. Fitting a deliberately misspecified model still gives meaningful beta rows, but a trailing row labelled rho or lambda holds whatever parameter the estimator returned in that position.

source
SpatialEconometrics.SpatialSimulation.PowerAnalysisResult — Type
PowerAnalysisResult

Power surfaces from power_analysis, for the three standard tests for spatial dependence.

Fields

  • sample_sizes: the N values examined (one per grid side length).
  • rho_values: the spatial parameter strengths examined.
  • power_moran, power_lm_lag, power_lm_error: matrices of rejection rates, indexed [sample size, rho].
  • alpha: nominal size used.

Read the rho = 0 column as a check on size: it should sit near alpha, and a test that fails there has no credible power anywhere else.

source
SpatialEconometrics.SpatialSimulation.SAC_DGP — Type
SAC_DGP(rho, lambda, beta, sigma)

Dependence in both y and the errors (SAC / SARAR): y = rho*W*y + X*beta + u, u = lambda*W*u + e.

With one weight matrix doing both jobs, rho and lambda are only weakly separated in finite samples — useful precisely for showing how hard the specification search gets. Parameter order is beta, rho, lambda.

See also SpatialDGP, SARAR.

source
SpatialEconometrics.SpatialSimulation.SAR_DGP — Type
SAR_DGP(rho, beta, sigma)

Spatial autoregressive process: y = rho*W*y + X*beta + e, with e ~ N(0, sigma^2).

Drawn as y = (I - rho*W)^{-1} (X*beta + e). Parameter order for comparison is beta then rho.

Examples

dgp = SAR_DGP(0.5, [1.5, -0.8], 0.5)
y, X = simulate_spatial(dgp, W, X)

See also SpatialDGP.

source
SpatialEconometrics.SpatialSimulation.SEM_DGP — Type
SEM_DGP(lambda, beta, sigma)

Spatial error process: y = X*beta + u with u = lambda*W*u + e.

Dependence is in the disturbance only, so OLS stays unbiased but its standard errors are wrong — which is what makes this the useful null for lm_test_error. Parameter order is beta then lambda.

See also SpatialDGP.

source
SpatialEconometrics.SpatialSimulation.SLX_DGP — Type
SLX_DGP(beta, theta, sigma)

Spatially lagged covariates only: y = X*beta + W*X*theta + e.

No feedback through y, so OLS on [X W*X] is consistent and the spillovers are read straight off theta without inverting (I - rho*W). Parameter order is beta then theta.

See also SpatialDGP.

source
SpatialEconometrics.SpatialSimulation.monte_carlo_spatial — Function
monte_carlo_spatial(dgp, W, N, K, estimator; config=MonteCarloConfig(), x_generator=nothing)

Run a Monte Carlo experiment. estimator is a function (W, X, y) -> model returning a StatsAPI.RegressionModel. Returns MonteCarloResult with bias, RMSE, and test rejection rates.

The DGPs generate y without an intercept while the estimators fit one, so a leading (Intercept) coefficient is dropped before comparison; the remainder lines up with the DGP's parameter ordering for all six DGPs.

Rows are labelled by the DGP, not the estimator

param_names comes from dgp, so the table is only fully meaningful when the estimator matches the DGP. Deliberately fitting a misspecified model still reports useful bias and RMSE for the β rows, but a trailing row labelled ρ or λ holds whichever parameter the estimator happens to return in that position — for an SLX fitted to SAR data, for instance, it is the W_x1 coefficient.

Replications whose estimator throws are excluded and reported rather than averaged in; n_successful records how many contributed.

source
SpatialEconometrics.SpatialSimulation.power_analysis — Function
power_analysis(dgp_constructor, grid_sizes, rho_values; n_reps=200, alpha=0.05, seed=42)

Compute power curves for Moran's I, LM-lag, and LM-error across sample sizes and spatial parameter strengths.

dgp_constructor(rho) -> SpatialDGP returns a DGP parameterised by the spatial parameter of interest. grid_sizes is a vector of grid side-lengths (N = L²).

source