Compute VCOVs robust to spatial correlation, a la Conley (1999).

vcov_conley(
x,
lat = NULL,
lon = NULL,
cutoff = NULL,
pixel = 0,
distance = "triangular",
ssc = NULL
)

conley(cutoff = NULL, pixel = NULL, distance = NULL)

## Arguments

x

A fixest object.

lat

A character scalar or a one sided formula giving the name of the variable representing the latitude. The latitude must lie in [-90, 90], [0, 180] or [-180, 0].

lon

A character scalar or a one sided formula giving the name of the variable representing the longitude. The longitude must be in [-180, 180], [0, 360] or [-360, 0].

cutoff

The distance cutoff, in km. You can express the cutoff in miles by writing the number in character form and adding "mi" as a suffix: cutoff = "100mi" would be 100 miles. If missing, a rule of thumb is used to deduce the cutoff.

pixel

A positive numeric scalar, default is 0. If a positive number, the coordinates of each observation are pooled into pixel x pixel km squares. This lowers the precision but can (depending on the cases) greatly improve computational speed at a low precision cost. Note that if the cutoff was expressed in miles, then pixel will also be in miles.

distance

How to compute the distance between points. It can be equal to "triangular" (default) or "spherical". The latter case corresponds to the great circle distance and is more precise than triangular but is a bit more intensive computationally.

ssc

An object returned by the function ssc. It specifies how to perform the small sample correction.

## Value

If the first argument is a fixest object, then a VCOV is returned (i.e. a symmetric matrix). If the first argument is not a fixest object, then a) implicitly the arguments are shifted to the left (i.e. vcov_conley("lat", "long") is equivalent to vcov_conley(lat = "lat", lon = "long")) and b) a VCOV-request is returned and NOT a VCOV. That VCOV-request can then be used in the argument vcov of various fixest functions (e.g. vcov.fixest or even in the estimation calls).

## Details

This function computes VCOVs that are robust to spatial correlations by assuming a correlation between the units that are at a geographic distance lower than a given cutoff.

The kernel is uniform.

If the cutoff is not provided, an estimation of it is given. This cutoff ensures that a minimum of units lie within it and is robust to sub-sampling. This automatic cutoff is only here for convenience, the most appropriate cutoff shall depend on the application and shall be provided by the user.

The function conley does not compute VCOVs directly but is meant to be used in the argument vcov of fixest functions (e.g. in vcov.fixest or even in the estimation calls).

## Examples


data(quakes)

# We use conley() in the vcov argument of the estimation
feols(depth ~ mag, quakes, conley(100))
#> OLS estimation, Dep. Var.: depth
#> Observations: 1,000
#> Standard-errors: Conley (100km)
#>             Estimate Std. Error  t value   Pr(>|t|)
#> (Intercept)  881.625   108.9005  8.09569 1.6480e-15 ***
#> mag         -123.421    19.2323 -6.41737 2.1389e-10 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> RMSE: 209.6   Adj. R2: 0.052245

# Post estimation
est = feols(depth ~ mag, quakes)
vcov_conley(est, cutoff = 100)
#>             (Intercept)        mag
#> (Intercept)   11859.324 -1955.8155
#> mag           -1955.816   369.8824