New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Hansen's Standardized Skewed T Distribution #86
Conversation
The first commit is a minor style fix |
Create a standardized skewed t distribution with `v` degrees of freedom and `λ` shape parameter. `ν,λ`` can be passed | ||
as scalars or vectors. | ||
""" | ||
StdSkewT(ν,λ) = StdSkewT([ν λ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StdSkewT(ν,λ) = StdSkewT([ν, λ])
as scalars or vectors. | ||
""" | ||
StdSkewT(ν,λ) = StdSkewT([ν λ]) | ||
StdSkewT(ν::Integer,λ::Integer) = StdSkewT(float(ν),float(λ)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed. That conversion happens automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it doesn't
""" | ||
StdSkewT(ν,λ) = StdSkewT([ν λ]) | ||
StdSkewT(ν::Integer,λ::Integer) = StdSkewT(float(ν),float(λ)) | ||
StdSkewT(v::Vector{T},λ::Vector{T}) where {T} = StdSkewT{T}(v,λ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work because there is no such inner constructor. Also, it probably shouldn't work, so just remove it.
StdSkewT(v::Vector{T},λ::Vector{T}) where {T} = StdSkewT{T}(v,λ) | ||
StdSkewT(coefs::Vector{T}) where {T} = StdSkewT{T}(coefs) | ||
|
||
(rand(d::StdSkewT{T})::T) where {T} = (ν=d.coefs[1];λ=d.coefs[2]; quantile(d,rand(1))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rand(d::StdSkewT{T}) where {T} = (ν=d.coefs[1];λ=d.coefs[2]; quantile(d, rand()))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? I see ν and λ being assigned and then not used
function quantile(d::StdSkewT{T}, q::T) where T | ||
ν = d.coefs[1] | ||
λ = d.coefs[2] | ||
xa = a(d,d.coefs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xa = a(typeof(d), d.coefs)
ν = d.coefs[1] | ||
λ = d.coefs[2] | ||
xa = a(d,d.coefs) | ||
xb = b(d,d.coefs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xb = b(typeof(d), d.coefs)
hand optimized the logkernel function for StdSkewT instead of using the support {a,b,c} functions which were wasteful since calls to them were repeated. A speed improvement of 4x has been attained on `fit(GARCH{1,1},BG96)`
I incorporated the changes you requested, added tests (by basically imitating the tests for the other distributions), I added a mention of the distribution in the docs (I'm not familiar with the process so I may have made mistakes) and optimized the performance (see my last post on #87, and/or commit message for 49e7858) |
This is starting to look good. There's just a doctest that's still failing: https://travis-ci.org/github/s-broda/ARCHModels.jl/jobs/762500760 Do you know how to address this? You basically need to update the output in src/usage.md, lines 331-362. If not, I can merge it as is and fix it myself. Cheers |
No, I am not familiar with what's going on in the lines you mentioned. However I also spotted a different thing on those logs: after the error on line 990 it is complaining that the evaluated output differs from what is expected (there is a space missing in the function call) |
It would be better if you fixed it, I haven't used julia's documentation system before |
OK, I'll merge and fix it myself. Thanks for your contribution! |
Thank you for the advice along the way! |
No description provided.