Closed luboshanus closed 2 years ago
Yes:
julia> fit(ARMA{1, 1}, BG96)
TGARCH{0, 0, 0} model with Gaussian errors, T=1974.
Mean equation parameters:
─────────────────────────────────────────────
Estimate Std.Error z value Pr(>|z|)
─────────────────────────────────────────────
c -0.0266446 0.0174716 -1.52502 0.1273
φ₁ -0.621838 0.160738 -3.86864 0.0001
θ₁ 0.643588 0.1543 4.17103 <1e-04
─────────────────────────────────────────────
Volatility parameters:
─────────────────────────────────────────
Estimate Std.Error z value Pr(>|z|)
─────────────────────────────────────────
ω 0.220848 0.0118061 18.7063 <1e-77
─────────────────────────────────────────
Automatic lag order selection is also supported:
julia> selectmodel(ARMA, BG96; minlags=0, maxlags=3)
TGARCH{0, 0, 0} model with Gaussian errors, T=1974.
Mean equation parameters:
────────────────────────────────────────────
Estimate Std.Error z value Pr(>|z|)
────────────────────────────────────────────
c -0.0164268 0.0105813 -1.55243 0.1206
────────────────────────────────────────────
Volatility parameters:
─────────────────────────────────────────
Estimate Std.Error z value Pr(>|z|)
─────────────────────────────────────────
ω 0.221018 0.011801 18.7288 <1e-77
─────────────────────────────────────────
Prediction is possible as well:
julia> am = fit(ARMA{1, 1}, BG96);
julia> predict(am, :return)
-0.0027370233204087047
Though I just noticed that predicting more than 1 step ahead appears to be broken.
Great! Thanks a lot.
Is there also a way how to change prediction horizon
? It throws me an error when changing putting something different than 1
.
I've fixed the error, see PR #105. I'll merge it and release Version 2.2.3 as soon as CI is green. Would be great if you could test it more thoroughly once you install the new version, e.g. by comparing the forecasts to some other software like Eviews.
Hi @s-broda,
Automatic lag order selection is also supported:
After automatically finding lags (let's say the values of $p$ and $q$ in $ARMA(p, q)$ ), how can I get the value of corresponding coefficients?
I tried:
julia> t = rand(50);
julia> m = selectmodel(ARMA, t; minlags=0, maxlags=3);
julia> m.meanspec.coefs
7-element Vector{Float64}:
0.9504307287368924
0.02619830162148422
-0.7313357753386505
-0.5611031531964645
-0.08701479135403353
0.6430621561894513
0.999999999999999
Are the first three values the AR's corresponding coefs and the next three the MA's coefs?
Another question is, how can I get the value of optimal lags? For example:
julia> m.meanspec
ARMA{3, 3, Float64}([0.9504307287368924, 0.02619830162148422, -0.7313357753386505, -0.5611031531964645, -0.08701479135403353, 0.6430621561894513, 0.9999999999999999])
How can I get the (3, 3)
values?
I guess I got this as well:
julia> typeof(m.meanspec).parameters[1:2]
svec(3, 3)
Hi
Yes, m.meanspec.coefs
is one way to do it. The first element is the intercept, the next 3 are the AR coefficients, and the last 3 the MA coefficients. You can verify that by just printing the model (leaving off the intercept after the selectmodel
call).
Another way is to use the accessor method coef(m)
, but this will return the volatility parameters as well (before those of the mean equation). In your example, that would just be $\omega$, the intercept in the volatility equation. If the distribution has parameters too, those would be returned at the end of the vector.
As to how to get the model order, yes, that would be the way to do it if you need to access it programmatically (I suppose I could add a convenience method). For interactive work, I would just print the model, or add show_trace=true
to the selectmodel
call.
Cheers Simon
Dear @s-broda Thank you so much for your response. If you had not told me that, I would have been continuing to build my research on wrong values! I thought the first 6 elements were the coefficients and I was omitting the last element.
I suppose I could add a convenience method
It would be great! I need the values in my signal processing model, so printing them wouldn't work for me. However, I got the values, such that I mentioned.
If the distribution has parameters too, those would be returned at the end of the vector.
Which vector? The one that coef(m)
returns?
Which vector? The one that
coef(m)
returns?
Yes, though I just noticed that I misremembered: the distribution parameters are returned before the mean parameters. You may find coefnames
useful:
julia> m = selectmodel(ARMA, BG96; dist=StdT);
julia> params = (; zip(Symbol.(coefnames(m)), coef(m))...)
(ω = 0.2782287395695833, ν = 2.98700318619116, c = 0.005811678603962783, φ₁ = -0.6307493938587386, θ₁ = 0.6628511611105171)
julia> params.φ₁
-0.6307493938587386
I just noticed that I misremembered: the distribution parameters are returned before the mean parameters.
Thanks for the clarification. I utilized m.meanspec.coefs
since I did not require distribution parameters. Regardless, I'd like to confirm whether the implementation involves any randomness that might yield varying results each time I fit the model.
The implementation is deterministic, so the results should always be the same.
Is there a way how to fit and predict ARMA using this package?
It might useful to Julia users, sice there are not many ways/packages to do it.
Thanks.