[R-SIG-Finance] How to add lagged values to rugarch-model

alexios ghalanos alexios at 4dscape.com
Wed Nov 5 16:18:12 CET 2014


On 05/11/2014 14:59, Lasse Thorst wrote:
> Thanks!
>
> Quick follow-up.
>
> My knowledge about ARMA-GARCH models is not perfect, but if want a lagged
> time series in the model - to work with seasonality - how can I then add
> it, if not via the ext.reg?
>
> For example, in STATA I would do something like choosing my "x  AR(24)
> AR(48)" for adding the 24th and 48th lag.
> I would here like to add the 24th and 48th lag to the mean model in my
> ARMA-GARCH model.

Try:
spec<-ugarchspec(mean.model=list(armaOrder=c(48,0)))
x = as.list(rep(0,46))
names(x)<-c(paste("ar",1:23,sep=""),paste("ar",25:47,sep=""))
setfixed(spec)<-x


> Should I look at another package?

Why not.

Alexios

> 2014-11-05 15:28 GMT+01:00 Robert Harlow <rharlow86 at gmail.com>:
>
>> Lasse,
>> Your problem is that you have NAs in your external regressor matrix.
>> Since you lagged it twice, you have 2 NAs.  Try the code below.
>> Thanks for the reproducible example, it made it really easy.
>> Bob
>>
>>
>> require(rugarch)
>> require(quantmod)
>>
>> x = runif(n = 1000, min = -5, max = 100)
>> ext.reg_lagged = cbind(Lag(x, k = 1), Lag(x, k = 2))
>> ext.reg = cbind(x + runif(n = 1000, min = 5, max = 20), x - runif(n = 1000,
>> min = 5, max = 15))
>>
>> *x <- x[-c(1:2)]*
>> *ext.reg_lagged = ext.reg_lagged[-c(1:2), ]*
>>
>> fit.spec <- ugarchspec(variance.model = list(model = "sGARCH",
>>                                                   garchOrder = c(1, 1)),
>>                         mean.model         = list(armaOrder = c(3, 1),
>>                                                   include.mean = TRUE,
>>                                                   external.regressors =
>>                             ext.reg_lagged), # with ext.reg.lagged it does
>> not work.
>>                         distribution.model = "sstd")
>> fit      <- ugarchfit(data = x, spec = fit.spec, solver = "hybrid")
>>
>>
>> On Wed, Nov 5, 2014 at 9:16 AM, Lasse Thorst <thorstlasse at gmail.com>
>> wrote:
>>
>>> Hi - First question here, so please bear with me:
>>>
>>> I would like to added lagged values to a rugarch-model, but have been
>>> unable to find answers in the vignette.
>>>
>>> Basic test-code:
>>>
>>> require(rugarch)
>>> require(quantmod)
>>>
>>> x = runif(n = 1000, min = -5, max = 100)
>>> ext.reg_lagged = cbind(Lag(x, k = 1), Lag(x, k = 2))
>>> ext.reg = cbind(x + runif(n = 1000, min = 5, max = 20), x - runif(n =
>>> 1000,
>>> min = 5, max = 15))
>>>
>>> fit.spec <- ugarchspec(variance.model = list(model = "sGARCH",
>>>                                                   garchOrder = c(1, 1)),
>>>                         mean.model         = list(armaOrder = c(3, 1),
>>>                                                   include.mean = TRUE,
>>>                                                   external.regressors =
>>> ext.reg), # with ext.reg.lagged it does not work.
>>>                         distribution.model = "sstd")
>>>
>>> fit      <- ugarchfit(data = x, spec = fit.spec, solver = "hybrid")
>>>
>>> Now this works perfectly, but if I exchange the external.regressors =
>>> ext.reg_lagged
>>> it no longer works.
>>>
>>> How can you do this in rugarch? Or do I need to try another package?
>>>
>>> /Regards Lasse
>>>
>>>          [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-SIG-Finance at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>> -- Subscriber-posting only. If you want to post, subscribe first.
>>> -- Also note that this is not the r-help list where general R questions
>>> should go.
>>>
>>
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>
>



More information about the R-SIG-Finance mailing list