Skip to content

Commit

Permalink
add a test to LD shrinkage
Browse files Browse the repository at this point in the history
  • Loading branch information
biona001 committed Nov 29, 2023
1 parent dbe3df0 commit 72ccd51
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/runtest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,22 @@
@test c == [[2], [1, 3], [5], [1, 3], Int[]]
@test typeof(c) <: Vector{Vector{Int64}}
end

@testset "LD shrinkage" begin
function mvn_logl_under_null_naive::AbstractMatrix, z::AbstractVector)
return -0.5logdet(Symmetric(Σ)) - dot(z, inv(Symmetric(Σ)), z)
end

p = 1000
z = randn(p)
x = randn(p, p)
storage=zeros(length(z))
Sigma = Symmetric(x'*x)
L = cholesky(Symmetric(Sigma));
a = mvn_logl_under_null_naive(Sigma, z)
b = mvn_logl_under_null(L, z)
@test a b

γ = find_optimal_shrinkage(Sigma, z)
@test 0 γ 1
end

0 comments on commit 72ccd51

Please sign in to comment.