Skip to content

Commit

Permalink
Update benchmarks.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
gragusa committed Oct 21, 2019
1 parent 52b8110 commit 3c8794e
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions benchmark/benchmarks.jl
Expand Up @@ -6,17 +6,37 @@ using BenchmarkTools

Random.seed!(1)

df = DataFrame(y = randn(1000))
df = DataFrame(y = randn(300*50))
for j in Symbol.("x".*string.(collect(1:5)))
df[j] = randn(1000)
df[j] = randn(300*50)
end
df[:cluster] = repeat(1:50, inner = [300])


frm = @formula(y ~ x1 + x2 + x3 + x4 + x5)
lm1 = glm(frm, df, Normal(), IdentityLink())
k_fix = TruncatedKernel(2)
k_opt = TruncatedKernel()
k_opt_andrews = TruncatedKernel()
k_opt_newey = TruncatedKernel(NeweyWest)

suite = BenchmarkGroup()
suite["HAC"] = BenchmarkGroup(["Optimal Uncached", "Fixed Uncached"])
suite["HAC"]["Optimal Uncached"] = @benchmarkable vcov(lm1, $k_opt)
suite["HAC"]["Fixed Uncached"] = @benchmarkable vcov(lm1, $k_fix)
suite["HAC"]["Truncated Optimal Andrews"] = @benchmarkable vcov(lm1, $k_opt_andrews)
suite["HAC"]["Truncated Optimal Andrews"] = @benchmarkable vcov(lm1, $k_opt_newey)
suite["HAC"]["Truncated Fixed "] = @benchmarkable vcov(lm1, $k_fix)

k_fix = ParzenKernel(2)
k_opt_andrews = ParzenKernel()
k_opt_newey = ParzenKernel(NeweyWest)

suite["HAC"]["Parzen Optimal Andrews"] = @benchmarkable vcov(lm1, $k_opt_andrews)
suite["HAC"]["Parzen Optimal Newey"] = @benchmarkable vcov(lm1, $k_opt_newey)
suite["HAC"]["Parzen Fixed "] = @benchmarkable vcov(lm1, $k_fix)

k = CRHC0(df[!,:cluster])
suite["HAC"]["Cluster HC0"] = @benchmarkable vcov(lm1, $k)
k = CRHC2(df[!,:cluster])
suite["HAC"]["Cluster HC2"] = @benchmarkable vcov(lm1, $k)
k = CRHC3(df[!,:cluster])
suite["HAC"]["Cluster HC2"] = @benchmarkable vcov(lm1, $k)

0 comments on commit 3c8794e

Please sign in to comment.