Skip to content

Instantly share code, notes, and snippets.

View Nosferican's full-sized avatar

José Bayoán Santiago Calderón Nosferican

View GitHub Profile
@Nosferican
Nosferican / multiway.R
Created December 3, 2017 19:24
Multiway clustering in R
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]
@Nosferican
Nosferican / gist:41b8ed14a823038acc44881be70b582c
Last active November 17, 2017 22:32
Skeleton for Benchmarking QRupdate
## This skeleton provides a framework to develop a benchmark for various routines using QRupdate
## The following example tests the efficiency of obtaining the subset of linearly independent columns from
## various matrices. An application of these procedures is for instrumental least squares estimators (e.g., 2SLS).
using QRupdate
srand(0)
m = Int(1e6)
X = rand(m, 3)
@Nosferican
Nosferican / Model Matrix Error.jl
Created November 16, 2017 01:47
Identifying error in StatsModels ModelMatrix
## Using modified forks to test code (mostly fixed depreciations, but can inspect the changes at the link)
using DataFrames # From https://github.com/JuliaEconometrics/DataFrames.jl
using Feather
using StatsModels # From https://github.com/JuliaEconometrics/StatsModels.jl
df = Feather.read("NLS.feather") # Feather file from Stata's webuse nlswork
df = df[[:idcode, :year, :ln_wage, :age, :race, :union, :ttl_exp]]
df[:idcode] = string.(df[:idcode])
df[:year] = string.(df[:year])