| vcov_conley | R Documentation |
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,
vcov_fix = TRUE
)
conley(cutoff = NULL, pixel = NULL, distance = NULL)
x |
A |
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, see details. |
pixel |
A positive numeric scalar, default is 0. If a positive number, the coordinates of
each observation are pooled into |
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 of class By default the VCOV is multiplied by (N - 1) / (N - K) with N the number of
observations and K the number of parameters.
To remove this adjustment, use |
vcov_fix |
Logical scalar, default is |
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).
If the cutoff is missing, a rule of thumb is used to deduce a sensible cutoff. The algorithm is as follows:
all observations are sorted according to their latitude and their longitude (latitude major)
for each observation we take the minimum distance across the three units with the closest latitude
we do the same when sorting this time by longitude first and latitude second (longitude major)
the cutoff is the sum of the median of these two distances (lat. major and lon. major)
This cutoff is provided only for convenience but should be an appropriate first guess. With this cutoff, about 50% of units should have at least around 8 neighbors.
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).
By default the VCOV is multiplied by (N - 1) / (N - K) with N the number of
observations and K the number of parameters.
To remove this adjustment, use ssc=ssc(K.adj = FALSE).
If the estimation contains fixed effects, you can modify how the number of parameters is computed
with the arguments K.fixef and K.exact (see ssc for details).
Conley TG (1999). "GMM Estimation with Cross Sectional Dependence", Journal of Econometrics, 92, 1-45.
data(quakes)
# We use conley() in the vcov argument of the estimation
feols(depth ~ mag, quakes, conley(100))
# Post estimation
est = feols(depth ~ mag, quakes)
vcov_conley(est, cutoff = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.