

This is my first post to this mailing list so I apologize if I am out of
order here.
I tried to ask this question on an online forum but got shot down
< https://stats.stackexchange.com/questions/457924/isthisabuginrugarchoristheforecastsupposedtoconcealthefirstforec?noredirect=1#comment849108_457924>
library(magrittr)
library(rugarch)
data = c(0.00448915878069781,0.00593011429139564,0.00521660375977179,0.00915792713276595,0.0281576105073823,0.00312671172731763,0.00354620561645788,0.0116968104863564,0.00885293595922043,0.0107479700328324,0.00286887922892909,0.0157860645324253,0.00034496291769634,0.00834156289619709,0.0118426954076351,0.0245429072803506,0.00920654078852251,0.0194853526917377,0.0101437726804425,0.0121099494070556,0.0035482064346366,0.00229786350435077,0.00733982114587459,0.00459640558705143,0.012915903683943,0.019073989784277,0.0126645393062962,0.00721493361382838,0.00999175394461038,0.0133412046238938,0.00648737743848443,0.00562686238554141,0.00330281416051201,0.00799100742663728,0.000663186933227922,0.0148432054223313,0.00196669935473182,0.000615357170258429,0.00113636710367157,0.0194719951587255,0.0169620174351603,0.0131164201273478,0.0135647068283389,0.00438317321680465,0.0147236772598623,0.00448073182498596,0.00388037967044466,0.0258503616763401,0.00971753055430585,0.0079
0819347457519,0.00755558584805335,0.0171629980145799,0.0107626388061985,0.0105764253253602,0.00728398157712776,0.00098385324839817,0.00401832316660708,0.00123931628811594,0.0117077717740899,0.017917887402996,0.010911835646347,0.00827245645002914,0.00906077086137638,0.0205094556293795,0.00737675894931045,0.00690210266337801,0.020337194824323,0.00700174492576033,0.000228651273513847,0.0143788420968017,0.013170014653836,0.0041840803265823,0.00998018021662783,0.00773937960715987,0.0150502886036981,0.00281352468848173,0.0106468266964306,0.00603505797098974,0.00448080249830074,0.00828145475545461,0.000440945562519113,0.0100964576962305,0.00160882489466677,0.000137141351361142,0.00954377280816113,0.00208528678239533,0.0209006426760515,0.00156626715014618,0.00691347744367798,0.00860724032017463,0.0110129635734199,0.00446238531960588,0.0112374698383101,0.0276009587172153,0.000631167643944636,0.000455412294070562,0.000428413112601861,0.00468012712974619,0.0132383598
723957,0.0272178690714789,0.0346151554938807,0.00428132065168324,0.0135193549155817,0.0161119996079523)
m_g_spec = ugarchspec(
mean.model = list(
armaOrder = c(1,2)
, include.mean = T
, archm = F
, arfima = F
)
, distribution.model = "norm"
, variance.model = list(model = "sGARCH", garchOrder = c(1,1)))
m_g_fit = ugarchfit(m_g_spec, data, solver = "hybrid")
f = ugarchforecast(m_g_fit)
plot(f, which = 1)
f@model$modeldata$data %>% tail(1) %>% {abline(h = .)}
f@forecast$seriesFor[1] %>% {abline(h = ., col = "red")}
The above code generates a chart.
The black horizontal line shows the last value of the input data. The red
line shows the first value of the forecast. Where did the last value in the
blue series come from? The blue series is supposed to show actual data, but
this last value is not in the input data. It seems to be the first forecast
value but it is not given in the forecast object. Any idea what is going
on?
[[alternative HTML version deleted]]
_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rsigfinance Subscriberposting only. If you want to post, subscribe first.
 Also note that this is not the rhelp list where general R questions should go.


There is no discrepancy here. It is just the way the plot is generated
to connect the last value in the data with the first value in the forecast.
Instead of plotting, you could just look at the data:
> tail(f@model$modeldata$data,1)
[1] 0.016112
> tail(f@model$modeldata$data,1)
[1] 0.016112
> head(f@forecast$seriesFor)
19700414 16:00:00
T+1 0.001220014
T+2 0.002245227
T+3 0.001834683
T+4 0.001518531
T+5 0.001275068
T+6 0.001087582
Alexios
On 4/1/20 10:39 AM, travisgleith . wrote:
> This is my first post to this mailing list so I apologize if I am out of
> order here.
>
> I tried to ask this question on an online forum but got shot down
> < https://stats.stackexchange.com/questions/457924/isthisabuginrugarchoristheforecastsupposedtoconcealthefirstforec?noredirect=1#comment849108_457924>
>
> library(magrittr)
> library(rugarch)
> data = c(0.00448915878069781,0.00593011429139564,0.00521660375977179,0.00915792713276595,0.0281576105073823,0.00312671172731763,0.00354620561645788,0.0116968104863564,0.00885293595922043,0.0107479700328324,0.00286887922892909,0.0157860645324253,0.00034496291769634,0.00834156289619709,0.0118426954076351,0.0245429072803506,0.00920654078852251,0.0194853526917377,0.0101437726804425,0.0121099494070556,0.0035482064346366,0.00229786350435077,0.00733982114587459,0.00459640558705143,0.012915903683943,0.019073989784277,0.0126645393062962,0.00721493361382838,0.00999175394461038,0.0133412046238938,0.00648737743848443,0.00562686238554141,0.00330281416051201,0.00799100742663728,0.000663186933227922,0.0148432054223313,0.00196669935473182,0.000615357170258429,0.00113636710367157,0.0194719951587255,0.0169620174351603,0.0131164201273478,0.0135647068283389,0.00438317321680465,0.0147236772598623,0.00448073182498596,0.00388037967044466,0.0258503616763401,0.00971753055430585,0.00
79
> 0819347457519,0.00755558584805335,0.0171629980145799,0.0107626388061985,0.0105764253253602,0.00728398157712776,0.00098385324839817,0.00401832316660708,0.00123931628811594,0.0117077717740899,0.017917887402996,0.010911835646347,0.00827245645002914,0.00906077086137638,0.0205094556293795,0.00737675894931045,0.00690210266337801,0.020337194824323,0.00700174492576033,0.000228651273513847,0.0143788420968017,0.013170014653836,0.0041840803265823,0.00998018021662783,0.00773937960715987,0.0150502886036981,0.00281352468848173,0.0106468266964306,0.00603505797098974,0.00448080249830074,0.00828145475545461,0.000440945562519113,0.0100964576962305,0.00160882489466677,0.000137141351361142,0.00954377280816113,0.00208528678239533,0.0209006426760515,0.00156626715014618,0.00691347744367798,0.00860724032017463,0.0110129635734199,0.00446238531960588,0.0112374698383101,0.0276009587172153,0.000631167643944636,0.000455412294070562,0.000428413112601861,0.00468012712974619,0.0132383
598
> 723957,0.0272178690714789,0.0346151554938807,0.00428132065168324,0.0135193549155817,0.0161119996079523)
>
> m_g_spec = ugarchspec(
> mean.model = list(
> armaOrder = c(1,2)
> , include.mean = T
> , archm = F
> , arfima = F
> )
> , distribution.model = "norm"
> , variance.model = list(model = "sGARCH", garchOrder = c(1,1)))
>
> m_g_fit = ugarchfit(m_g_spec, data, solver = "hybrid")
> f = ugarchforecast(m_g_fit)
> plot(f, which = 1)
>
> f@model$modeldata$data %>% tail(1) %>% {abline(h = .)}
> f@forecast$seriesFor[1] %>% {abline(h = ., col = "red")}
>
> The above code generates a chart.
> The black horizontal line shows the last value of the input data. The red
> line shows the first value of the forecast. Where did the last value in the
> blue series come from? The blue series is supposed to show actual data, but
> this last value is not in the input data. It seems to be the first forecast
> value but it is not given in the forecast object. Any idea what is going
> on?
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rsigfinance>  Subscriberposting only. If you want to post, subscribe first.
>  Also note that this is not the rhelp list where general R questions should go.
>
_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rsigfinance Subscriberposting only. If you want to post, subscribe first.
 Also note that this is not the rhelp list where general R questions should go.

