Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
s-broda committed Feb 5, 2020
1 parent 4fc75b9 commit 367b813
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ARCHModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using SpecialFunctions: beta, gamma, digamma #, lgamma

# work around https://github.com/JuliaMath/SpecialFunctions.jl/issues/186
# until https://github.com/JuliaDiff/ForwardDiff.jl/pull/419/ is merged
# remove test in runtests.jl as well when this gets fixed
using Base.Math: libm
using ForwardDiff: Dual, value, partials
@inline lgamma(x::Float64) = ccall((:lgamma, libm), Float64, (Float64,), x)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ using DataFrames

T = 10^4;

@testset "lgamma" begin
@test ARCHModels.lgamma(1.0f0) == 0.0f0
end

@testset "TGARCH" begin
@test ARCHModels.nparams(TGARCH{1, 2, 3}) == 7
@test ARCHModels.presample(TGARCH{1, 2, 3}) == 3
Expand Down Expand Up @@ -404,6 +408,7 @@ end
@test_throws AssertionError DCC{1, 1}([1. 0.; 0. 1.], [0., 0.], [GARCH{1, 1}([1., 0., 0.]), GARCH{1, 1}([1., 0., 0.])]; method=:bla)
@test coefnames(am1) == ["β₁", "α₁", "ω₁", "β₁₁", "α₁₁", "μ₁", "ω₂", "β₁₂", "α₁₂", "μ₂"]
@test ARCHModels.nparams(DCC{1, 1}) == 2
ARCHModels.nparams(DCC{1, 1, GARCH{1, 1}, Float64, 2}) == 8
@test ARCHModels.presample(DCC{1, 2, GARCH{3, 4}}) == 4
@test ARCHModels.presample(DCC{1, 2, GARCH{3, 4, Float64}, Float64, 2}) == 4
io = IOBuffer()
Expand Down Expand Up @@ -455,6 +460,7 @@ end

Random.seed!(1)
ccc = fit(CCC, DOW29[:, 1:4])
@test dof(ccc) == 16
@test ccc.spec.R[1, 2] 0.37095654552885643
@test stderror(ccc)[1] 0.06298215515406534
cccs = simulate(ccc, T)
Expand Down

0 comments on commit 367b813

Please sign in to comment.