Skip to content

Instantly share code, notes, and snippets.

Avatar

José Bayoán Santiago Calderón, PhD Nosferican

View GitHub Profile
@Nosferican
Nosferican / multiway.R
Created Dec 3, 2017
Multiway clustering in R
View multiway.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 Nov 17, 2017
Skeleton for Benchmarking QRupdate
View gist:41b8ed14a823038acc44881be70b582c
## 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 Nov 16, 2017
Identifying error in StatsModels ModelMatrix
View Model Matrix Error.jl
## 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])