s-broda / ARCHModels.jl

A Julia package for estimating ARMA-GARCH models.
https://juliaeconometrics.wordpress.com/
Other
90 stars 18 forks source link

Update univariatearchmodel.jl #67

Open azev77 opened 4 years ago

s-broda commented 4 years ago

Thanks!

You're going to have to update the tests in runtest.jl and the doctests in the documentationtoo to get CI to pass. Also, I'm not fond of littering the output with Float64, that's why I wrote the function modname which strips the last type parameter. My suggestion is to change the line

length(sem) > 0 && println(io, "Mean equation parameters:", "\n",
                                   CoefTable(hcat(ccm, sem, zzm, 2.0 * normccdf.(abs.(zzm))),
                                             ["Estimate", "Std.Error", "z value", "Pr(>|z|)"],
                                             coefnames(am.meanspec), 4
                                             )
                                  )

to

length(sem) > 0 && println(io, "Mean specification is ", modname(typeof(am.meanspec)), ", with parameters:", "\n",
                                   CoefTable(hcat(ccm, sem, zzm, 2.0 * normccdf.(abs.(zzm))),
                                             ["Estimate", "Std.Error", "z value", "Pr(>|z|)"],
                                             coefnames(am.meanspec), 4
                                             )
                                  )

Result:

julia> fit(GARCH{1, 1}, BG96, meanspec=ARMA{1, 1}, dist=StdT)

TGARCH{0,1,1} model with Student's t errors, T=1974.

Mean specification is ARMA{1,1}, with parameters:
───────────────────────────────────────────────
       Estimate  Std.Error    z value  Pr(>|z|)
───────────────────────────────────────────────
c    0.00364834  0.0113688   0.320909    0.7483
φ₁  -0.614422    0.209571   -2.9318      0.0034
θ₁   0.65015     0.199659    3.25631     0.0011
───────────────────────────────────────────────

Volatility parameters:
──────────────────────────────────────────────
      Estimate   Std.Error   z value  Pr(>|z|)
──────────────────────────────────────────────
ω   0.00241045  0.00163656   1.47288    0.1408
β₁  0.882039    0.0365434   24.1368     <1e-99
α₁  0.127324    0.0402363    3.1644     0.0016
──────────────────────────────────────────────

Distribution parameters:
─────────────────────────────────────────
   Estimate  Std.Error  z value  Pr(>|z|)
─────────────────────────────────────────
ν   4.11992   0.402128  10.2453    <1e-23
─────────────────────────────────────────

That shouldn't require a change to runtests.jl, but it does require changing the doctests. I'd also recommend testing changes locally before pushing, via

import Pkg; Pkg.test("ARCHModels")

and by running from a terminal in the ARCHModels main folder

julia --project=docs/ docs/make.jl

You can check the generated HTML by running

python -m http.server --directory=docs/build
azev77 commented 4 years ago

OK, I'm gonna think more about this and let this sit for a while. It feels a bit inconsistent to have:

Mean specification is ARMA{1,1}, with parameters:
Volatility parameters:
Distribution parameters:

Perhaps instead:

Mean specification is ARMA{1,1}, with parameters:
Volatility specification is TGARCH{0,1,1}, with parameters:
Error distribution is Student's t, with parameters: