# Writing the likelihood and conditional variance in a ARMAX model or regression with GARCH (R rugarch with external covariates)

I was looking at the r package called rugarch (docs) also mentioned in this question and in the Matlab Guide but I cannot see any example of how the likelihood or log-likelihood is computed when external covariates are included (as for a regression with GARCH error term or even an ARMAX model). In particular, when we have external covariates, I don't know whether we have to write the likelihood conditionally on $$t-1$$ or conditionally on $$t-1$$ and covariates $$x_{t}$$ ?

More details are provided as follows. Since, I am interested in the case where you have external covariates, consider a regression model model with GARCH error term (but I could have used an ARMAX) of the kind $$y_{t}=\beta x_{t} + e_{t}$$ with $$e_{t}=\sigma_{t} Z_{t}$$ and $$Z_{t} \sim N(0,1)$$ where $$\sigma_{t}$$ is a matrix of appropriate size resulting from the Cholesky decomposition of the conditional covariance matrix $$\sigma_{t}^{2}$$, $$\sigma_{t}^{2}$$ follows a GARCH process. Here I have written a regression with GARCH error term, but the same problem happens when I try to use a ARMAX model, so it is a more general problem that relates to the presence of external covariates $$x_{t}$$ more than to the shape of the error term.

Indeed, my question is: which is the correct likelihood function and, in particular, the correct conditional variance to be used in the likelihood function? Is it $$Var(y_{t}|t-1, x_{t-1})$$ because we calculate the time-t conditional pdf as $$L(y_{t} |t-1,x_{t})$$ so that we condition on both $$t-1$$ info set and external covariates? Or instead we have to condition on time t-1 only and write the likelihood as $$L(y_{t} |t-1)$$? So that the conditional variance to be used becomes the conditional variance of residuals $$Var(e_{t}|t-1)=Var(y_{t}-\beta x_{t}|t-1)$$?.

More precisely, if we have to condition on $$t-1$$ only, then, applying conditional expectations, we have $$E(y_{t}|t-1)=E(x_{t}+\beta x_{t}|t-1)=0$$ which in my case is 0 because I do not have any conditional mean structure on any variable. Then the conditional variance is $$Var(y_{t}|t-1)=Var(e_{t}+\beta x_{t}|t-1)$$ and the time-t pdf conditionally on $$t-1$$ becomes:

$$L(y_{t}|t-1)=(2 \pi)^{-k/2} Var(y_{t}|t-1))^{-1/2} e^{-1/2 (y_{t}^{T} Var(y_{t}|t-1)^{-1} (y_{t})}$$

BUT, if we have to condition on both $$t-1$$ and external covariates $$x_{t}$$, then the conditional variance term would change from $$Var(y_{t}|t-1)$$ into $$Var(y_{t}|t-1, x_{t})$$ as, if we condition on $$t-1$$ then $$x_{t}$$ becomes non-stochastic. The time-t pdf used in the likelihood would be:

$$L(y_{t}|t-1, x_{t})=(2 \pi)^{-k/2} det(Var(y_{t}|t-1))^{-1/2} e^{-1/2 (y_{t}-\beta x_{t})^{t} Var(y_{t}|t-1)^{-1} (y_{t}-\beta x_{t})}$$

which, substituting $$Var(y_{t}|t-1, x_{t})=Var(e_{t}|t-1, x_{t})=Var(e_{t}|t-1)=\sigma_{t}^{2}$$, becomes

$$L(y_{t}|t-1, x_{t})=(2 \pi)^{-k/2} det(\sigma_{t}^{2})^{-1/2} e^{-1/2 (y_{t}-\beta x_{t})^{t} \sigma_{t}^{2 -1} (y_{t}-\beta x_{t})}$$

Which is the correct one for the rugarch package? I am trying to check the docs of the library but I haven't found anything precise on this point.

Thank you

• @Aksakal you helped a lot on a similar question, maybe you know the answer here? – Fr1 Aug 6 '19 at 21:28
• @StoryTeller0815 you helped me pretty much in a question a few days ago, where we talked about similar topics.. maybe do you know the answer here? – Fr1 Aug 6 '19 at 21:30

I do not know more about rugarch than can be found in its documentation, so I will not be of help clarifying the finer details of its model specifications.

Regarding conditioning in general, I would condition on the information I have. E.g. if I have $$x_t$$ when modelling $$\sigma_t^2$$, I would condition on it; if not, then not. I would start from deciding on what model I want to use and what information I have and then define the likelihood accordingly. An example of my thinking: if you have $$x_t$$ in your equation for $$\sigma_t^2$$ or some other place as a regressor, include it in the likelihood. If you do not want it included in the likelihood, re-express the model so as to exclude $$x_t$$ from it.

From sources:

source 0 MARSS State Space Models pag. 3 and 22 for the likelihood of a generic MARSS model in State Space form without and with external covariates (the latter is referred to expectation maximization algorithm but provides the likelihood for a generic model represented in State Space form that involves external covariances, in addition to endogenous variables).

source 2 ARMAX pag.5

source 3 Dynamic Regression likelihood

In case some exogenous regressors are added to a time-series, then the likelihood must be computed conditionally on t-1 and covariates (that are indeed assumed to be exogenous!). So given the generic dynamic regression (here with GARCH error term described by $$\sigma_{t}^{2}$$ which is not described any further for brevity!) $$y_{t}=\beta x_{t} + e_{t}$$ with $$e_{t}=\sigma_{t} Z_{t}$$ and $$Z_{t} \sim N(0,1)$$.

Let’s compute the conditional moments: $$E(y_{t}|t-1, x_{t})= \beta x_{t}$$ $$Var(y_{t}|t-1, x_{t})=Var(\beta x_{t}+e_{t}|t-1, x_{t})=Var(e_{t}|t-1, x_{t})=Var(e_{t}|t-1)=\sigma_{t}^{2}$$ Then the time-t likelihood expression, given both the info set at time t-1 and the external regressors becomes $$L(y_{t}|t-1, x_{t})=(2 \pi)^{-k/2} det(Var(y_{t}|t-1, x_{t}))^{-1/2} e^{-1/2 E(y_{t}|t-1, x_{t})^{T} Var(y_{t}|t-1, x_{t})^{-1} E(y_{t}|t-1, x_{t})} \rightarrow$$ $$L(y_{t}|t-1, x_{t})=(2 \pi)^{-k/2} det(\sigma_{t}^{2})^{-1/2} e^{-1/2 (y_{t}-\beta x_{t})^{T} \sigma_{t}^{2 -1} (y_{t}-\beta x_{t})}$$

P.S. however if you disagree, please notify me and inprove the answer

• (Answering your request from another thread.) I don't know more about rugarch than can be found in its documentation, so I will not be of help clarifying the finer details of its model specifications. Regarding conditioning, I would condition on the information I have. E.g. if I have $x_t$ when modelling $\sigma_t^2$, I would condition on it; if not, then not. I would start from deciding on what model I want to use and what information I have and then define the likelihood accordingly. – Richard Hardy Aug 11 '19 at 16:27
• An example of my thinking: if you have $x_t$ in your equation for $\sigma_t^2$ or some other place as a regressor, include it in the likelihood. If you do not want it included in the likelihood, reexpress the model so as to exclude $x_t$ from it. Probably this is not much help at all, but this is how I would start. – Richard Hardy Aug 11 '19 at 16:30
• @RichardHardy ok Richard many thanks for your help.. I understand that you agree with the formulation where if you have external regressors then you have to condition based on those.. if so, and you want to have some reputational reward for your help, please turn your comment 1 into answer and will upvote and mark as answer. Thank you, you have been very kind – Fr1 Aug 11 '19 at 16:35
• You are the one who is kind here. My answer took a long time and did not provide more than some basic insight, IMHO. – Richard Hardy Aug 11 '19 at 17:32