# NOT RUN {
# Load trade data
data(trade)
# We estimate the effect of distance on trade (with 3 fixed-effects)
est_pois = fepois(Euros ~ log(dist_km)|Origin+Destination+Product, trade)
# Comparing different types of standard errors
sum_standard = summary(est_pois, se = "standard")
sum_hetero = summary(est_pois, se = "hetero")
sum_oneway = summary(est_pois, se = "cluster")
sum_twoway = summary(est_pois, se = "twoway")
sum_threeway = summary(est_pois, se = "threeway")
etable(sum_standard, sum_hetero, sum_oneway, sum_twoway, sum_threeway)
# Alternative ways to cluster the SE:
# two-way clustering: Destination and Product
# (Note that arg. se = "twoway" is implicitly deduced from the argument cluster)
summary(est_pois, cluster = c("Destination", "Product"))
summary(est_pois, cluster = trade[, c("Destination", "Product")])
summary(est_pois, cluster = list(trade$Destination, trade$Product))
summary(est_pois, cluster = ~Destination+Product)
# Since Destination and Product are used as fixed-effects, you can also use:
summary(est_pois, cluster = 2:3)
# You can interact the clustering variables "live" using the var1 ^ var2 syntax.
summary(est_pois, cluster = "Destination^Product")
summary(est_pois, cluster = ~Destination^Product)
# Equivalent to
summary(est_pois, cluster = paste(trade$Destination, trade$Product))
#
# Compatibility with sandwich
#
# You can use the VOCVs from sandwich by using the argument .vcov:
library(sandwich)
summary(est_pois, .vcov = vcovCL, cluster = trade[, c("Destination", "Product")])
# }
Run the code above in your browser using DataLab