External Regressors in GARCH Equation when using Twinkle

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

External Regressors in GARCH Equation when using Twinkle

Neil Patrick Lawton
Hello all,

I am having trouble with the inclusion of external regressors in the GARCH
equation, when using the twinkle package kindly provided by Alexios
Ghalanos.
I believe I am including the data correctly to starspec. An xts object,
which is pre-lagged and has the same index as the data included within
starfit optimization.

Below, I have included an example of my code, with some generated data.

library(xts)
library(twinkle)

xts1 <- xts(x=rnorm(100), order.by=Sys.Date()-1:100)

xts2 <- xts(x=rnorm(100), order.by=index(xts1))



spec = starspec(mean.model = list(states = 2,

                                   include.intercept = c(1,1),

                                   arOrder = c(1,1),

                                   maOrder = c(2, 2),

                                   matype="state",

                                   statevar = 'y',

                                   ylags = 3,

                                  statear = TRUE),

                                  variance.model=list(dynamic=TRUE,

                                   model="sGARCH",submodel = NULL,

                                   garchOrder=c(1,1),

                                  vreg=xts1,

                                  variance.targeting = FALSE),

                                  distribution.model = "norm")


ctrl=list(maxit=1000, alpha=0.2, beta=0.1, gamma=0.7, reltol=1e-12,

           trace=0,method="BFGS",n.restarts=2,rseed=1)


mod = starfit(spec, data = xts2,

              solver.control = ctrl,

               solver = "msoptim")



I get the following error when trying to run, which only occurs when the
'vreg' argument is included in the variance model:


Error in matrix(vexdata, ncol = modelinc[39]) :

  object 'vexdata' not found



I get errors with other solvers also, whether I am including the
solver.control list or not.

In the rugarch package, the external regressors should be included as a
matrix, not an xts object. However, when I include data as a matrix here, I
get: starspec-->error: vreg must be an xts object.


Is there a solution or work around to this problem?


Kind regards,

Neil

--
__

Séanadh Ríomhphoist/_

Email Disclaimer__
**

Tá an ríomhphost seo agus
aon chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus
sin amháin é. Is féidir tuilleadh a léamh anseo.
<https://www4.dcu.ie/iss/seanadh-riomhphoist.shtml
<https://www4.dcu.ie/iss/seanadh-riomhphoist.shtml>*
_

This e-mail and any
files transmitted with it are confidential and are intended solely for use
by the addressee. Read more here.
<https://www4.dcu.ie/iss/email-disclaimer.shtml> _
*_

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: External Regressors in GARCH Equation when using Twinkle

alexios
Hi,

That's my bad for not testing this. Fixed and on bitbucket now.

Thanks for the bug report.

Alexios

On 9/11/19 4:54 PM, Neil Patrick Lawton wrote:

> Hello all,
>
> I am having trouble with the inclusion of external regressors in the GARCH
> equation, when using the twinkle package kindly provided by Alexios
> Ghalanos.
> I believe I am including the data correctly to starspec. An xts object,
> which is pre-lagged and has the same index as the data included within
> starfit optimization.
>
> Below, I have included an example of my code, with some generated data.
>
> library(xts)
> library(twinkle)
>
> xts1 <- xts(x=rnorm(100), order.by=Sys.Date()-1:100)
>
> xts2 <- xts(x=rnorm(100), order.by=index(xts1))
>
>
>
> spec = starspec(mean.model = list(states = 2,
>
>                                     include.intercept = c(1,1),
>
>                                     arOrder = c(1,1),
>
>                                     maOrder = c(2, 2),
>
>                                     matype="state",
>
>                                     statevar = 'y',
>
>                                     ylags = 3,
>
>                                    statear = TRUE),
>
>                                    variance.model=list(dynamic=TRUE,
>
>                                     model="sGARCH",submodel = NULL,
>
>                                     garchOrder=c(1,1),
>
>                                    vreg=xts1,
>
>                                    variance.targeting = FALSE),
>
>                                    distribution.model = "norm")
>
>
> ctrl=list(maxit=1000, alpha=0.2, beta=0.1, gamma=0.7, reltol=1e-12,
>
>             trace=0,method="BFGS",n.restarts=2,rseed=1)
>
>
> mod = starfit(spec, data = xts2,
>
>                solver.control = ctrl,
>
>                 solver = "msoptim")
>
>
>
> I get the following error when trying to run, which only occurs when the
> 'vreg' argument is included in the variance model:
>
>
> Error in matrix(vexdata, ncol = modelinc[39]) :
>
>    object 'vexdata' not found
>
>
>
> I get errors with other solvers also, whether I am including the
> solver.control list or not.
>
> In the rugarch package, the external regressors should be included as a
> matrix, not an xts object. However, when I include data as a matrix here, I
> get: starspec-->error: vreg must be an xts object.
>
>
> Is there a solution or work around to this problem?
>
>
> Kind regards,
>
> Neil
>

_______________________________________________
[hidden email] 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.