From 599a1dfbbaf342e1efc8ccf90ee2bd7970531490 Mon Sep 17 00:00:00 2001 From: Giuseppe Ragusa Date: Tue, 15 Oct 2024 20:11:24 +0000 Subject: [PATCH] Delete --- src/CR.jl | 18 +++------------- test_sw_mc1.jl | 56 -------------------------------------------------- 2 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 test_sw_mc1.jl diff --git a/src/CR.jl b/src/CR.jl index 9751204..2382c98 100644 --- a/src/CR.jl +++ b/src/CR.jl @@ -10,18 +10,6 @@ function clusterize(X::Matrix, g::GroupedArray) return Symmetric(X2' * X2) end -# function mean_by_cluster(X::Matrix, g::GroupedArray) -# X2 = zeros(eltype(X), g.ngroups, size(X, 2)) -# idx = 0 -# @inbounds for j in axes(X, 2) -# idx += 1 -# @simd for i in axes(X, 1) -# X2[g.groups[i], idx] += X[i, j] -# end -# end -# return Symmetric(X2' * 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 @@ -45,7 +33,7 @@ end nclusters(k::CR) = (map(x -> x.ngroups, k.g)) rescale!(k::T, S::Matrix) where {T<:CR0} = nothing -function rescale!(k::T, S::Matrix) where {T<:CR1} +function rescale!(k::T, S::AbstractMatrix) where {T<:CR1} # scale total vcov estimate by ((N-1)/(N-K)) * (G/(G-1)) G = minimum(nclusters(k)) N = length(k.g[1]) @@ -53,5 +41,5 @@ function rescale!(k::T, S::Matrix) where {T<:CR1} @. S *= ((N - 1) / (N - K)) * (G / (G - 1)) end -rescale!(k::T, S::Matrix) where {T<:CR2} = nothing -rescale!(k::T, S::Matrix) where {T<:CR3} = nothing +rescale!(k::T, S::AbstractMatrix) where {T<:CR2} = nothing +rescale!(k::T, S::AbstractMatrix) where {T<:CR3} = nothing diff --git a/test_sw_mc1.jl b/test_sw_mc1.jl deleted file mode 100644 index 42b5b9c..0000000 --- a/test_sw_mc1.jl +++ /dev/null @@ -1,56 +0,0 @@ -using CovarianceMatrices -using LinearAlgebra -using Random -using StatsFuns -## Monte Carlo for the regression model with a single -## stochastic regressor, in which ut and xt are independent Gaussian -## AR(1)’s with AR coefficients ρu = ρx = √0.7. - -function simulate(T, beta_0, beta_1) - # Generate the data - rho_u = sqrt(0.7) - rho_x = sqrt(0.7) - sigma_u = 1 - sigma_x = 1 - u = zeros(2*T) - x = zeros(2*T) - for t = 2:2*T - u[t] = rho_u * u[t-1] + sigma_u * randn() - x[t] = rho_x * x[t-1] + sigma_x * randn() - end - y = beta_0 .+ beta_1 .* x + u - return y[T+1:end], [ones(T,1) x[T+1:end]] -end - - - -T = 600 -ν = floor(Int64, 0.4*T^(2/3)) -reject = zeros(10000) - -for j in 1:10000 - - y, x = simulate(T, 0, 0) - β̂ = x\y - û = y - x*β̂ - z = x.*û - Ω̂ = CovarianceMatrices.avar(CovarianceMatrices.EWC(ν), z) - Z = x'x - Ω̂ᶜʰᵒˡ = cholesky(Ω̂).L - V̂ᶜʰᵒˡ = sqrt(T).*(Z\Ω̂ᶜʰᵒˡ) - V̂ = V̂ᶜʰᵒˡ*V̂ᶜʰᵒˡ' - se = sqrt.(diag(V̂)) - - ## sqrt.(diag(T*inv(Z)*Ω̂*inv(Z))) - - - ## V̂ = cholesky(A)\cholesky(Ω̂).L - ## V̂*V̂' - ## inv(inv(A)*Ω̂*inv(A))/100^2 - - t = β̂[2] ./ se[2] - - reject[j] = abs(t) >= StatsFuns.tdistinvcdf(ν, .975) -end - -mean(reject)