Suspicious estimates of ARMA-GARCH parameters in `rugarch` in `R` - r

I am facing a problem in ARMA-GARCH modelling in R. The model is specified by ugarchspec and fitted by ugarchfit in rugarch package. The solver produces an ARMA part with AR and MA coefficients essentially cancelling each other. For example, I get ARMA(2,2) with
AR1 = 1.72, AR2 = -1.71, MA1 = -1.8341, MA2 = 1.8346.
I suppose that this set of parameters is a local maximum of the surface of model likelihood, and the optimizer used in ugarchfit unfortunately reach it instead of reaching the global maximum.
Is there a way to avoid such situations? Perhaps it is possible to constrain parameters using ugarchfit so that such local maxima would be excluded a priori? For example, set some inequality constraints on parameters a priori, e.g.
| AR1 - AR2 | > 0.01
or, perhaps better, to do the same for the characteristic roots of AR and MA parts (so that they are not too close), or similar. Any ideas and help will be appreciated!

Related

R rugarch package. Error: parameters names do not match specification

I'm working on a personal project in R with the aim of fitting some GARCH models to returns which are then used to estimate some risk measures on univariate financial time series.
To fit the univariate GARCH models I'm using the package 'rugarch'.
Now, I set-up a gjrGarch model with garchOrder=c(3,3) and armaOrder=c(3,3) in the ugarchspec and then, with ugarchfit I fitted the model. However, when it comes to get the forecasted values of mu and sigma with ugarchforecast I get the following error:
ugarchfilter-->error: parameters names do not match specification
Expected Parameters are: mu ar1 ar2 ar3 ma1 ma2 ma3 omega alpha1 alpha2 alpha3 beta1 beta2 beta3 gamma1 gamma2 gamma3
Error: Exiting
Does anybody know what it means and how to solve it?
This is the code I wrote:
for (i in 1:length(df_data_wd_15$Return))
{
model=ugarchspec(variance.model=list(model='gjrGARCH', garchOrder=c(3,3)), mean.model=list(armaOrder=c(3,3), include.mean=TRUE), distribution.model='norm')
modelfit=ugarchfit(spec=model, data=df_data_wd_15$Return[i:(i+199)])
foref<-ugarchforecast(modelfit, n.ahead=2)
mu_for[i]<-foref#forecast$seriesFor[1]
sigma_for[i]<-foref#forecast$sigmaFor[1]
}
Thanks
A) Unfortunately, I can only help you with what the error means.
As the error messages states, modelfit doesn't contain the expected parameters, such that the forecast cannot be calculated. This could be the case when the solver in modelfit wasn't able to find a solution and fit coefficients.
You could check whether this is the case by printing modelfit and checking whether it looks empty. You could also double-check if that is truly where to problem lies by typing traceback() into your command prompt, which would show you in which line the error occurred.
B) How to solve the problem, or why the solver couldn't find a solution, I don't know. I suggest for you to (i) have a look at the specifications, to see whether there is something at odds there, or (ii) play around with the solver andsolver.control options (see documentation for ugarchfit), e.g. to allow multiple restarts.

In the auto.arima() function in R, how do I find the p,d,q values for that arima

I used an R code with an auto.arima function on a time series data set to forecast. From here, Id like to know how to find the p,d,q values for the arima. Is there a quick way to determine that, thank you.
The forecast::auto.arima() function was written to pick the optimal p, d, and q with respect to some optimization criterion (e.g. AIC). If you want to see which model was picked, use the summary() function.
For example:
fit <- auto.arima(lynx)
summary(fit)
Series: lynx
ARIMA(2,0,2) with non-zero mean
Coefficients:
ar1 ar2 ma1 ma2 mean
1.3421 -0.6738 -0.2027 -0.2564 1544.4039
s.e. 0.0984 0.0801 0.1261 0.1097 131.9242
sigma^2 estimated as 761965: log likelihood=-932.08
AIC=1876.17 AICc=1876.95 BIC=1892.58
Training set error measures:
ME RMSE MAE MPE MAPE MASE ACF1
Training set -1.608903 853.5488 610.1112 -63.90926 140.7693 0.7343143 -0.01267127
Where you can see the particular specification in the second row of the output. In this example, auto.arima picks an ARIMA(2,0,2).
Note that I did this naively here for demonstration purposes. I didn't check whether this is an accurate representation of the dependency structure in the lynx data set.
Other than summary(), you could also use arimaorder(fit) to get the vector c(p,d,q) or as.character(fit) to get "ARIMA(p,d,q)".

Lbq test and ARMA results, Should I include lags?

I have a return time series in daily frequency, which is stationary(proofed by ADF test) , has no autocorrelation up to lag10(proofed by lbq test with lag10) and has ARCH effect(proofed by LM test). My initial though is just directly applying GARCH model. Rather than the usual procedure: first using ARMA(p,q) to get the residuals, and then fit GARCH to this ARMA residuals.
However, out of curiosity, I still use ARMA(p,q) model loop through (p,q) lags with range [0,1,..,10] to see whether ARMA(0,0) has the smallest AIC among all. After looping though those 121 (p,q) combinations, I find the smallest AIC does NOT belong to ARMA(0,0) model, but ARMA(2,7). Then I check the coef of this ARMA(2,7) model and find the may lags included are significant. The two AR lags are both significant at 1% level.
Now, I am quite confusing. Based on the result of lbq(10) test, I should use ARMA(0,0). Based on the results of smallest AIC of ARMA models, I should use ARMA(2,7). May I please ask, in this case, should I use ARMA(0,0) or ARMA(2,7)? My preference is to use ARMA(2,7), but how can I explain to others when they ask: why still use ARMA model when lbq test shows no autocorrelation?
Any of your kind thoughts is greatly appreciated!
Please see the code and results below
lbqtest(returns,'Lags',1:10)
I could also use the following code to only get autocorrelation up to lag10
lbqtest(returns,'Lags',10)
The p results of lbq(1) till lbq(10) are:
p =
0.3425 0.5612 0.4180 0.5356 0.6637 0.7696 0.7770 0.8448 0.8995 0.9198
The AIC results of ARMA(2,7) and ARMA(0,0) are
AIC AR MA
-1498.252431 2 7
-1494.028 0 0
The estimation result of ARMA(2,7) using R is
arima(x = returns, order = c(2, 0, 7))
Coefficients:
ar1 ar2 ma1 ma2 ma3 ma4 ma5 ma6 ma7 intercept
-1.6786 -0.8756 1.6808 0.8128 -0.1691 -0.1736 -0.1065 0.0419 0.0411 -0.0006
s.e. 0.0381 0.0308 0.0660 0.1044 0.1078 0.1097 0.1082 0.1017 0.0642 0.0015

arima estimate validation through arima.sim

This is out of my curiosity trying to compare time series input to an ARMA model and reconstructed series after an ARMA estimate is obtained. These are the steps I am thinking:
construct simulation time series
arma.sim <- arima.sim(model=list(ar=c(0.9),ma=c(0.2)),n = 100)
estimate the model from arma.sim, assuming we know it is a (1,0,1) model
arma.est1 <- arima(arma.sim, order=c(1,0,1))
also say we get arma.est1 in this form, which is close to the original (0.9,0,0.2):
Coefficients:
ar1 ma1 intercept
0.9115 0.0104 -0.4486
s.e. 0.0456 0.1270 1.1396
sigma^2 estimated as 1.15: log likelihood = -149.79, aic = 307.57
If I try to reconstruct another time series from arma.est1, how do I incorporate intercept or s.e. in arima.sim? Something like this doesn't seem to work well because arma.sim and arma.rec are far off:
arma.rec <- arima.sim(n=100, list(ar=c(0.9115),ma=c(0.0104)))
Normally we use predict() to check the estimate. But is this a legit way to look at the estimate?

OLS estimation with AR(1) term

For reasons that I cannot explain (because I can't, not because I don't want to), a process used at my office requires running some regressions on Eviews.
The equation specification used on Eviews is:
dependent_variable c independent_variable ar(1)
Furthermore, the process used is "NLS and ARMA."
I don't use Eviews but, as I understand it, that equation means an OLS regression with a constant, one independent variable and an AR(1) term.
I tried running this in R:
result <- lm(df$dependent[2:48] ~ df$independent[1:47] + df$dependent[1:47])
Where df is a data.frame containing the dependent and independent variables (both spanning 48 observations).
Am I doing it right? Because the parameter estimations, while similar, are different in Eviews. Different enough that I cannot use them.
I've thoroughly searched the internet for what this means. I've read up on ARIMA and ARMAX models but I don't think that this is it. I'm sorry but I'm not that knowledgeable on statistics. By the way, estimating ARMAX models seems very complicated and is done by ML, not LS, so I'm really hoping that's not it.
EDIT: I had to edit the model indexes again because I messed them up, again.
You need arima function, see ?arima
Example with some data
y <- lh # lh is Luteinizing Hormone in Blood Samples in datasets package (Base)
set.seed(001)
x <- rnorm(length(y), 100, 10)
arima(y, order = c(1,0,0), xreg=x)
Call:
arima(x = y, order = c(1, 0, 0), xreg = x)
Coefficients:
ar1 intercept x
0.5810 1.8821 0.0053
s.e. 0.1153 0.6991 0.0068
sigma^2 estimated as 0.195: log likelihood = -29.08, aic = 66.16
See ?arima to find help about its arguments.

Resources