Skip to content

Commit

Permalink
Implement VARHAC
Browse files Browse the repository at this point in the history
  • Loading branch information
gragusa committed Nov 9, 2024
1 parent 142a20b commit a237b32
Show file tree
Hide file tree
Showing 8 changed files with 430 additions and 354 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GroupedArrays = "6407cd72-fade-4a84-8a1e-56e431fc1533"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

NaNStatistics = "b946abbf-3ea7-4610-9019-9858bfdeaf2d"
[weakdeps]
GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand All @@ -23,6 +23,7 @@ Combinatorics = "1.0"
GLM = "1.9"
GroupedArrays = "0.3"
julia = "1.9"
NaNStatistics = "0.6"
SparseArrays = "1.0"
Statistics = "1.0"
StatsBase = "0.34"
Expand Down
12 changes: 12 additions & 0 deletions src/CR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ function clusterize(X::Matrix, g::GroupedArray)
return Symmetric(X2' * X2)
end

function clusterize_mean(X::Matrix, g::GroupedArray)
X2 = zeros(eltype(X), g.ngroups, size(X, 2))
idx = 0
for j axes(X, 2)
idx += 1
@inbounds @simd for i axes(X, 1)
X2[g.groups[i], idx] += X[i, j]
end
end
return X2
end

function avar(k::T, X::Union{Matrix{F},Vector{F}};
kwargs...) where {T<:Union{CR0,CR1,CR2,CR3},F<:AbstractFloat}
f = k.g
Expand Down
4 changes: 3 additions & 1 deletion src/CovarianceMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ using GroupedArrays
using LinearAlgebra
using Statistics
using StatsBase
using NaNStatistics
using Base.Threads

include("types.jl")
include("aVar.jl")
include("HAC.jl")
include("CR.jl")
include("HR.jl")
Expand All @@ -26,6 +26,8 @@ include("demeaner.jl")
include("EWC.jl")
include("api.jl")
include("smoothing.jl")
include("VARHAC.jl")
include("aVar.jl")
#include("VARHAC.jl")
export Andrews,
NeweyWest,
Expand Down
Loading

0 comments on commit a237b32

Please sign in to comment.