Simulation & Power Analysis
Six data-generating processes, Monte Carlo experiments and power curves.
SpatialEconometrics.SpatialSimulation.MonteCarloConfig — Type
MonteCarloConfig(; n_replications = 500, seed = 42)Replication count and seed for monte_carlo_spatial.
The seed fixes the whole experiment, so a run is reproducible; raising n_replications is what tightens the Monte Carlo standard error on the reported bias and RMSE.
SpatialEconometrics.SpatialSimulation.MonteCarloResult — Type
MonteCarloResultOutput 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.
SpatialEconometrics.SpatialSimulation.PowerAnalysisResult — Type
PowerAnalysisResultPower surfaces from power_analysis, for the three standard tests for spatial dependence.
Fields
sample_sizes: theNvalues 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.
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.
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.
SpatialEconometrics.SpatialSimulation.SDEM_DGP — Type
SDEM_DGP(lambda, beta, theta, sigma)Spatial Durbin error process: y = X*beta + W*X*theta + u with u = lambda*W*u + e.
Lagged covariates plus a spatial error, but no lag of y. Parameter order is beta, theta, lambda.
See also SpatialDGP.
SpatialEconometrics.SpatialSimulation.SDM_DGP — Type
SDM_DGP(rho, beta, theta, sigma)Spatial Durbin process: y = rho*W*y + X*beta + W*X*theta + e.
Nests SAR_DGP at theta = 0 and SLX_DGP at rho = 0, so it is the natural process for checking common_factor_test. Parameter order is beta, theta, rho.
See also SpatialDGP.
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.
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.
SpatialEconometrics.SpatialSimulation.SpatialDGP — Type
SpatialDGPA data-generating process for simulation, passed to simulate_spatial and monte_carlo_spatial.
Six processes are provided, spanning the usual specification ladder: SAR_DGP, SEM_DGP, SDM_DGP, SLX_DGP, SAC_DGP, SDEM_DGP.
None of them includes an intercept, while the estimators all fit one. monte_carlo_spatial drops the leading (Intercept) coefficient before comparing, so beta lines up with the estimates.
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.
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.
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²).
SpatialEconometrics.SpatialSimulation.simulate_spatial — Function
simulate_spatial(dgp, W, X; rng=Random.default_rng())Generate one realization from the specified spatial DGP. Returns (y, X).