Created
December 3, 2017 19:24
-
-
Save Nosferican/e183f0d270fce9ee7f34a12670a8d89d to your computer and use it in GitHub Desktop.
Multiway clustering in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!any(grepl(pattern = 'pacman', x = installed.packages()[,1]))) { | |
install.packages('pacman') | |
} | |
pacman::p_load(dplyr, plm, multiwayvcov) | |
df = data(Grunfeld, package = 'plm') | |
model = lm(formula = value ~ inv + capital, | |
data = Grunfeld) | |
vcov_both = multiwayvcov::cluster.vcov(model, select(Grunfeld, firm, year)) | |
diag(vcov_both)[2:3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment