Reference¶
This page documents the public spur-stata command surface.
Overview¶
| Command | Description |
|---|---|
spur |
Run the full SPUR workflow and return diagnostics plus levels and transformed branches |
spurtest |
Run one of the four SPUR diagnostic tests |
spurtransform |
Transform variables to remove spatial unit roots |
spurhalflife |
Estimate a spatial half-life confidence interval |
Conventions¶
Coordinates¶
All commands in the package expect the spatial coordinates to be stored in
variables named s_*.
- with
latlong,s_1is latitude ands_2is longitude - without
latlong, the availables_*variables are treated as Euclidean coordinates
Dependencies¶
morematais required by the SPUR commandsscpcis a separate Stata package and handles the inference stage after the branch has been chosen
Simulation Controls¶
The SPUR tests and half-life interval are simulation-based.
q(#): number of low-frequency weighted averages; defaultq(15)nrep(#): number of Monte Carlo draws; defaultnrep(100000)seed(#): random seed for the simulation draws; defaultseed(42)
Full Workflow¶
spur¶
Run the full SPUR workflow for a linear regression.
Syntax
spur depvar indepvars [if] [in] [, q(#) nrep(#) seed(#) latlong avc(#) uncond cvs replace]
Behavior
- runs
spurtest i0andspurtest i1on the dependent variable - runs
spurtest i0residandspurtest i1residfor the regression - estimates the levels regression with
regress ..., robust - runs the external
scpcpostestimation command - transforms the dependent and independent variables with
spurtransform, usingprefix(h_)andtransformation(lbmgls) - estimates the transformed regression with
regress ..., robust - runs
scpcagain
The wrapper always computes both the levels and transformed branches. It does not encode the practitioner-guide branch decision as a returned field.
Options
q(#),nrep(#),seed(#),latlong: passed to the SPUR diagnostic testsavc(#),uncond,cvs: passed toscpcreplace: allow overwriting existing transformedh_*variables
Stored results
spur stores the following main results in r():
r(diagnostics): rowsi0,i1,i0resid,i1resid; columnsteststat,p,ha_paramr(levels_scpcstats): SCPC inference table from the levels regressionr(transformed_scpcstats): SCPC inference table from the transformed regressionr(levels_scpccvs)andr(transformed_scpccvs): critical-value matrices whencvsis specified- diagnostic scalar aliases such as
r(i0_p)andr(i1resid_teststat) - model-statistic scalars such as
r(levels_N)andr(transformed_r2)
The wrapper is OLS-only. IV and fixed-effect workflows should be estimated
directly and followed by scpc.
Diagnostics¶
spurtest¶
Run one of the four SPUR tests.
Syntax
spurtest i1 varname [if] [in] [, q(#) nrep(#) seed(#) latlong]
spurtest i0 varname [if] [in] [, q(#) nrep(#) seed(#) latlong]
spurtest i1resid depvar [indepvars] [if] [in] [, q(#) nrep(#) seed(#) latlong]
spurtest i0resid depvar [indepvars] [if] [in] [, q(#) nrep(#) seed(#) latlong]
Subcommands
i0: variable-levelI(0)testi1: variable-levelI(1)testi0resid: residual-basedI(0)test for a linear regressioni1resid: residual-basedI(1)test for a linear regression
Options
q(#): number of weighted averages used in the test statisticnrep(#): number of Monte Carlo draws used to simulate the reference distributionseed(#): random seed for the simulation draws; defaultseed(42)latlong: interprets_1ands_2as latitude and longitude
Stored results
spurtest stores the following in r():
r(teststat): LFUR or LFST test statisticr(p): p-valuer(ha_param): alternative-hypothesis parameter (c_aorg_a)r(cv): matrix of critical values at 1%, 5%, and 10%
The residual tests automatically include a constant in the underlying regression.
Transformation¶
spurtransform¶
Transform one or more variables and write the transformed versions back into the current dataset.
Syntax
spurtransform varlist [if] [in], prefix(string) ///
[transformation(string) radius(#) clustvar(varname) latlong replace separately]
Required option
prefix(string): prefix applied to the transformed variables, for exampleprefix(h_)to createh_am
Options
transformation(string): transformation modelbmgls: GLS-style transformation; default branchnn: nearest-neighbor differencingiso: isotropic differencing within a radiuscluster: within-cluster demeaningradius(#): radius fortransformation(iso); required there and not allowed otherwiseclustvar(varname): cluster variable fortransformation(cluster); required there and not allowed otherwiselatlong: interprets_1ands_2as latitude and longitudereplace: allow overwriting previously created transformed variablesseparately: construct the transformation separately for each variable rather than on the common non-missing sample
Behavior
- the command transforms every variable in
varlist - transformed variables are written back into the active dataset
- there are no stored results; the output is the newly created variables
Persistence¶
spurhalflife¶
Estimate a confidence interval for the spatial half-life of a variable.
Syntax
spurhalflife varname [if] [in] [, q(#) nrep(#) seed(#) level(#) latlong normdist]
Options
q(#): number of weighted averages; defaultq(15)nrep(#): number of Monte Carlo draws; defaultnrep(100000)seed(#): random seed for the simulation draws; defaultseed(42)level(#): confidence level in percent; defaultlevel(95)latlong: interprets_1ands_2as latitude and longitudenormdist: report the interval as a fraction of the maximum pairwise distance rather than in distance units
Stored results
spurhalflife stores the following in r():
r(ci_l): lower interval boundr(ci_u): upper interval boundr(max_dist): maximum pairwise distance in the sample
If normdist is not specified, the interval is reported in metres under
latlong, or in the units of the Euclidean coordinates otherwise.
Workflow Note¶
Use spur for the full OLS pipeline in one command. Use spurtest,
spurtransform, spurhalflife, and direct scpc calls when you want only
selected steps or when you need IV / fixed-effect estimation.