[R-SIG-Finance] External Regressors in GARCH Equation when using Twinkle

alexios galanos @|ex|o@ @end|ng |rom 4d@c@pe@com
Thu Sep 12 06:23:12 CEST 2019


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
>



More information about the R-SIG-Finance mailing list