Reference¶
This page documents the public scpcR API.
Overview¶
| Function | Description |
|---|---|
scpc() |
Run spatial correlation-robust inference for a fitted model |
print() |
Print the main SCPC coefficient table |
summary() |
Print the coefficient table plus confidence intervals |
coef() |
Extract the coefficient estimates |
confint() |
Extract confidence intervals for selected coefficients |
Conventions¶
Supported Models¶
scpc() accepts fitted:
lmmodelsfixest::feols()models, including IV specifications
Coordinates¶
Provide exactly one coordinate specification:
lonandlatfor geographic coordinatescoords_euclideanfor planar coordinates
Do not pass both specifications in the same call.
Clustering and Method Selection¶
clusternames an optional clustering variable indata- coordinates must be constant within clusters
- when a model uses absorbed fixed effects and external clustering, the
conditional adjustment is not implemented; use
uncond = TRUE method = "auto"selects the exact branch for smaller problems and the approximation branch once the large-nthreshold is reached
Core Inference¶
scpc()¶
Run spatial correlation-robust inference.
Signature
scpc(
model,
data,
lon = NULL,
lat = NULL,
coords_euclidean = NULL,
cluster = NULL,
ncoef = NULL,
avc = 0.03,
method = "auto",
large_n_seed = 1,
uncond = FALSE,
cvs = FALSE
)
Parameters
model: fitted model object. Supported classes arelmandfixest::feols(), including IV models.data(data.frame): data used to fitmodel. It must contain the coordinate columns referenced bylon/latorcoords_euclidean.lon,lat(character | NULL): longitude and latitude column names for geographic distance calculations.coords_euclidean(character | NULL): Euclidean coordinate column names. Use instead oflonandlat.cluster(character | NULL): optional clustering variable indata.ncoef(integer | NULL): number of coefficients to report.NULLreports all coefficients.avc(numeric): upper bound on average pairwise correlation. Must lie in(0.001, 0.99). Default:0.03.method(character): spatial algorithm."auto": choose between exact and approximate branches"exact": always use the full distance matrix"approx": always use the large-napproximation branchlarge_n_seed(numeric): integer-valued seed used by the large-napproximation branch. Ignored whenmethod = "exact".uncond(logical): ifTRUE, skip the conditional adjustment and report unconditional critical values only.cvs(logical): ifTRUE, store per-coefficient critical values at the 32%, 10%, 5%, and 1% levels.
Returns
- object of class
"scpc" scpcstats: matrix with coefficient estimates, SCPC standard errors, t-statistics, p-values, and 95% interval boundsscpccvs: matrix of stored critical values, orNULLwhencvs = FALSEW: spatial projection matrixavcc0cvqmethodlarge_n_seedcall
Methods¶
print.scpc()¶
Print the main SCPC coefficient table.
Signature
print(x, ...)
Parameters
x: object of class"scpc"
Returns
- the input object, invisibly
The printed output shows the coefficient table with estimates, SCPC standard
errors, t-statistics, and p-values. If cvs = TRUE, stored critical values
are printed as well.
summary.scpc()¶
Print the fuller SCPC summary.
Signature
summary(object, ...)
Parameters
object: object of class"scpc"
Returns
- the input object, invisibly
The summary adds the 95% confidence interval table and reports avc alongside
the main coefficient output.
coef.scpc()¶
Extract the coefficient estimates.
Signature
coef(object, ...)
Parameters
object: object of class"scpc"
Returns
- named numeric vector of coefficient estimates
confint.scpc()¶
Extract confidence intervals for selected coefficients.
Signature
confint(object, parm = NULL, level = 0.95, ...)
Parameters
object: object of class"scpc"parm(character | numeric | NULL): coefficient names or indices to include.NULLuses all coefficients.level(numeric): confidence level to request.0.95is always available0.68,0.90, and0.99are also available whencvs = TRUE
Returns
- numeric matrix of lower and upper interval bounds
Return Object¶
"scpc"¶
Returned by scpc().
Fields
scpcstatsscpccvsWavcc0cvqmethodlarge_n_seedcall
Methods
print()summary()coef()confint()
The primary inferential output is stored in scpcstats. Its rows correspond to
coefficients, and its columns contain the estimate, standard error,
t-statistic, p-value, and 95% interval endpoints.