The mixed frequency regression studies the explanatory power of high frequency variables on the low frequency outcome. The weights associated with high frequency regressors are usually assumed some functional form. This toolbox is a repack of the Mi(xed) Da(ta) S(ampling) regressions (MIDAS) programs written by Eric Ghysels. It supports ADLMIDAS type regressions. The package also includes two functions for GARCHMIDAS and DCCMIDAS estimation. See the enclosed user guide for details.
Syntax:
[...] = MIDAS_ADL(DataY,DataYdate,DataX,DataXdate)
[...] = MIDAS_ADL(DataY,DataYdate,DataX,DataXdate,name,value,...)
[...] = GarchMidas(y, name,value,...)
[...] = DccMidas(Data, name,value,...)
2.3.0.0  Add a namevalue pair 'DiscountIncrease' to MIDAS_ADL. 

2.2.0.0  Fix a bug in DccMIDAS FMINSEARCH when MATLAB Optimization Toolbox is not available. 

2.2.0.0  Update user guide 

2.1.0.0  version2.1 Add MIDAS quantile regression 

2.0.0.0  Package written by Eric Ghysels and collaborators 

2.0.0.0  Update the toolbox title from "MIDAS Regression" to "MIDAS Matlab Toolbox" 

2.0.0.0  Add GARCHMIDAS and DCCMIDAS functions 

1.5.0.0  Support Ylag as a cell array such as Ylag = {3,6,9} for flexible low frequency lagged regressors


1.2.0.0  Update the user guide (version Dec 21, 2014) 

1.2.0.0  Support the special case DL_MIDAS by setting Ylag = 0 

1.1.0.0  Allow leads and lags specification 'horizon' be negative. Add true outofsample forecast; results are restored in the last output argument 'Extended Forecast' struct. 
Create scripts with code, output, and formatted text in a single executable document.
yuexian tang (view profile)
Dear Huang Qian,
Thanks for your reply. I did contact the author, but as expected, I have not got the reply. This is much easier to predict than stock volatility using GARCHSpline model.
All the best
Yuexian Tang
Hang Qian (view profile)
Dear Yuexian,
Sorry, I do not have GARCHSpline code. Perhaps the best way to get the code is to contact the authors?
yuexian tang (view profile)
Dear Hang Qian,
Thanks for your reply. Do you know where to get the code for the GARCHSpline model (Engle and Rangel, 2008) because I want to make a comparison between the GARCHSPLINE and GARCHMIDAS model in terms of forecasting performance.
All the best
Yuexian Tang
Eric Ghysels (view profile)
Dear Lue Li:
Two references which might be useful on the topic of testing for Granger causality in mixed frequency data:
E. Ghysels, J. Hill and K. Motegi “Testing for Granger Causality with Mixed Frequency Data”, Journal of Econometrics, 192, 207230.
E. Ghysels, J. Hill and K. Motegi "Testing a Large Set of Zero Restrictions in Regression Models with an Application to Mixed Frequency Granger Causality", Journal of Econometrics (forthcoming).
Particularly the second one proposes a very simple regressionbased set of Granger causality tests in a mixed frequency data setting.
Sincerely,
Eric Ghysels
Hang Qian (view profile)
Dear Lue Li,
I am not aware of a MATLAB program for Granger causality test for mixed data models. I think you may construct a Wald (or likelihood ratio) test statistics using the estimated coefficients and covariance matrix obtained from the MIDAS regression program. Alternatively, maybe you can do data screening by running multiple MIDAS regression, and take those producing good forecasting results and discard bad ones.
Li Lue (view profile)
Dear Hang Qian,
I have a question I would like to ask, is the mixing data required for raw data screening? For example, is there a matlab program that explains whether there is a "causal relationship" to the mixed data model, such as Granger causality. I want to learn to understand, thank you very much.
All the best
LUE LI
Hang Qian (view profile)
Dear Yuexian,
If we want to compare log likelihood between models of different lags, it is necessary to fix the number of observations. Otherwise, it is not an appletoapple comparison and the log likelihood values are monotonously decreasing with more lags.
Hope it helps,
Hang Qian
yuexian tang (view profile)
Dear Hang Qian,
When I run the original code of GARCHMIDAS with the data used in Engle et al. (2013), I found the log likelihood values are monotonously decreasing. However, it seems that the paper said that there is maximum log likelihood value at about 30 MIDAS lags but the plot of the log likelihood function is not reported in that paper. I am wondering if you ever came across this problem.
All the best
Yuexian Tang
Hang Qian (view profile)
Dear Yuexian,
All the output variables are real, even if there are complex numbers in some intermediate variables. It is the expected behavior and it is a numeric vehicle that facilitates gradientbased maximum likelihood optimization. The GARCHMIDAS code is based on a standard GARCH(1,1) specification, but you probably can extend the model to Egarch, and adapt the code accordingly. I think the shortrun component of the conditional variance can be specified as Egarch, and the longrun component is determined by the realized volatility or macroeconomic series, which is specified as a MIDAS regression.
yuexian tang (view profile)
Dear Huang Qian,
when I read the code of GARCHMIDAS, I cannot understand that the imaginary number of the complex value is the derivative: Gradient(:,m) = imag(complexValue). Can you please explain it? Another question I got is that I wonder if the code is still valid when I change the Garch specification into Egarch process?
All the best
Yuexian Tang
Li Lue (view profile)
Hang Qian (view profile)
Hi Changfeng,
The warning message 'Covariance matrix of estimators cannot be computed precisely due to inversion difficulty' usually indicates that the numeric maximum likelihood does not converge to a local optimum. Maybe it stopped at a saddle point. In that case, the information matrix is not necessarily positive definite and there could be problems when it is inverted for the covariance matrix. We may want to try some different starting values and see if it can converge to a better point. There are some namevalues pairs for adjusting the starting values, like 'Mu0', 'Alpha0', 'Beta0', 'Theta0', etc.
Zhou Changfeng (view profile)
Hi Hang Qian
Thank you so much for your toolbox, I faced some problem in the GARCHMIDAS model. When I run the GarchMidasX model, I received the warning. 'Covariance matrix of estimators cannot be computed precisely due to inversion difficulty.', and what's the reason lead to it?
Best,
Changfeng Zhou
Chengtao Deng (view profile)
Hi Hang Qian
I really appreciate your help. I would try to contact the author for more information about this topic. I have some idea for the X to influence the correlation matrix but not the variance part. Thanks again!
Best,
Chengtao Deng
Eric Ghysels (view profile)
Dear Chengtao:
Regarding extensions of the DCCMIDAS model, a great researcher to contact would be Christian Conrad at Heidelberg University. He would be happy to help you out. You may mention our exchange.
Best
Eric Ghysels
Hang Qian (view profile)
Hi Chengtao,
It is good to know that you are extending the DCCMIDAS model by adding X variables to the dynamic correlation. It is definitely a promising direction of research and challenging problem to address. I have no research in DCCMIDAS, and thus not the best person for technical discussions. Just my two cents: it might be easier to add X variables to the square root the dynamic correlation matrix – at least, we are free from the positivedefinite constraints. Good luck!
Best,
Hang Qian
Chengtao Deng (view profile)
HI Hang Qian
Thank you for your timely reply! I tried to change the univariate GARCH model to make it become a GARCHX style.But the dynamic correlation between two series did not show a significantly change after I change the univariate GARCH model, even the exogenous variable "X" is significant in the Variance function. I think the "X" should be added to the estimation of q11, q12, q22 in the second step of the DCC estimation. Also the positive definite should be changed to (1abx)>0. I'm interested in how to define the influence of X on the dynamic correlation between A and B. I saw a article of which Christian Conrad and Karin Stürmer(2017) called "On the economic determinants of optimal stockbond portfolios: international evidence". In this article they introduced a dccrcx model that I think is helpful to our discussion. Look foward to your reply.
Hang Qian (view profile)
Dear Chengtao,
The toolbox function DccMidas follows a twostep model specification and estimation strategy. Conditional variances are obtained from the univariate GARCHMIDAS models with the longrun component being the realized volatility. I do not have code for exogenous variable X in DCCMIDAS. For users who want to extend the model with macroeconomic data, refer to the GarchMidas function, in which there is a namevalue pair 'X'. Perhaps macroeconomic data could be inserted in the firststep univariate regressions?
Chengtao Deng (view profile)
Dear Hang Qian
I noticed the discussion between you and Fu Wang about how to add the exogenous variable X in DCCMIDAS. I tried to modify the command but it doesn't work. I wonder if it is ok that you or FuWang have completed the discussion of this problem,could you please give me some help for this problem?
Hang Qian (view profile)
Dear xiaohui,
When we change the namevalue pair 'LogTau', we switched to a different model specification (in which longrun volatility is modelled in logarithm). Similarly, resetting 'Beta2Para' leads to a model where we use twoparameter Beta MIDAS polynomial instead of oneparameter Beta polynomial. Different model can give us different results. Setting an appropriate starting value for MLE is a trialanderror process. A good starting value needs to be close enough to the true (but unknown) value of parameter.
xiaohui zhao (view profile)
Dear Hang Qian,
Thank you for reply me so quickly.
I am still confused about the setting. I just try to change the 'LogTau'=true, then that warning disappeared.
Ane when I set 'Beta2Para'=true, the Pvalue of the theta changed a lot (the significant value to insig, while the insigparameter changed to significant value). And when I changed the starting value of the 'Theta0' the Pvalue of Theta also changed dramatically.
When I set the starting value, is there some rules(economic or mathmatic) I need obey? Or I just can set them what ever I want.
It seems that I can manipulate the model to change the results until I get the results I want.
Hang Qian (view profile)
Dear xiaohui,
The message was issued by the MATLAB numerical optimization function FMINCON, which requires the starting value of MLE must fall into the feasible region (which corresponds to a finite log likelihood value). Otherwise, the optimizer cannot start to work. The only way to solve that problem is to experiment various starting values. I do not know the appropriate starting values, but the software offers a set of namevalue pairs ('Mu0', 'Alpha0', 'Beta0', 'Theta0', 'W0', 'M0') so that users can reset them. For example, we could put 'Theta0', 0.01 and/or 'M0', 0.001, etc.
xiaohui zhao (view profile)
Dear Hang Qian,
Thank you so much for your toolbox, I faced some problem in the GARCHMIDAS model.
I want to add some marco variable. Only one variable with all positive data can get the results. However, when I add some variables with mixed data(positive and negative). I received the warning.
xDay2 = prod;
>> [estParams,EstParamCov,Variance,LongRunVar] = GarchMidas(nex,'Period',period,'NumLags',24,'X',xDay2,'ThetaM',1);
警告: FMINCON failed... Switch to FMINSEARCH. Error Message: Objective function is undefined at initial point. Fmincon cannot continue.
I see your reply to other person who faced the same problem. But, I am not sure how to change the starting values.
Hang Qian (view profile)
Dear karim,
When we work on the realized volatility, it is necessarily a positive number. However, some macro variable may take on negative values. Parameter estimation works better if the Namevalue pair ''thetaM'' is set to true. In that case, the parameter theta and m in the longrun volatility component can be either positive or negative.
karim belcaid (view profile)
Dear Hang Qian!
Dear Hang Qian,Thank you so much for your toolbox, I feel confused about the GARCHMIDAS model：
[estParams,EstParamCov,Variance,LongRunVar] = ...
GarchMidas(y,'Period',22,'NumLags',12,'X',xDay, 'ThetaM',1);
When i do this code in order to obtain GARCHMIDAS parametr estimations with macro variable, i obtain this error message:
Reset the Namevalue pair 'thetaM' to true, so that theta and M could be negative.
I dont understand why does this happen even i set 'thetaM' to true.
Hang Qian (view profile)
Hi Fu Wang,
Sorry for the confusion. The GarchMidas function has a namevalue pair 'X' for macroeconomic data that determines the longrun conditional variance. This corresponds to Equation 3.23 and the realized volatility is represented in Equation 3.22. The DccMidas function does not support exogenous variables in the model. If we really want to insert a macroeconomic variable into the variance part of the model, we may consider rewriting line 275 of the DccMidas function. This line calls GarchMidas for conditional variances. It might be possible to add a namevalue pair 'X' when GarchMidas is called. I am not sure if really works, but you are encouraged to try this namevalue pair. Also, the namevalue pair 'ThetaM' and 'LogTau' are important when exogenous variables are used instead of realized volatility. It is good to try values that are different from the default setting. Also, the default starting values might not be appropriate if the exogenous variable has a scale that is vastly different from the realized volatility. Line 276 – 279 contains many namevalue pairs related to initialization. It is good to try various values to make the numeric optimization works well.
Fu Wang (view profile)
Hi Hang Qian
Continuing the discussing of dccmidas on 19 Jan 2018 ,I am afraid you misunderstanding my question.I am wondering how can we use v_t=1/N ∑_x_it (3.23), not the equation 3.22 in the dccmidas model. The toolbox doesn't provide the option that we can use the monthly average of an exogenous variable to replace the realized volatility in the dccmidas model .
Hang Qian (view profile)
Hi Claire,
You may check the code block that calculates the initialize values sent to fmincon. Do the initial values have the same vector dimension and orientation as your lower and upper bounds? Do the initial values fall into the bounds? MATLAB debugging tool might be useful in addressing those puzzles. You may want to check if the values sent to fmincon function is in a feasible region and validate the gradient is also computed correctly by numeric difference.
Claire (view profile)
Hi, Hang Qian!
One question. When I used Exponential Almon Lags, I used fmincon function to constraint the lower and upper bounds. However, it always went wrong. I checked the Beta Lags way and fount out the bnls_adl_new.m eventually invoked the mfrvobj_adl.m just as enls1_adl_new does. I have no idea why it worked for one but not the other. Could you give me some advice?
Hang Qian (view profile)
Dear qiu luo,
When we set 'thetaM' to true, the program does not take the squares for the parameter theta and m in the longrun volatility component. It will make the numeric optimization work better, especially when the macroeconomic variable (which could be positive or negative valued) is used instead of realized volatility. It is recommended to set this namevalue pair, whose default value is due to compatibility for the original code that comes with the journal article.
qiu luo (view profile)
Dear Hang Qian,Thank you so much for your toolbox, I feel confused about the GARCHMIDAS model：
[estParams,EstParamCov,Variance,LongRunVar] = ...
GarchMidas(y,'Period',22,'NumLags',12,'X',xDay);
警告: Reset the Namevalue pair 'thetaM' to true, so that theta and M could be
negative.
why does this happen？According to the economic theory ,theta should be positive...
Hang Qian (view profile)
Hi Fu Wang,
I am not sure how to add exogenous variables into DCCMIDAS. Each element of the correlation matrix has its own dynamic components. If exogenous variables are inserted, there could be numerous parameters to estimate. Parameter estimation might work under a customized model, in which exogenous variables affect correlation matrix in a constrained manner. As a generalpurpose software program, it might not work well as we expected.
Fu Wang (view profile)
hi Hang Qian
thank you for providing the DCCMIDAS code. There is a problem confusing me for a long time .that is how can we add the X into the DCCMIDAS model just like the GarchMIDAS model.I tried to revise the code ,but failed. It is important for my paper and graduation.could you provide an update vision ? thank you
Hang Qian (view profile)
Hi qinmeng,
Thank you for clarification. Maybe you are right, though I am not sure.
qinmeng qin (view profile)
dear Hang,
ρ dfi is the（d,f）element of ρ i, then day t in month i
Hang Qian (view profile)
Hi qinmeng,
In your notation, what do the variable d and f stand for? I do not have the two variables defined in equation (26).
qinmeng qin (view profile)
dear Hang Qian,
In the equation(26), q ijt = ρ ijt (1 − a − b) + aε i,t−1 ε j,t−1 + bq ij,t−1 , I think it should be this one,
q dfit = ρ dfi(1 − a − b) + aε di,t−1 ε fi,t−1 + bq dfi,t−1(variable d and f),then equation(27):
change t to i . I want to know what's wrong with me? thank you very much!!!
Hang Qian (view profile)
Hi Trung,
The Bootstrap method that I used in MidasQuantile code works like this: I just resampled the residuals and then reconstruct the simulated data. With simulated data, I used gradientfree numerical method (fminsearch) for parameter estimation. With a collection of simulated parameters, I computed the sample standard error. I did not use gradient information in the Bootstrap and do not know how to make use of it for a better approximation of the standard errors.
Trung Le (view profile)
Hi Hang Qian
Many thanks for your answer. It is definitely different depending on the specified model. Since the MidasQuantile function currently only supports Beta Function, I think I will need to try another model specification.
Just another question, in Ghysels, Plazzi and Valkanov (2016) they reported the pvalue for estimated parameters based on NeweyWest standard errors. In the toolbox, however, the standard errors is calculated using Boostrapping standard errors. I spotted that you already write function to automatically objFun gradient. How could I use these functions to compute the standard errors similar to Ghysels et al (2016)?
Hang Qian (view profile)
Dear Ruobing Liu,
If the estimated longrun variance looks unreasonable, I would check parameter estimation first, as the longrun variance is obtained from the estimated parameters. If the estimated parameters are unusually large or small due to numerical optimization, I would revise the model specification and/or change the optimization settings. I would also try some other macroeconomic variables, the volatility of the macroeconomic variable itself may have an impact on the results. For example, if we have a macrovariable never changes values over time, perhaps no regression can generate meaningful estimation results.
Hang Qian (view profile)
Hi Trung,
The weight parameters are estimated along with other parameters like the slope terms. When the sampling variation is large, it is possible that some estimated parameters are not significant. If we use the Beta polynomial like (1j/n)^(theta1), it could be a problem if the estimated theta is not significantly different from zero, because we put increasing weights on coefficients when theta = 0. If we use exponential Almon lags, then an insignificant weight parameter indicates flat weights on the regressors, which might be still reasonable as in a traditional aggregation scheme with flat weights. It is certainly good to try to find a model specification in which estimated parameters are significant. Otherwise, if the zero coefficients remain interpretable under some polynomials, I would still view it as a valid specification.
Hang Qian (view profile)
Hi hellocate,
The number 0.7071 represents sqrt(2)/2. We inverse the normal c.d.f. to obtain the pvalue, as the asymptotic distribution is normal. The formula used in the code is an approximation, but it should be close to the results obtained by norminv().
It appears that 252*Variance(seq) is the annualized volatility, when we use daily data the estimated variance is daily volatility. We just rescale the variable so that the results are more interpretable.
Ruobing Liu (view profile)
Dear Hang
Thank you so much for your toolbox, I feel confused about the GARCHMIDAS model, when I add in the macroeconomic variables into the model, the longrun variance is pretty big, which is larger than 1, for the model without the macroeconomic variables, the longrun variance is pretty small, about 0.0001. I want to know is the difference normal?
hellocate (view profile)
Hello Hang Quian,
thanks for the toolbox! I'm just a little bit confused about the GarchMidas.I want to know why we Calculate pval in this formula，pval = 0.5 * erfc(0.7071 * abs(zstat)) * 2，and what 0.7071 means.And i don't down why we use 252*Variance(seq) rather then Variance(seq) directly in appGARCHMIDAS1.m:plot(year(seq),sqrt(252*Variance(seq)),'g','LineWidth',1).
Trung Le (view profile)
Hi Hang Qian
I have a question with regards to the interpretation of weighting parameter(s) in the MIDAS model in general and specially the Quantile MIDAS model.
How could I interpret the significance of the weighting parameters? I looked at several papers using MIDAS and notice that almost all of them did not pay attention on the significant level of these weighting parameters, but only the slope.
Is it still save to use the model if I have insignificant weighting parameters but strongly significant slope parameter in Quantile MIDAS?
Imran Kanjoo (view profile)
Hang Qian (view profile)
Dear qinmeng,
The toolbox only supports one high frequency (HF) predictor. There is no simple way to adapt the code for multiple variables. Also, Prof. Ghysels once responded to the question you raised. He wrote: “The MIDAS Matlab Toolbox only handles one HF series and recommends forecast combinations as explained in the User's Guide. Having multiple HF series in a single MIDAS regression often runs into nearcolinearity issues which may impair the nonlinear estimation procedure. For that reason Andreou et al. (2013) suggest using one HF series for potentially a large panel of HF data and perform forecast combinations. Some other software packages  such as EViews  allow for MIDAS regressions with multiple HF series."
Andreou, Elena, Eric Ghysels, and Andros Kourtellos. "Should macroeconomic forecasters use daily financial data and how?." Journal of Business & Economic Statistics 31.2 (2013): 240251.
qinmeng qin (view profile)
Dear Hang，
Thank you so much for your toolbox.
I want to know that ADL_MIDAS model has only one high frequency variable,so how to add two or more than two high frequency variables.
thank u!
Hang Qian (view profile)
Hi Qi Li,
The toolbox does not use the function 'ssr_r25'. It used 'ssr_r25_adl_new', which is located in the same folder as MIDAS_ADL. The function computes the objective function for the MIDAS Beta polynomials.
Claire (view profile)
Hi Hang,
Thank you so much for the great toolbox.
I'm just a little confused when I stepped into bnls_adl_new.m and replaced 'fminunc' by the constrained optimizer 'fmincon' with my constraints, I couldn't find function 'ssr_r25' in the toolbox package. How can I settle this problem?
Hang Qian (view profile)
Hi Stefan,
Yes, with lagged y included as additional predictors, it is an ADLMIDAS model.
Stefan (view profile)
Thanks again! But in formula (2.1) in the 2016 version of the manual I can't see lagged y as additional predictors? With lagged y included (as in formula (2.12)) it is a ADLMIDAS isn't it?
Hang Qian (view profile)
Hi Stefan,
A baseline MIDAS model consists of a lowfrequency dependent variable y and a highfrequency explanatory variable x. The regressors involve lagged x.
A DLMIDAS model consists of a lowfrequency dependent variable y, a highfrequency explanatory variable x, as well as lagged y as additional predictors. The regressors involve both lagged x and lagged y.
The estimation methods are the same. Unknown parameters are estimated by nonlinear least squares.
Stefan (view profile)
Hello Qian,
I looked at the manual once more and got another question. What is the difference between the DLMIDAS and the MIDAS model? I thought that the only difference between distributed lag and MIDAS models is that the independent variable has the same frequency as the dependent variable in case of a distributed lag model and that the frequency of the independent variable is higher in case of a MIDAS model. Now I'm a bit confused since equation (2.1) in the toolbox manual looks like a standard MIDAS equation to me. Are they simply the same and just named differently or is there a difference in the specification or estimation? Thanks for clarification!
Stefan (view profile)
Thank you very much for your fast reply Hang Quian and Prof. Ghysels!
Hang Qian (view profile)
Hi Stefan,
Prof. Ghysels provided an answer to your question.
“In the Clements and Galvao setup there is a parameter restriction between the autoregressive coefficient in the regression and the MIDAS polynomial lag coefficients. Andreou, Ghysels and Kourtellos in their Handbook chapter explain that this restriction is unwarranted and can lead to misspecifications and therefore inconsistent parameter estimates. In an ADLMIDAS there is no restriction between the AR parameter(s) and the MIDAS polynomial parameters.”
Hang Qian (view profile)
Hi Stefan,
The software implements equation (2.12) by adding autoregressive lags to the MIDAS regression, and I did not note numeric problems. The software does not put "common factor" in the regression. Sometimes, we note problems when we put multiple highfrequency predictors, but with lowfrequency autoregressive predictors the software appears wellbehaved.
Stefan (view profile)
Hello Hang Quian,
thanks for the toolbox! I'm just a little bit confused about the ADLMIDAS because Ghysel, Sinko, and Volkanov (2007) and Clements and Galvao (2008) discuss the problem of simply adding an autoregressive lag (seasonality between y and x) and Clements and Galvao (2008) suggest the implementation as "common factor". I don't see any difference between equation (2.12) in the MIDAS Matlab Toolbox handbook (the ADLMIDAS) and a standard MIDAS equation augmented with an autoregressive lag. Why does the problem not occur here? Thanks for your help!
Hang Qian (view profile)
Hi mantu,
Thank you for your interest in the toolbox. If you believe the results are good, you may ignore the covariance matrix message. Sometimes it is caused by numeric issues for a theoretically welldefined problem.
In the U.S., the commonly used value format is 7.26 (seven point twentysix), which is also used by MATLAB software.
mantu (view profile)
hi again qian, I ve done things you ve told me and I had good results but it still gave me same error.
Warning: Covariance matrix of estimators cannot be computed precisely due to inversion difficulty.
> In GarchMidas (line 311)
In adana (line 25)
Should I ignore it or do I have to try to still. Also interestingly the code gives me different result when I use different value format like comma and dot (7,26 or 7.26) on excell. I ve got better result with dot but can I use both of them? thanks...
Hang Qian (view profile)
Hi mantu,
The GarchMidas program resorts to numerical routines for maximum likelihood estimation, and the occasionally the estimated covariance matrix is not positive definite. Sometimes the indefiniteness is caused by nonconvergence of the numeric solver. There is no good solution, but you may try different starting values for the parameters by resetting the namevalue pairs 'Alpha0', 'Beta0', etc. You may also consider more accurate gradient computation, by setting the namevalue pair 'Gradient'. If the data really fit the model poorly, consider alternative model specifications such as adding/subtracting some lags by the namevalue pair 'NumLags', resizing the estimation window by the namevalue pair 'EstSample'.
mantu (view profile)
hi hang, I have problem with my datas. I m using shareholder Daily prices as dependent variable and firms profit quarterly profits as independent variable (my datas from 2005.1 to 2016.6) but I have this warning;
Warning: Covariance matrix of estimators cannot be computed precisely due to inversion difficulty.
> In GarchMidas (line 311)
In adana (line 25)
I know some other fellas had this problem you said we should adjust our model specifications, can tell me more specifically also when I use secular component it gave me this warning;
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
I think my datas are fine but do you have any suggestion. thank you
Hang Qian (view profile)
Dear Ruobing,
The default behavior of the software is to restrict one MIDAS parameter to unity.
There is a namevalue pair 'Beta2Para', which is a logical value that indicates twoparameter Beta MIDAS polynomial.
Ruobing Liu (view profile)
Dear Hang
I have one question about the GARCHMIDAS model and the MIDAS toolbox. Based on the MIDAS Matlab toolbox equation 3.24, the GARCHMIDAS model have w1 and w2. When I use the tool box, I only get one w, My command is like follow: [estBeta2Para,EstBeta2ParaCov,Variance, LongRunVar]=GarchMidas(y,'Period',period,'NumLags',numLags,'X',x);,
Could you please tell me the reasons. Looking forward to your reply.
Ruobing Liu
Eric Ghysels (view profile)
Dear Erik:
Both EViews and midasr allow for multiple HF regressors (even with different frequencies). Multi colinearity is a generic problem encountered in linear regressions  but its prevalence is potentially more acute when using closely related HF series. There is no special treatment in EViews or midasr specific to MIDAS regressions. The MIDAS Matlab Toolbox avoids the issues by opting for forecast combinations.
Hope this helps
Eric Ghysels
Erik Stenberg (view profile)
Hi,
I wonder how/why Eviews can handle these nearcollinearity issues that happens when using multiple HF series to forecast? Are forecast combinations equally good? Do you happen to know if it is possible to use multiple HF series in the R package midasr? Thanks a lot for a great toolbox!
Erik
Hang Qian (view profile)
Hi Ruobing,
When the namevalue pair AdjustLag is set to 1, the software will reweigh the presample observations, instead of discarding those missing values. Refer to Line 555 – 589 in GarchMidas for the weight calculation. The software does not support both realized volatility and macroeconomic variables, but you may consider modify the code by adding more variables (and new parameters for estimation as well). Basically, you may adapt the local function FML at 432, in which log likelihood of GARCHMIDAS is computed.
Ruobing Liu (view profile)
Dear Hang
Thank you so much for your toolbox, I have problems with the GARCHMIDS model. As I run the regression to obtain the longrun variance, as the time period is short, so I use the AdjustLag, but I don't know how to calculate the weight of every lags. I also want to know can I use the variance and the level of the macroeconomic at the same time by employing the toolbox? Looking forward to your reply.
Robin Liu
Hang Qian (view profile)
Dear Alberto,
I am not sure if it could resolve your problem, but you may consider the following: 1) resetting the namevalue pair 'ThetaM' to 1, which indicates not taking squares for the parameter theta and m in the longrun volatility component; 2) resetting the namevalue pair 'Gradient' to 1, which uses analytic gradients; and 3) if you have Global Optimization Toolbox of MATLAB, try to replace FMINCON by some global optimization routine supported by that toolbox.
Eric (view profile)
Alberto:
I forwarded your questions to Bumjean Sohn who will be able to help you
Eric
Alberto Grassi (view profile)
Dear Hang,
Thank you for your toolbox. I have problems with the GARCHMIDAS example because when I run it I obtain a flat long term variance for the part of the example with the macroeconomic variables. I also tried to modify the original codes of the authors to replicate the paper of Ghysels, Engle and Sohn(2013) but also in that case I have problems with the log(tau) model. Many times with those codes I obtain the same result as the one I obtain with your code: a flat tau. If this is related to the initial values of the parameters, how can I find out the right ones to begin? If not, I think this is linked to the use of fmincon. How can I approach this issue?
Thanks in advance
Alberto
Hang Qian (view profile)
Thank you, Andrianos.
Prof. Ghysels once responded to the question you raise. He wrote: “The MIDAS Matlab Toolbox only handles one HF series and recommends forecast combinations as explained in the User's Guide. Having multiple HF series in a single MIDAS regression often runs into nearcolinearity issues which may impair the nonlinear estimation procedure. For that reason Andreou et al. (2013) suggest using one HF series for potentially a large panel of HF data and perform forecast combinations. Some other software packages  such as EViews  allow for MIDAS regressions with multiple HF series.
Andreou, Elena, Eric Ghysels, and Andros Kourtellos. "Should macroeconomic forecasters use daily financial data and how?." Journal of Business & Economic Statistics 31.2 (2013): 240251.”
Andrianos Tsekrekos (view profile)
Excellent work. Thanks for sharing. How would one go about extending the code to multiple highfrequency variables (even just for the umidas option?
Hang Qian (view profile)
Hi Cristian,
The program produces the results shown on the user manual on my Windows x64 computer with MATLAB 2017a. MATLAB Optimization Toolbox needs be installed for numerical maximum likelihood estimation.
Cristian Sandoval (view profile)
Hi there, I hope you are keeping well. I am novice about GARCHMIDAS and I need some support regarding GARCH MIDAS.
Any of you have could replicated the manual's result when the model includes Industrial Production?. I have tried rescaling, changing different option optimization and modifiying gradient, and I always I have had as a result a flat long term volatility.
Hang Qian, kindly gave me a couple of comments, but the problem persist. I employed my data (other macro variables and some realized volatility) and the problem is still there, so I am afraid that the problem is not about the data.
Please, any advice would be useful.
many thanks.
Hang Qian (view profile)
Hi Sebastian,
The GARCHMIDAS program resorts to a numerical optimizer for maximum likelihood estimation. The message “ Solver stopped prematurely” indicates that the solver does not find a maximum point because the maximum number of functional evaluations has reached. There is a namevalue pair 'Options' for tuning the optimizer. For example, we may reset the optimizer like optimoptions('fmincon','MaxFunctionEvaluations',10000), which increases the number of iterations.
Also, MATLAB Optimization Toolbox has update from release to release, and the optimal point found by the solver could vary as well. The results shown on users’ computer may vary.
Best,
Hang Qian
Sebastian k (view profile)
Hi,
Many thanks for the Toolbox. I have tried to run the demo appGARCHMIDAS1.m and it works fine for the fixed and roll window.
But for GARCHMIDAS model with the exogenous regressor I get some error with the solver and fmincon.
“ Solver stopped prematurely”
“fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 3000 (the default value).”
Thus the estimated parameters that I see in Matlab are different than the ones in the Guide on page 37.
I am using Matlab R2016a. Could that be the issue or could it be something else? I have the optimization toolbox installed and I have only tried to run the demo without any alterations.
Br,
Sebastian
Hang Qian (view profile)
Hi mantu,
Yes, it is possible that MATLAB reads date format differently. It uses the system locale to determine the date/time format. The software works with the U.S. date/time format. I am not sure if it could work well with the date formats used in other regions.
mantu (view profile)
Hi Hang, I ve couldnt solve my problem. I dont think there is a problem in matlab code. Is it possible Matlab reads excel date format differently. My excel date format is 'yyyymmdd' but I think matlab reads it like this 'yyyy.mm.dd' and that s because it gives me an error message in my opinion
y = xlsread('nas','B2:B11628');
>> x = xlsread('ind','B2:B536');
>> GarchMidas(y,'Period',22,'NumLags',32,'X',22,'ThetaM',1)
Error using GarchMidas (line 189)
Macroeconomic regressor must be a vector of the same length as y.
Hang Qian (view profile)
Dear hellocate,
Yes, you are right. The macroeconomic variable is calculated as same as RV. Please refer to Eq (3.22) and (3.23) of the User Guide for GARCHMIDAS model specification. For the software, the namevalue pair 'X' specifies macroeconomic data that determines longrun conditional variance. If X is not specified, realized volatility will be used.
hellocate (view profile)
Dear Hang,
Thank you for your excellent toolbox. I have some questions to ask you about GarchMIDAS.In the GarchMIDAS modle,macroeconomic variables include the level and volatility.But in the MATLAB code,It has not been shown. macroeconomic variable is calculated as same as RV.Can you solve my trouble? I will be appreciated if you give me a replyThank you!
Hang Qian (view profile)
Hi lu chen,
As its name suggests, QuasiCorrMatrix is a quasicorrelation matrix in which the diagonal elements have not been normalized to one, because the elements of the matrix are timevarying. Once it is normalized and we add the conditional variance back, it becomes the conditional covariance matrix. Please refer to Eq (3.28) of the User Guide for the definition of that matrix and the normalization method. Thank you.
lu chen (view profile)
Hi Hang:
Thank you for your excellent toolbox.I'm using it do some researchings,but there are some problems which troubles me a lot.I want to get the Covariance matrix ,Is the QuasiCorrMatrix Covariance matrix？if not ,how to get it? and what the QuasiCorrMatrix stand for in the paper of Eric Ghysels? I will be appreciated if you give me a reply!
Hang Qian (view profile)
Hi mantu,
The error message indicates that the length of the regressor is not equal to that of y. It only checked the number of elements in the input arguments by numel(…). You may want to double check your inputs, either by comparing numel(Regressor) and numel(y), or by setting a break point at the line where the error message occurs to see the length of the two inputs in the program.
mantu (view profile)
Hi again Hang, When I use the datas NASDAQCOM and INDPRO in Midasv2.2 on makroekonomik regressor give me this;
Error using GarchMidas (line 211)
Macroeconomic regressor must be a vector of the same length as y.
well time length wasnt the same and I fix it. Also it gives me same error when I use with other datas. thank you
Hang Qian (view profile)
Hi Amar,
That sounds interesting, but the model you described is not MIDAS. It is a new model that requires
your own estimation method.
amar soebhag (view profile)
Hello Hang Qian,
Thank you for uploading this. Can I use MIDAS is the dependent variable has a higher frequency (daily in my case) than the independent variable (quarterly/yearly?)
Thank you again.
mantu (view profile)
ooo ok, thank you Qian you re very helpfull
Hang Qian (view profile)
Hi mantu,
Our GarchMidas MATLAB program supports oneparameter and twoparameter Beta polynomial, using the namevalue pair 'Beta2Para', which is a logical value that indicates twoparameter Beta MIDAS polynomial. Section 3 of the User Guide for MIDAS Matlab Toolbox describes the model. Refer to Equation (3.24) and (3.25) in the user guide. Thank you.
mantu (view profile)
Hi Qian and my economist fellas, I ve solve the matlab but I couldnt figure out how beta lags work in GARCHMIDAS model. I ve tried to use ϕk(ω) beta lag formulate to figure out how does beta lags solve in engleghyselssohn 2013 article but I coudnt find same result on that article. Do you have any idea where did I do wrong on that ϕk(ω) beta lags formulate. Many thanks.
ϕk(ω)=((k/K)^(w11) *(1k/K)^(w21))/(∑(j=1 to K)(j/K)^((w11)) * (1k/K)^(w21) ) → beta lags
Hang Qian (view profile)
Hi Ting XIA,
“parameters sensitive problem and convergence problem” you mentioned exists for many numerical maximum likelihood problems. The numerical optimization routine may fail to converge, as the objective function has saddle points that a optimization routine gets stuck. If you have a license of Global Optimization Toolbox of MATLAB, you may replace FMINCON/FMINUNC/FMINSEARCH (currently used in GARCHMIDAS program) by more advanced global optimization tools.
Ting XIA (view profile)
Hi, Hang.
Thanks for your suggestion.
Resetting the AdjustLag and finetuning the optimization option, such as change solver or MaxIter or TolCon, do not help to fix the parameters sensitive problem and convergence problem.
My sample size is around 4800 (daily data). In case of lossing too much observations, I tried NumLagsCorr value between 5 and 30. However, the ”a b w” still vary according to the NumLagsCorr value. I have several pairs of stock index returns and tried different pairs many times. They simply encounter the same problem.
It confused me whether the exogenous variable matters or computation matters.
While it runs well in Garchmidas with exogenous variable. How it comes wrong in the step2 computation? Step 2 estimation is merely based on the standardized residuals from garch model.
Hang Qian (view profile)
Dear Ting XIA,
Thank you for your interest in our DCCMIDAS functionalities.
“NumLagsCorr” specifies the number of lags in filtering the secular component by MIDAS weights, in the second step estimation of correlation matrix. Though more lags do not increase the number of unknown parameters, more initial observations will be lost by excess lags. In a daymonth aggregation, lags of 30 months lose 660 observations. In that case, estimation might not work as expected when your sample size is moderate. I am not sure if resetting 'AdjustLag' will help in that case.
When some parameters get stuck at the initial value in model setting, and it takes long to compute the results, the most likely cause is convergence problems. There is no guarantee that numerical algorithm will find the maximum likelihood estimator. It could fail sometimes. One may finetune the optimization options by the namevalue pair 'Options', which specifies the solvers and stopping criteria. Also try other initial values. The chance of convergence is larger if the initial values are close to the true values, though we do not know the latter.
Ting XIA (view profile)
Dear Hang,
Thank you for your excellent toolbox.
I come across a problem which troubles me a lot when running the Dccmidas model.
My Dcc estimations (a,b,w) are sensitive to “NumLagsCorr” value. When I use the default number (10), w is larger than 1, while its p value is as large as 0.8. When I find an appropriate one, say 11, making the p value of w zero, but the w equals 1.001 (the initial value in model setting). Does it mean the exogenous variable do not significantly affect the long run component?
However, other NumLagsCorr values which I have tried, say lager than 30, usually fail to be computed out or take a long long long time to compute.
And I have tried other pairs of data, it result most of the same.
How could I fix my problem? Thanks so so much.
Hang Qian (view profile)
Dear Pingjun,
I think multipleperiod forecast can be achieved by setting the namevalue pair 'Horizon'. For example, when it is equal to 2 and we have X data up to 11/01/84, then we could forecast Y value at 01/01/85. If we set 'Horizon' to a larger number, we could forecast Y value at a longer time interval. There is an output argument of the function MIDAS_ADL called OutputForecast, in which the results of forecasts such as Yf and RMSE are stored.
dengpingjun (view profile)
Dear Hang,
Thanks for your reply that gives me a better understanding of the usage of MIDAS_ADL. However, I‘m still a little confused about this function that I don't know how can I use the function 'MIDAS_ADL' for 'hstepahead' forecasting. I read the manual in this toolbox, but I cannot find the corresponding augment associated with 'hstepahead' forecasting. How can I adjust the input augments’ settings of 'MIDAS_ADL' for this purpose.
Hang Qian (view profile)
Dear Pingjun,
'Horizon' refers to the number of (high frequency) lags from which lagged high frequency regressors start. When we put MIDAS_ADL(…,'Horizon',2), the timing convention is that
Reg Y(01/01/85) on X(11/01/84),X(10/01/84),…
That is, there are two month lags of X variable when 'Horizon' = 2.
Of course, there are a variety of data format – some are recorded at the beginning of the month; some are denoted at the end of the month. The best way to see the effects of 'Horizon' is to watch the time frame shown on the screen.
dengpingjun (view profile)
Dear Hang,
Thanks for uploading this excellent toolbox. However, some issues may be in it. In function MIDAS_ADL, the optional arguments, such as 'Horizon', 'XLag' and 'YLag', are not exactly matched with the model. For example,
[DataY,DataYdate] = xlsread('mydata.xlsx','sheet1');
DataYdate = DataYdate(2:end,1);
[DataX,DataXdate] = xlsread('mydata.xlsx','sheet2');
DataXdate = DataXdate(2:end,1);
DataXgrowth = log(DataX(2:end)./DataX(1:end1))*100;
DataYgrowth = log(DataY(2:end)./DataY(1:end1))*100;
DataX=DataXgrowth;
DataY=DataYgrowth;
DataYdate = DataYdate(2:end);
DataXdate = DataXdate(2:end);
MIDAS_ADL(DataY,DataYdate,DataX,DataXdate,'Xlag',4,'Ylag',2,'Horizon',2,'EstStart',EstStart,'EstEnd',EstEnd,'Polynomial','Almon','Method','fixedWindow','Display','full')
the partial results as following:
Mixed frequency regression time frame:
Reg Y(01/01/85) on Y(10/01/84),Y(07/01/84),X(11/01/84),X(10/01/84),...,X(08/01/84)
Reg Y(04/01/85) on Y(01/01/85),Y(10/01/84),X(02/01/85),X(01/01/85),...,X(11/01/84)
...
Reg Y(01/01/09) on Y(10/01/08),Y(07/01/08),X(11/01/08),X(10/01/08),...,X(08/01/08)
in fact, the correct result should be:
Mixed frequency regression time frame:
Reg Y(01/01/85) on Y(07/01/84),Y(04/01/84),...
Reg Y(04/01/85) on Y(10/01/84),Y(07/01/84),...
...
Reg Y(01/01/09) on Y(07/01/08),Y(04/01/08),...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if not so, what is true meaning of 'Horizon' and what is difference between 'Horizon' and h that in 'hstepahead'? Can you give me a reply?
Best regards
Pingjun Deng
Hang Qian (view profile)
Hi tr206,
'thetaM' is an optional input argument, as a namevalue pair, of the GarchMidas function.
The syntax is like GarchMidas(y,'thetaM',1);
It is a logical value that indicates not taking squares for the parameter theta and m in the longrun volatility component. The default is false (they are squared). So if those two parameters are allowed to be negative, reset the namevalue pair 'thetaM' to true.
tr206 (view profile)
Hi Hang,
I am running the GarchMidas for a macroeconomic variable and I sometimes get the warning
Warning: Reset the Namevalue pair 'thetaM' to true, so that theta and M could
be negative.
Must I set 'thetaM' to 1 or is this done by Matlab? What does that mean and what must I do?
Hang Qian (view profile)
Hi Alberto,
The GarchMidas programs uses numerical methods for maximum likelihood estimation. When the optimization program failed to find the maximum point, you are likely to get tau equal to a fixed number. You may want to try to adjust the optimization options. There is a namevalue pair 'Options', where you can change the solver and tune the solver. Also, the initial values sent to the optimization program may have an impact on the results. The software has namevalue pairs 'Mu0', 'Alpha0', 'Beta0', etc. for resetting the initial values. As for the lag order selection, you may profile the results under different lagorder scenarios. If you have a large sample size, you may try more lags. It does not increase the number of parameters, but more initial observations will be consumed.
Alberto Grassi (view profile)
Dear Hang,
I am coming across some troubles while I'm comparing the Garchmidas model with different data. When i use yours (NASDAQCOM from 1971 to today) everything goes well, when I use mines (DOWJONES from 1950 to today) too, but when I try to use my data from the same day of yours I obtain good results only using K=36, otherwise I always get tau equal to a fixed number for all the days of the sample. Can you give me some instruction on how to select K according to the data? Is there something I can study to understand? (by now I have only written Ghysels' paper and the pdf that explain how to use the codes, but their don't explain what I am looking for).
Thank you in advance,
Best regards
Alberto Grassi
Hang Qian (view profile)
tr206  In the toolbox, there is a utility function ForecastCombine.m, which handles forecast combination of ADLMIDAS regressions. It takes the forecast results from multiple models, and assigns them weights by MSE, AIC or BIC, and then does the averaging. I think you have to write some of your own programs for other MIDAS models – there are so many varieties and generalpurpose software cannot cover them.
tr206 (view profile)
Dear Eric,
Thanks a lot for your reply. This makes sense and I like the line of argumentation. However, I am not very familiar with writing such functions myself in Matlab. Are there any functions which I can use to implement Andreou et al. (2013) or similar functions to do that?
Eric (view profile)
Dear tr206:
The MIDAS Matlab Toolbox only handles one HF series and recommends forecast combinations as explained in the User's Guide. Having multiple HF series in a single MIDAS regression often runs into nearcolinearity issues which may impair the nonlinear estimation procedure. For that reason Andreou et al. (2013) suggest using one HF series for potentially a large panel of HF data and perform forecast combinations.
Some other software packages  such as EViews  allow for MIDAS regressions with multiple HF series.
Andreou, Elena, Eric Ghysels, and Andros Kourtellos. "Should macroeconomic forecasters use daily financial data and how?." Journal of Business & Economic Statistics 31.2 (2013): 240251.
Hang Qian (view profile)
Hi tr206,
Yes, you can combine the forecast obtained from different models by the MSE. You may write some small program to get the MSE from your estimate GARCHMIDAS model and then combine them manually.
tr206 (view profile)
Hi Hang,
Thanks for your reply. Yes, there are many predictors such as GDP growth, inflation CCI etc. and I would like to incorporate all of them in one GarchMidas model. Nevertheless, you are saying that forecast combination of different models could be a reasonable workaround? Are you refering to FORCASCOMB in Matlab?
Ruiting Chen (view profile)
Hi Sir, I have sent you a email, did you receive it? Because it's my first time use this website, I really hope I didn't have misoperation.
Hang Qian (view profile)
Hi tr206,
The program only supports one highfrequency predictor. If you have many predictors, consider forecast combination of different models. If you would like to exclude the constant or other terms, one way is to adapt the code. For example, in GarchMidas.m there is a subfunction fML, in which the unknown parameter vector is allocated to structural parameters. You may add or subtract components from there.
tr206 (view profile)
Hi Hang,
your code is only for one independent variable but I need to do this for 5 or 6 variables. Can I somehow do the analysis for multiple variables?
I think I could simply add the taus of the individual variables but then I guess I will have a problem with the constant in the tau formula. Can I somehow exclude the constant from tau?
Hang Qian (view profile)
Hi Amor,
Thank you for your comments. Could you please send me an email about your code and sample data? Processing date/time is difficult in MATLAB, and the program may not correctly recognize your date format and match the two series.
AmorAniss Benmoussa (view profile)
Hello, I think there is an error in the code. For example, for a twoquarter forecast in advance if the low frequency series is quarterly with a monthly series at high frequency, the low frequency data does not go back sufficiently. I tried it with the UMIDAS specification.
Amor Aniss Benmoussa
Hang Qian (view profile)
Hi Alberto,
The paper you mentioned used different software/programs, and I wrote a MATLAB program GarchMidas last year, just to illustrate the idea of GARCHMIDAS models. It probably will not replicate everything seen in the paper. The parameters are estimated by numeric search for optimal values, so you may experiment if the starting values and the optimization options affect your results. Sometimes there are convergence issues. It is a good idea to look at the codes, as you noted in line 206. If you find better ways to estimate the model, feel free to modify the program. Also let me know if you have suggestions for improving the software. Thank you very much.
Alberto Grassi (view profile)
Hello Hang,
I'm trying to replicate the paper "Stock Market Volatility and Macroeconomic Fundamentals" through your toolbox. I am using only dowjones data for the part without the macroeconomics and everything works well, but when I go for the part with industrial production I obtain the figure (3) where the blue line is completely flat. This with my data and also with yours. Also I have a signal of error in line 206 of your code, but I can't understand why. Can you please help me? Thanks in advance.
Hang Qian (view profile)
Hi Mantu,
In the toolbox, there is a garch midas function: GarchMidas(y, name,value,...) . The user guide in the package describes how to use it.
mantu (view profile)
Hello Hang. @IHSEViews told me on twitter to I can use garch midas model in this program with higher frequency dependent variable. Can I use it I m looking for articles and user guide like crazy but I cant see anything. Also I ll use financial series not macroeconomic variables. My models will be with monthly dependent variable and quarterly independent variables. thanks
Ting XIA (view profile)
Hello Hang
Thank you for your advice “Also consider setting the namevalue pair 'LogTau' if the regressor X is other than the realized volatility” (on 23 Nov 2016). It settles my problem.
When the regressor X is not the RV, setting “LogTau ” to 1 seems to be essential in most circumstances.
Thanks again.
Hang Qian (view profile)
Hi Anup,
Matlab 2011b is an old version that does not support some namevalue pairs of the inputParser class. You may try to replace addParameter by addParamValue. I think the syntax is the same. However, there are updates to the optimization tools in recent years. I am not sure if the codes yield good results under older version of MATLAB.
czbx51 (view profile)
Hi Hang，
Thank you so much! I have solved my problem.The data Y begins ealier than the suggested start date, which is determined by X and the lags. Without exoreg, the program works well and reports" Start date cannot be earlier than 24Mar2003 due to lagged regressors. Reset start date to 24Mar2003 ". But it cannot run with the exoregs. I cut Y to the suggested starting date and it works well.
Anup Chowdhury (view profile)
Dear Qian,
Many thanks for uploading this fantastic resource. I am using Matlab2011b version and getting following error messeages:
For ADLMIDAS:
No appropriate method, property, or field addParameter for class inputParser.
Error in MIDAS_ADL (line 201)
parseObj.addParameter('Xlag',9,@(x)validateattributes(x,{'numeric','char'},{},callerName));
For GARCHMIDAS:
Undefined function 'addParameter' for input
arguments of type 'inputParser'.
Error in GarchMidas (line 146)
addParameter(parseObj,'X',[],@(x)validateattributes(x,{'numeric'},{'2d'},callerName));
Can you please help me to fix these. Many thanks again for your nice cooperation.
Anup
Hang Qian (view profile)
Hi czbx51,
You may take a look at the example file appADLMIDAS4, in which there is an example of running the program with exogenous regressors. In that example, I saw ExoReg and Y are both column vectors with the same length. To process exogenous regressors, make sure the time series is a column vector with long enough length (taking the presample truncation caused by Xlag, Ylag into account as well). I am not sure why there is an error when you run the codes, but you may also set a break point at 297. Ideally, you would see both EstY and Mimic.EstY are two column vectors of the same length. Otherwise, try if it helps to remove that line (which only does some error checking). Also, check the date format, which varies from country to country. If MATLAB fails recognize your date format correctly, then the program will not run properly as well.
czbx51 (view profile)
Hi Hang,
Thank you so much for this toolbox, it really helps a lot.
However, I cannot apply the exogenous variable into the ADL_MIDAS program. Matlab reports the bug as'错误使用 ~= 矩阵维度必须一致。MIDAS_ADL (line 297) if any(EstY ~= Mimic.EstY)', saying the dimension of the matrix is not the same. However the ExoReg data is exactly same date and length with the low frequency dependent variable Y, and it doesn't have any NaN value. Can you tell me what's wrong with this mimic part? Thank you!
Hang Qian (view profile)
Hi Ning,
The toolbox supports multistep forecast. If you run the example file appADLMIDAS1.m. There are four outputs of the main function MIDAS_ADL. The first one is the forecasted values after the estimation sample, and the fourth output variable is the outofsample forecast after DataY is exhausted.
ning xu (view profile)
Hi Hang,
First, Thanks for uploading this toolbox! Especially the ADLMIDAS is very useful to me.
I wonder how do you perform hstep ahead forecast using this toolbox? I have referred to the MIDAS user guide for the multistep forecast, but I still don't understand how to operate. Can you give me an example?
Thank you.
Hang Qian (view profile)
Hi Chen Ryan,
It seems that the MATLAB Optimization Toolbox is not installed on your computer. The DccMIDAS uses a numeric optimization function FMINCON for maximum likelihood estimation. When that function is not available, it is supposed to switch to another optimization function FMINSEARCH in the core MATLAB. However, there was a bug that FMINSEARCH was not invoked properly. I just fixed the problem and the updated files should work in the absence of Optimization Toolbox. Thank you very much for reporting the issue!
Chen Ryan (view profile)
Hi Hang,
Thank you for the nice toolbox. Whe I ran the code of the GARCHMIDAS model, no problem emrged. When I ran the DCCMIDAS model ,however, the follow error pops up:
警告: FMINCON failed... Switch to FMINSEARCH.
> In DccMidas (line 386)
In appDCCMIDAS1 (line 43)
错误使用
DccMidas>@(params)nansum(fML(params,Resid,CrossResid,ResidCorr,period,nlagCorr,adjustLag,zeroLogL,beta2Para,rollWindow))
输入参数太多。
出错 fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
出错 DccMidas (line 387)
estParamsStep2 = fminsearch(myfun,params0,[],[],[],[],lb,ub,[],options);
would you pls help to point out where the prolem lies? Thanks a lot.
Hang Qian (view profile)
Hi Yu,
The codes only support one predictors, either the realized volatility or a macroeconomic variable. You may consider forecast combination by running two models. If you would like to put more than one macro variables in the regression, you will have to modify the codes. There is a subfunction [logL,...]=fML(params...) which computes the log likelihood. So you may want to expand the length of params and then add those macroeconomic variables that contribute to the log likelihood.
Hang Qian (view profile)
Hi Sebastian,
When the MIDAS component is suppressed (Set Xlag=0), the parameters in the Beta polynomials, etc, become unidentified. Refer to the Davies problem. The codes do not support regression without high frequency regressors. If you really want to run an AR(p) without highfrequency predictors, you might extract the regressors and response variables from the output variable MixedFreqData, in which there are variables like EstY, EstX, EstLagY. By extracting those regression data, you could call the MATLAB function regress, fitlm or arima so as to run a AR(p) model. Then you could still compare R^2 of the two models.
Yu (view profile)
Dear Hank,
I want to estimate a twocomponent(or more components ) GARCHMIDAS model, e.g., two or more macroeconomic fundamentals once in a GARCHMIDAS model.
Is it possible?
Thank you very much!
Sebastian Bentele (view profile)
Hi Hang,
for my research I would like to compare my results of the MIDA model to an Ar(p) process. I tried to estimate and forecast the ARprocess with the MIDAs toolbox as it is described in the manual (Set Xlag=0) but everytime I get an error: "Error using *
Inner matrix dimensions must agree".
How may I solve this problem?
Thanks in advance.
jianjian lyu (view profile)
Hang Qian (view profile)
Hi Johann,
I am sorry but there is no such magic function that could identify the appropriate starting values for numeric optimization.
johann guenkel (view profile)
Hi Hang,
I have tried to increase the number of iterations but I cannot eliminate the problem. Is there a function I can use to identify the appropriate starting values?
Hang Qian (view profile)
Yes, increasing the number of iterations may help convergence. For GarchMidas.m and DccMidas.m, there is a namevalue pair called 'Options', in which you could specify the number of iterations for the numeric solver. For MIDAS_ADL.m, that option is not available, but one may step into the internal functions (in the private folder) such as bnls_adl_new.m (for Beta polynomials) and modify the variable ‘options’. Refer to MATLAB documentation page for optimoptions.
johann guenkel (view profile)
Hi Hang,
another idea that just came into mind is to increase the number of iterations. Sometimes I get the message that the solver stopps prematurely as by default the number of iterations is 3000. Do you think it helps to increase the number of iterations to 10000? How can I adjust the number of iterations?
johann guenkel (view profile)
Hi Hang,
Thanks for your reply. If I get it right, the warning indicates that the model does not converge. In some cases I fiddled with the starting values and it now works for most variables. However, there are still few cases that do not work must I change the optimization method in this case? How can I do that in the code?
Hang Qian (view profile)
Hi Johann,
When we resort to numeric methods for likelihood maximization (squared residual minimization), it may or may not converge to a local optimal point. When it fails to converge, the warning message is likely to pop up. In that case, we will need to experiment on different starting values and alternative optimization methods.
johann guenkel (view profile)
Hi Hang,
I want to analyse the relationship between stock index returns and macroeconomic variables such as inflation or GDP growth. In some cases the midas analysis returns good results i.e. I get significance and no warning message. However, in some cases I get the warning
Warning: Covariance matrix of estimators cannot be computed precisely due to
inversion difficulty.
In my code, I assumed the starting values given by default. I neither changed them nor did I determine my own starting values. What does that mean? How can I avoid this message?
Hang Qian (view profile)
Ting 
The namevalue pairs W0, Alpha0, Beta0 control for the initial parameters for MLE, while ZeroLogL controls for the initial observations. You may try both. Also consider setting the namevalue pair 'LogTau' if the regressor X is other than the realized volatility.
Ting XIA (view profile)
Hello Hang,
Thanks for your reply.
I checked my X data, there was no abnormal values, and its statistical characteristic seems normal, I changed other X data, it returned the same.
You mean reset the starting values, is it to reset W0, Alpha0, Beta0 which are used in MLE OR to set the ‘ZeroLogL’ to, such as in the input Syntax like ‘ZeroLogL’,[1,2] ?
I tried both, it returned the same. I also tried to set the ‘Options’, it seemed a little complex and didn’t get it work well yet, does it matter?
Regards.
Hang Qian (view profile)
Ting  Yes, the data might have some problems, for example excessive amount of missing values, and the log likelihood at the initial parameter values is not finite. You may try some other starting values. If all the reasonable starting values return infinite/NaN log likelihood, then the data are possibly have some problems.
Alex  You may contact Eric for codes request.
Ting XIA (view profile)
Hi Hang Qian,
Thanks for you great toolbox. I just started with GarchMidas model, it worked well. But when I tried my data, using a macroeconomic variable (X) to model GarchMidas, the X is monthly data, it replied this problem:
Warning: FMINCON failed... Switch to FMINSEARCH. Error
Message: Objective function is undefined at initial
point. Fmincon cannot continue.
>In GarchMidas (line 303)
Is it my data(X) problem? Could you give any suggestion?
Thanks in advance.
Alex L (view profile)
Excellent tool. For my research I am very interested in the "mixed frequency VAR model" programs (classical approach), based on Ghysels (2016). Will they be included in the toolbox? I read in the userguide that they can be available upon request.
Thank you very much for sharing the toolbox.
Alex L (view profile)
Sam Rolland (view profile)
Thank you Hang
It was my date configuration for the Ydata. I had chosen different representations of quarterly data. Eventually worked with a 1 lead configuration.
Hang Qian (view profile)
Hi Sam,
If your model does not include lagged autoregressive Y terms, you may try to append some values to the end of the Y series. If there are sufficient amount of X data, OutputForecast might produce some outputs.
Sam Rolland (view profile)
Hello Hang
I am trying to run a basic nowcast (Horizon= 2) variation of the model, using MIDAS1 My YData goes to 20160630, and my XData goes to 20160831. However, when I try and run the model at EstEnd: 20160630, there is no OutputForecast produced, and when I take it back (say, a year), it only goes to my last YDate. Why would this be, and where should I be looking to make it that I can produce a forecast for 20160931?
Thanks in advance
Hang Qian (view profile)
Hi Trung,
If you would like to impose constraints on the coefficients, you will have to step into the codes and make changes. You may go to bnls_adl_new.m and search for the unconstrained numeric optimizer 'fminunc', and replace it by the constrained optimizer 'fmincon' with the desired constraints.
Trung Le (view profile)
Hi Hang Quian
Thanks for the great toolbox.
Currently, I am working on the MIDAS_ADL function with the Beta polynomial specification. I would like to put a constraint on Beta1 of Beta polynomial to 1 to ensure the monotonic pattern of weight. How could I do that in the toolbox?
Thanks
T
Ghulam Abbas (view profile)
Hang Qian (view profile)
Yes, you may need to modify the codes. When we combine models in forecast, we need weights, which are proportional to the inverse of the forecast MSE. Both X and y data are needed to compute MSE.
Sam Rolland (view profile)
Hi Hanq Qian
Thank you for this, I understand the theory behind it. One further question, to perform an extended forecast to a point where DataX is exhausted, am I correct in saying that appADLMIDAS3.m requires alteration to include the function 'ExtendedForecast.m' to perform a true outofsample forecast? I a struggling to understand the 'Combined Forecast by xxx' numbers and how they only go to the end of the DataY sample size.
Hang Qian (view profile)
Prof. Ghysels added comments on Sam’s question: “While it is in principle possible to estimate MIDAS regressions with various HF regressors, it is preferred to use forecast combination techniques as HF regressors often tend to be highly colinear, which causes estimation problems. Nevertheless, some packages such as EViews have implemented MIDAS regressions with multiple HF regressors. It is a possibility but has to be applied with caution in many practical applications.”
Hang Qian (view profile)
Hi Sam,
Basically we estimate two or more models separately and then combine the forecast results by ForecastCombine(Output1,Output2). The example file appADLMIDAS3.m illustrates forecast combination.
Sam Rolland (view profile)
Hello Hang Qian
I am new to this toolbox, although it appears to be very well constructed.
Potentially a silly question, but how does one add a second variable to then use in ForecastCombine.m? It mentions it "By adding the industrial production as a second high frequency series", but does not elaborate.
Can you assist please?
Hang Qian (view profile)
Hi Ruiru,
I do not have codes on your MIDAS_CJ model. The licence of the toolbox gives you permission to do modifications on the original codes. It is fine to adapt the codes so it is more suitable for your own studies.
Ruiru Guo (view profile)
Hello,Qian,thank you for the great toolbox! I am now trying to apply a MIDAS_CJ model where I seperate the continuous part and the jump part in the high frequency data. I am wondering if I could do some change to your original function MIDAS_ADL to realize it or it is better for me to write a new function on MIDAS_CJ? Or do you have any related code on MIDAS_CJ? Thank you so much!
Hang Qian (view profile)
Hi Chen Ryan,
It is possible that the numeric optimizer fails to find an optimum. I do not have a good solution, but you may experiment different starting values by setting the namevalue pairs. Also, turn on 'Gradient' and try to set the FMINCON 'Options' and see how alternative numeric optimization algorithms work.
Chen Ryan (view profile)
Hello,Qian,thank you for the nice toolbox. I have tried to use the code you provided and they all work just fine. However, when I tried to implement more than one macroeconomic variables in GARCHMIDAS and DCCMIDAS models through constructing a linear model x = f(X,theta) that incorporates the macroeconomic variables, I failed numerous times. Would you like to be a little more specific on how to implement more than one macroeconomic variables in GARCHMIDAS and DCCMIDAS models? Thank you!
Jason (view profile)
hi Hang Qian
I have solve the problem of the “corr" function you are right there is another "corr" function ,I did not find it is misused .
thank you
Jason (view profile)
HI Hang Qian
I am using 2014a matlab ,is it possible that the error is caused by the version difference?
thank you
Hang Qian (view profile)
Hi Jason,
Thank you for your interest in DCC MIDAS. The codes work on my computer. One reason that it might fail on yours is the "corr" function is overloaded by your own. The error message seemed to indicate that "corr" is not the original MATLAB function.
Jason (view profile)
Hi Hang Qian
I am using the DCCmidas command. I follow the
the code in the user guide
options = optimoptions('fmincon','Algorithm','activeset');
[estParamsStep1,¬,estParamsStep2,¬,Variance,LongRunVar,CorrMatrix,LongRunCorrMatrix]...
= DccMidas(Data,'Period',20,'NumLagsVar',36,'NumLagsCorr',144,...
'options',options,'ZeroLogL',1:3600,'mu0',0.001);
CorrMatrix = reshape(CorrMatrix,9,nobs)';
LongRunCorrMatrix = reshape(LongRunCorrMatrix,9,nobs)';
and the data is from the toolbox, NASDAQCOM, DEXJPUS, DGS10 .
but when I execute the code ,their is running error, the warning is
"错误使用 pe (line 54)
输入参数的数目不足。
出错 corr (line 3)
k=x(1)*price+x(2)*fund+x(3)*pe
出错 DccMidas (line 489)
sampleCorr = corr(Resid);
I can not get the correlation varience ,the code is just exactly the same as in the userguide .
thank you .
Hang Qian (view profile)
Hi mael Blanchet,
When that warning message shows up, the most likely reason is that the model fit is poor and the optimizer gets trapped somewhere other than the maximum point. In that case, usually we have to make adjustment on the model specification.
mael Blanchet (view profile)
Hello,
Thank you for toolbox.
However, I have a problem with the Maximum Likelihood Estimator. The software displays a warning message: "Warning: Covariance matrix of estimators cannot be computed precisely due to inversion difficulty.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate."
Do you have any advice?
thank you.
Hang Qian (view profile)
Hi AmorAniss,
The periods are in OutputForecast.YfDates. Weights such as RMFE and others are also retrieved from OutputForecast. Refer to the help header of the corresponding functions for details. Thank you.
AmorAniss Benmoussa (view profile)
Hello , how I can know the period for estimating weight for the combination of forecasts with DMSFE or MSFE approach? For exemple the page 29 in the user guide.
thank you
Stephen Zhang (view profile)
Hi Hang Qian,
Thank you very much.
Stephen
Hang Qian (view profile)
Hi Stephen,
When 'Beta2Para' is set to be false, it fixes one parameter equal to one and varies the other parameter, so that the weights are monotone decreasing. Basically, the default behavior of the software is as you described.
For DccMidas, residuals can be changed if you replace Line 274283 by whatever estimation method.
Thank you.
Stephen Zhang (view profile)
Hi Hang Qian,
Thanks a lot for the toolbox. I am working on the GarchMidas and DccMidas and I have two questions:
1: For GarchMidas, when setting 'Beta2Para' to be true, we have two weights, w1 and w2. Based on Asgharian, How and Javed, 2013, its better to set w1 fixed equal to 1, and vary w2. Can we do this with the toolbox?
2: For DccMidas, the 2nd step estimation(the dcc part) is based on the residuals of the GarchMidas, can we keep the second part but change the residuals to be from the basic Garch model?
Thank you for your concerns. I really appreciate your work on the toolbox.
Best,
Stephen Zhang
chengyuan Ai (view profile)
Hang Qian (view profile)
Hi luis,
The date matching algorithm is not perfect, and it could fail in some cases. You may try to append zero values to the end of the series and make them look as if they were estimation data points. This might help you if the program correctly aligns the estimation data. Also try to format your dates and data in the same format as those in the example file. They are so many ways to write down calendar dates, and I am not sure which format works better than other formats.
luis gomez (view profile)
Hello:
I am not able to get the "Extended Forecast". In the subroutine there seems to be something wrong when calling "MixFreqData" because the structure I get back from it does not have the padded "Y" or the correct "X". I have quarterly data till 2016Q1 and monthly till march 2016 and I want to forecast 2016Q2. I'd really appreciate your help.
Regards
LMGZ
Test Topi (view profile)
Dear Hang Qian,
Dear Eric,
many thanks for your responses.
Regards,
Topi
Eric (view profile)
Dear Test Topi:
I'd like to add to Hang's reply that the Engle, Ghysels and Sohn (REStat, 2013) paper suggests to profile the likelihood function to decide on the lag structure. Hang's reply is absolutely correct. If one wants to decide on lag length and also the aggregation level of say the RV measures in the long run component  then profiling is a good idea. See the aforementioned paper for further details
EG
Hang Qian (view profile)
Dear Test Topi,
'NumLagsVar' specifies the number of lags in filtering the secular component by MIDAS weights in the first step estimation. In term of parameter estimation, there is no penalty of many lags, except that some initial values will be lost. It should be fine if the lag length is long enough to make the weights vanish to zero.
'NumLagsCorr' specifies the number of lags for the second step estimation of correlation matrix. The number of parameters does not increase, so a long lag length should be fine provided that there are sufficient amount of observations.
Test Topi (view profile)
Dear Hang Qian,
many thanks for the quick response. However, I have one last question, hope is not to clumsy: is there a method in order to determine the optimal values for 'NumLagsVar' and 'NumLagsCorr'?
Thanks in advance.
Hang Qian (view profile)
Dear Test Topi,
The DCC MIDAS codes support an arbitrary number of series. Just provide a Tbyn matrix input to the function DccMidas(...). The output variables CorrMatrix and LongRunCorrMatrix should be nbynbyT. Of course, you might want to adapt the demo scripts appDCCMIDAS1 when you plot the results. For example, Line 44 and 45 can be reshaped as
CorrMatrix = reshape(CorrMatrix,n^2,nobs)';
LongRunCorrMatrix = reshape(LongRunCorrMatrix,n^2,nobs)';
Test Topi (view profile)
Dear Hang Qian,
many thanks for the DCC MIDAS code. However, I wonder if it is possible to change the trivariate code for DCC MIDAS in order to estimate a bivariate DCC MIDAS model? Should I replace the output arguments for CorrMatrix and LongRunCorrMatrix?
Eric (view profile)
Dear Raphael:
In the ADLMIDAS model one typically selects the Ylag using information criteria such as BIC  see e.g. Andreou, Ghysels and Kourtelos (JBES, 2013). For the Xlag, one typically uses a long enough lag such that the weights vanish to zero. The only downside of having too many lags is the loss of initial values at the start of the sample. With MIDAS polynomial there is no penalty in terms of parameter estimation when adding lags since the hyper parameters stay the same. Of course, that is not true with UMIDAS or MIDAS with stepfunction  in which case one uses again information criteria
Raphael Zagaglia (view profile)
Hi, I would like to know what is the procedure to choose the Ylag and Xlag in the model ? Is there any test to figure out which value must I use ?
Thanks in advance.
Hang Qian (view profile)
Hi Hafize,
When we see the estimated covariance matrix is not positive definite in numerical maximum likelihood or nonlinear least squares, some causes are: 1) some parameters are not individually identified; 2) the numerical optimizer does not find a local maximum or minimum point; and 3) the data is not suitable for the proposed model. Some possible solutions: 1) try a more parsimonious model; 2) transform the data, either in the statistical or economic sense; and 3) change the starting values for numerical optimization and consider alternative solvers. Good luck!
Hafize (view profile)
Hi Hang Qian,
Many thanks for the matlab code. I want to estimate monthly variance of returns using daily returns, but when I run the code, I get a warning saying that the covariance matrix is not positive definite and that's why get NaN for the standard deviations and tvalues of the beta1 and beta2 parameters. Now I know that this can be a result of variables which are highly correlated (multicollineairty), but I have no idea how I can solve this, can you help me out?
Hafize
Hang Qian (view profile)
Hi Joyce,
The codes you are running are different from those used in the original paper, so it can only replicate (or nearly replicate) a subset of results in the paper. The codes treat parameters symmetrically among equations and do not impose crossequation constraints (i.e., some parameters are shared by multiple equations). It does not get the result of dcc=2. However, you can adapt the codes to impose constraints by modifying the subfunction fml(...) in line 526 – 683. Basically, you may reduce the length of the variable "params" and allocate it to various equations in the DCCMIDAS regression.
Joyce L (view profile)
Hi!
Thanks a lot for this matlab package.
I am studying DCCMidas model and trying to replicate the empirical part of Colacito et al. (2011).After reading the userguide,I try to set the "MorePara"(DccMidas.m) to 1 and then I get a1 a2 a3&b1 b2 b3.Is this the result of DCC=3?
And I wonder if there is a way to get the result of dcc=2 using this packages?
Really sorry to bother you.
Thanks in advance.
Joyce
Hang Qian (view profile)
Hi Daisy,
Double check your data and make sure all the dates are properly recorded. The MATLAB internal function datevec throws an error message "Cannot parse date 0" when some dates look like a string of zero, say datevec('0'). Also, some users cannot run the program if their operating system locale is not US English, when MATLAB or EXCEL interprets the date string in a different way.
Daisy Doan (view profile)
Hi Hang,
Thank you very much for pointing out the problem. I have adjusted my data to a balanced one with the same number of daily obs (19) in each month. However, when running MIDAS_ADL, I encountered the following errors:
Error using datevec (line 276)
Cannot parse date 0.
Error in MixFreqData (line 99)
DataYdateVec = datevec(DataYdate)
do you think explicitly specifying the format of the input string as'mmddyyyy HH:MM:SS' will solve the problem?
Below is a sample of the data for Y
DATE VALUE
01/31/1974 0.006483
02/28/1974 0.003119
03/31/1974 0.021241
and for X:
DATE VALUE
01/02/1974 3.67E06
01/03/1974 0.000474398
01/04/1974 7.40E05
01/07/1974 6.41E05
Hang Qian (view profile)
Hi Daisy,
Dailymonthly aggregation is unbalanced, and I am not sure if the program’s datadate conversion routine can work properly in that case. However, you may try Xlag = 22 so as to approximate dailymonthly aggregation. Does the program generate an error message or produce unreasonable results? If the program can still run, you may check the mixed frequency regression time frame displayed on the screen. It shows how the program matches y with X. Also, the output variable MixedFreqData will display the matched y and X matrices, based on which the nonlinear least squares are run. Good luck.
Daisy Doan (view profile)
Hi Qian,
thank you for the MIDAS program. I try with monthly and daily data but it does not seem to work.
Here is the sample of my data:
Monthly data:
DATE VALUE
01/31/1974 0.006483
02/28/1974 0.003119
03/31/1974 0.021241
Daily
DATE VALUE
01/02/1974 3.67E06
01/03/1974 0.000474398
01/04/1974 7.40E05
01/07/1974 6.41E05
and my codes:
[DataY,DataYdate] = xlsread('mydata1.xlsx','sheet1');
DataYdate1 = DataYdate(2:end,1);
datadatesformat1='dd/mm/yyyy';
DateYnum=datenum(DataYdate1,datadatesformat1);
datadatesformat2='mm/dd/yyyy';
DataYdate=datestr(DateYnum,datadatesformat2);
[DataX,DataXdate] = xlsread('mydata1.xlsx','sheet2');
DataXdate1 = DataXdate(2:end,1);
DateXnum=datenum(DataXdate1,datadatesformat1);
DataXdate=datestr(DateXnum,datadatesformat2);
Xlag = 0;
Ylag = 0;
Horizon = 1;
EstStart = '01/01/1989';
EstEnd = '01/01/2010'; % to match with Baker and Wurgler's period for investment sentiment.
Method = 'fixedWindow';
[OutputForecast,OutputEstimate,MixedFreqData,ExtendedForecast] = MIDAS_ADL(DataY,DataYdate,DataX,DataXdate)
[OutputForecast1,OutputEstimate1,MixedFreqData,ExtendedForecast] = MIDAS_ADL(DataY,DataYdate,DataX,DataXdate,...
'Xlag',Xlag,'Ylag',Ylag,'Horizon',Horizon,'EstStart',EstStart,'EstEnd',EstEnd,'Polynomial','beta','Method',Method);
Hope you can shed light into my problem. Many thanks.
Daisy
ququxi (view profile)
Hi Hang Qian,thank you for your work about MIDAS model! But when I run the data of China, I find the function doesn't converge to global optimal point!So I want to know if we can use simulated annealing algorithm to solve this problem with linear constraint!
Hang Qian (view profile)
Hi EMEL,
It appears that your MATLAB does not recognize the ‘private’ folder. It might be caused by some global preference that overloads the default filesystem precedence. You may try the program on another machine. Also, you may consider dragging all the files out of the ‘private’ folder and place them into your current folder, or adding the folder on your MATLAB search path. Good luck!
EMEL ODABASI (view profile)
Hi Hang Quian,
First of all many thanks for your sharing. I am a very new user of Matlab. Before uploding my own data in the toolbox, I tried to run programme. But It gives error as follows:
Undefined function or variable 'bnls_adl_new'.
Error in MIDAS_ADL>MIDAS_Estimate (line 462)
Results = bnls_adl_new(y,x,numofparams,output_type,polyconstr);
Error in MIDAS_ADL (line 315)
OutputEstimate = MIDAS_Estimate(EstY,EstX,EstLagY,EstXdate,polynomial,stepfun,almonDegree,nExoReg,ylagVec);
Error in appADLMIDAS1 (line 40)
[OutputForecast1,OutputEstimate1,MixedFreqData,ExtendedForecast] = MIDAS_ADL(DataY,DataYdate,DataX,DataXdate,...
How can I correct this error to obtain the results?
Thanks in advance
EMEL
Hang Qian (view profile)
Hi Xiaojun,
Though the software supports a single macroeconomic variable, the GARCHMIDAS with a single index series indeed could be a function of multiple macro series.... x = f(X,theta), where f is a linear function and X a set of macro series. The parameters theta were estimated along with the rest of the model. You will have to modify the codes and insert those macro series in the likelihood function. In the subfunction fML(...) starting from Line 432, you may replace the scalar theta0 by a vector theta0 and then add the macro series in that subfunction. It needs some coding work, but the model with multiple macro series is valid. You may consider the similar for DccMidas as well.
Yes, estParamsStep1 is 6byn estimated parameters for [mu;alpha;beta;theta;w;m] obtained from univariate GARCHMIDAS models
Chu xiaojun (view profile)
Hi Hang Qian,
First of all thanks for the toolbox.
When I run GARCH MIDAS, I find only one macroeconomic variables X is supported. If I want to use N macroeconomic variables, i.e., X is TxN, how could it be implemented?
Is it possible with DccMidas code to run GARCH MIDAS with N macroeconomic variables?
Is the estParamsStep1 GARCH MIDAS result?
Thanks
Xiaojun
Hang Qian (view profile)
Hi Aniss,
The codes address one high frequency regressor. In your case, one quarterly variable with one or more yearly variables. Thank you.
AmorAniss Benmoussa (view profile)
Hello,
I have a very quick question. The code you provide is it enough to make a general MIDAS regression with annual data (low frequency) and quarterly (high frequencies) and also to do with a combination of quarterly indicators ?
Thank you!!
Aniss
Hang Qian (view profile)
Hi KK Chen,
The MIDAS toolbox supports multiple low frequency regressors. Users may specify the namevalue pairs 'ExoReg' and 'ExoRegDate', where the former is a matrix of lowfrequency exogenous regressors and latter is a vector date of those regressors. There is a toolbox demo file appADLMIDAS4.m that illustrates how to include exogenous predictors in MIDAS regression.
Currently the toolbox handles a single high frequency regressor. Users may consider forecast combination if there are multiple high frequency regressors. Forecast combination might yield more robust prediction results. The toolbox demo file appADLMIDAS3.m shows an application of forecast combination.
Thank you!
KK Chen (view profile)
Hi Qian,
May I know if the MIDAS function supports multifactors of low frequency and high frequency data? It seems that the argument DataX and DataY in function MixFreqData only accept vector instead of a matrix.
Eli Twire (view profile)
Hi Qian,
May I ask you why, in the MidasGarch.m line 34, when plotting, you scaled LongRunVar by 252?
line 34:
plot(year(seq),sqrt(252*LongRunVar(seq)),'b','LineWidth',2);
AmorAniss Benmoussa (view profile)
Hi Hang Qian,
Thanks you!
I solved the problem, which came from the convertion of time in excel to Matlab.
Amor
Hang Qian (view profile)
Hi Amor,
I just tried appADLMIDAS2 on Matlab 2015a, and the codes worked with no error messages. I am not sure about the cause of failure on your machine, but I guess these two possibilities:
* The xlsx file is not opened by the MS EXCEL server, and the loaded data series are different.
* The language locale is not U.S. English and the date format is different.
Anyway, after your modification of codes, would you be able to obtain the same results, which look like
RMSE Beta: 0.3146
RMSE Beta NonZero: 0.3311
RMSE Exp Almon: 0.3395
RMSE UMIDAS: 0.3272
RMSE Stepfun: 0.3245
RMSE Almon: 0.3376
Thank you.
AmorAniss Benmoussa (view profile)
Hi Hang Qian,
I use Matlabr2015a and I can not make the example appADLMIDAS2 (or others). I always get the following errors :
Index exceeds matrix dimensions.
Error in MixFreqData (line 264)
fprintf('Reg Y(%s) on ',datestr(EstYdate(m),2));
Error in MIDAS_ADL (line 255)
MixedFreqData = MixFreqData(DataY,DataYdate,DataX,DataXdate,xlag,ylag,horizon,estStart,estEnd,dispTime);
Error in appADLMIDAS1 (line 45)
[OutputForecast1,OutputEstimate1,MixedFreqData,ExtendedForecast] = MIDAS_ADL(DataY,DataYdate,DataX,DataXdate,...
I had to modify the Load data section of this code to be able to have my growth vectors as well as time:
% Load data
[DataY,DataYdate] = xlsread('mydata.xlsx','Sheet1');
DataYdate = DataYdate(2:end,1);
[DataX,DataXdate] = xlsread('mydata.xlsx','Sheet2');
DataXdate = DataXdate(2:end,1);
DataXgrowth = log(DataX(2:end,2)./DataX(1:end1,2))*100;
DataYgrowth = log(DataY(2:end,2)./DataY(1:end1,2))*100;
DataYdate = DataY(2:end,1);
DataXdate = DataX(2:end,1);
DataX=DataXgrowth;
DataY=DataYgrowth;
Thank you,
Amor
Hang Qian (view profile)
Hi Nicolas,
I wrote the GARCHMIDAS codes several months ago, and they are not the codes used in the original paper. The original codes can be found in the data archives of Review of Economics and Statistics:
https://dataverse.harvard.edu/dataverse/restat
You may search the item “Replication data for: Stock Market Volatility and Macroeconomic Fundamentals”.
I did not notice any problems in your specified input arguments, but I do not have the original data and thus are not aware of the source of discrepancy. For the realized volatility MIDAS models, the results obtained from my codes are usually similar to the original codes, given the exactly identical data (both the data source and the method to pretreat the data have to be exactly the same).
Also, I feel that GARCHMIDAS models are robust: the estimated parameters may vary, but the conditional variance patterns and forecasted volatility are similar. My suggestion is to focus on the graphs of the conditional volatility and check if surge and drop of the volatilities have good economic interpretations, and evaluate the predictive power of your estimated volatility model.
Thank you. Good luck!
Hang Qian
Nicolas Soemer (view profile)
Hallo,
First of all thanks for the toolbox. Especially the GARCHMiDaS is very useful to me.
I tried to replicate the results from the 2013 paper “Stock Market Volatility and Macroeconomic Fundamentals” by Engle, Ghysels and Sohn. I used the returns from Schwert’s page and transformed the IP and PPI series as described in the paper, to replicated the results. The descriptive statistics of the returns and macro time series fit. Unfortunately, the results of the regression – especially those with the macro variables – differ a lot. Therefore I was wondering was this matlab model used in the paper?
If yes, what is the correct value for the input arguments? I used 'ThetaM' ,true, 'Period’, 65, and 'NumLag', 16. (This is how I understand it was done in the paper.) Unfortunately, my results differ and are very sensitive to the Period value.
Regards, Nicolas
wang (view profile)
Hi Hang Qian,
Thanks for your rely!
Best regards,
wang
Hang Qian (view profile)
Hi Wang,
For volatility forecasting with a macroeconomic variable X, we need the value of X in the forecasting periods. Therefore, the length of y and X must be the same when we run the program GarchMidas. Otherwise, there will be an error message.
In your scripts, I saw 'X' is assigned a value xDay, which does not increases its size within the FOR loop. So you might want to expand the size of the variable xDay in order to match the size of yBig. For example, the codes would look like
xDayBig = [xDay;xNew];
where xNew is the value of the macroeconomic variable in a onestep forecasting period.
Thank you.
wang (view profile)
Hi Hang Qian,
In out of sample forecast using direct marcoeconomic variable X, I encounter with an error message:
Error using GarchMidas (line 189)
Macroeconomic regressor must be a vector of the same length as y.
could you give me some advice
this code is shown as follows:
yBig = [y;0];
for t = 1:nForecast
[~,~,Variance,LongRunVar] = GarchMidas(yBig,'Period',period,'NumLags',numLags,'X',xDay,'LogTau',1,'ThetaM',1,'Beta2Para',1,'RollWindow',1,'Params',estParams);
yPseudo = estParams(1) + sqrt(Variance(end));
yBig = [yBig(1:end1);yPseudo;0];
end
wang (view profile)
Hi Hang qian,
Thank you very much for your rely.
Hang Qian (view profile)
Hi Wang,
Thanks for your interests in the toolbox. In reply to your question about the outofsample forecast, the variable “yPseudo” is not an observation, but a mathematic construction such that its squared value can recover the conditional variance. Recall that the GARCHMIDAS variances recursion is given by g(i,t) = (1ab) + a * (y(i1,t)mu)^2/tau + b*g(i1,t). In an outofsample forecast, the squared yPseudo works as if it were the squared y(i1,t) because the expected value of (yPseudo – mu)^2 equals the conditional variance. If you would like to add the residual “Resid”, you might want to find a variable whose squared value has the unit variance. Thank you.
wang (view profile)
Hi Hang Qian,
thanks for your wondeful toobox. In Outofsample forecast, yPseudo = estParams(1) + sqrt(Variance(end)); why not is yPseudo = estParams(1) + sqrt(Variance(end))*Resid.
Di Mo (view profile)
Hang Qian (view profile)
The “nobs” you saw is a scalar variable that keeps track of the number of observations. I am not aware in the codes that the variable is used before it is defined. You might check the line number that generates the error message?
Di Mo (view profile)
Hi Hang Qian,
Thank you for the quick reply. I have received another wrong message when running the GARCHMidas Command. The error is as follows:
Undefined function or variable 'nobs'.
Do you have any suggestions on this?
Kind Regards
Di
Hang Qian (view profile)
Hi Di,
The error message you saw is most likely a problem of older version of MATLAB. A few years ago, the Optimization Toolbox of MATLAB migrated optimset to optimoptions. If your MATLAB version is older than 2014a, the software will not recognize optimoptions. You may change optimoptions(...) by something like options = optimset(...).
Di Mo (view profile)
Hi Hang Qian,
Thank you very much for this wonderful Midas Toolbox. I just started with GarchMidas model and an error appeared as follows:
??? Undefined function or method 'optimoptions' for input arguments of type 'char'.
Error in ==> GarchMidas at 294
options = optimoptions('fmincon','Algorithm','interiorpoint','Display','notifydetailed');
Could you give me some advice on this please?
Thank you very much!
Best,
Di
Hang Qian (view profile)
Hi Muhammad,
If your MATLAB version is earlier than R2014b, you may see an error message from the input parser. You will have to replace the name “addParameter” by “addParamValue”. They are the same thing, but the former is its new name. Thank you.
Muhammad Yudhistira (view profile)
Hi Qian,
Thanks a lot for this great toolbox. I just start with MIDAS model, and trying one of the example in the toolbox: appADLMIDAS2. I encounter with this problem.
Error in ==> MIDAS_ADL at 201
parseObj.addParameter('Xlag',9,@(x)validateattributes(x,{'numeric','char'},{},callerName));
Could you give any suggestion?
Best
Hang Qian (view profile)
Hi Yijie,
When you adjust the parameter ”Horizon”, it will shift the dates of the high frequency regressors backward or forward. Setting the Horizon = 2 indicates shift the dates two periods ahead. Depending on how many high frequency periods equal to a low frequency period, this may give you a nowcasting effect. When you run the program, the screen will show how the dates of low and high frequency regressions match each other in a regression. This time frame will be the same for both estimation and forecast.
Also, if you want to verify how the dates match, you may look at the output struct MixFreqData, in which the variables OutYdate and OutXdate are the dates of the low and high variables in the forecasting periods, respectively.
Hang Qian (view profile)
Hi Jennifer,
The error message you saw is a date format issue. The program relies on the MATLAB function datevec to translate string dates to vector dates. It supports 14 date formats, but “01.04.1947” is not one of them. Refer to the documentation of the MATLAB function datevec.
You will have to replace 01.04.1947 by 04/01/1947 (or perhaps 01/04/1947?) Both R2015b and earlier versions of MATLAB use the same date convention. Therefore, the easiest solution is to change the date format in your dataset.
jennifer (view profile)
Thanks for sharing useful toolbox.
The program didnt work on MATLAB R2015b. It gives following errors. Could you give some advice ?
Best
error using datevec (line 276)
Cannot parse date 01.04.1947.
Error in MixFreqData (line 99)
DataYdateVec = datevec(DataYdate);
Error in MIDAS_ADL (line 255)
MixedFreqData = MixFreqData(DataY,DataYdate,DataX,DataXdate,xlag,ylag,horizon,estStart,estEnd,dispTime);
Error in appADLMIDAS5 (line 49)
[OutputForecast1,OutputEstimate1,MixedFreqData,ExtendedForecast] = MIDAS_ADL(DataY,DataYdate,DataX,DataXdate,...
Yijie Huang (view profile)
Hi Qian,
Thanks a million for this toolbox.
In your application 3, if setting the Horizon = 2,is it nowcasting GDP with monthly data? E.g. the forecast result is in 10/01/2009 is based one the 10/01/2009  12/01/2009 monthly data?
Thanks very much.
Hang Qian (view profile)
Hi David,
I guess the error message is most likely a MATLAB version issue. Double check that the Optimization Toolbox is installed and your MATLAB version is R2013b or newer.
If you have the Optimization Toolbox, the namevalue pairs of the optimization options vary from version to version. If your software cannot recognize parameter names like 'LargeScale and 'Jacobian', simply remove it from the codes and use the default optimization setting.
If you do not have the Optimization Toolbox, the only way you can use this software is to change the solver. Replace the toolbox functions lsqnonlin or fmincon by fminsearch, which is available for the base MATLAB. Also remove the bounds constraints, as fminsearch does not support constrained optimization.
Thank you.
David Stephan (view profile)
Thank you for a great toolbox. I am just getting started with MIDAS models and have been trying to follow the example in the user guide. Although everything works fine for models 46 I get a similar error for models 13.
For Models 1 and 2:
Error using optimset (line 219)
Unrecognized parameter name 'LargeScale'.
For Model 3 a similar error:
Error using optimset (line 219)
Unrecognized parameter name 'Jacobian'.
Any ideas what I am doing wrong?
Thanks again for a great toolbox
Saeed (view profile)
Thanks much Eric.
And yes I am using ExoReg to have couple of variables on the right hand side that have the same frequency as the dependent variable.
And yes you are totally correct, I can improve upon simple averaging by using more sophisticated forecast combination approaches.
Thanks,
Saeed
Eric (view profile)
Dear Saeed:
Thanks for your kind words about the MIDAS Matlab Toolbox.
You are correct that multiplicative MIDAS is not yet implemented. Empirical evidence seems to indicate that regular MIDAS specifications typically do better though.
Regarding your question of adding leads of another variable which you call var2. In principle you can use the ExoReg specification to do this, if you properly align the var2 series. So, you can do the direct estimation, assuming that the var2 is not a variable you estimate via a MIDAS polynomial.
Otherwise, if the var2 series is also high frequency it is much easier to run two MIDAS regressions with leads, one for var1 and one for var2, and do forecast combination. You mention that you simply take the average. That is typically not a good idea. Better forecast combination methods exist and are available in the Toolbox
EG
Saeed (view profile)
Dear Eric and Hang:
First of all, I have found the toolbox extremely useful and the accompanying user guide quite detailed and very well written, and so many thanks for making this availabe to all.
Secondly, I am assuming that multiplicative MIDAS is still not implemented (page 16 of the userguide mentions it as well). I ask, because many papers published do seem to apply multiplicative MIDAS such as Andreou, Ghysels, and Kourtellos (2013): Should macroeconomic forecasters look at daily financial data? (JBES).
So currently, I am using daily series named var1 with leads to forecast a monthly series Y. But on the right hand side I also want to have leads of another variable, var2. Since I cannot use multiplicative MIDAS, so I run one MIDAS regression using only leads of var1, and then I run another MIDAS regression using only leads of var2. I average the two forecasts of Y. But it will be nice to just run "one" MIDAS regression that allows for leads of both variables var1, and var2.
Any help in that regard will be very much appreciated. Thanks in advance.
Eric (view profile)
Dear Philippe:
This is essentially a question about mixed frequency VAR models. There is a literature on this. See for example the paper entitled "Macroeconomics and the reality of mixed frequency data", forthcoming in the Journal of Econometrics which I wrote. Estimation can be done with standard VAR packages.
Regards,
EG
Philippe (view profile)
Hello,
Is it possible with this code to run multivariate MIDAS regressions? If not, how could it be implemented?
Regards,
Philippe
Eric (view profile)
Dear Duhyun:
The MIDAS Toolbox only covers MIDAS regression analysis. To my knowledge there is no user friendly MIDAS volatility model code publicly available. Still to be done, unfortunately. However, it is not so difficult to start from Matlab ARCHtype code and replace the volatility dynamics with a MIDAS polynomial specification. It would not be generic, but easy to tailor to a specific application you have in mind.
I agree that it would be useful to have generic MIDAS volatility code publicly available. I've had discussions with Hang on this topic.
Sincerely,
Eric Ghysels
Duhyun Cho (view profile)
It is honor to say to you Eric
Actually, I am deeply interested asymmetric MIDAS model in your paper "There is risk return tradeoff after all"
One of my focuses is finding empirical relations between risk and return though estimating ICAPM model in Asian Pacific stock market.
Anyway I found a related toolbox manual
the ULR is that
http://pages.stern.nyu.edu/~ehedegaa/PDFs/MidasManual.pdf
However, there was only manual of a toolbox but I couldn't find original toolbox still.
If I wouldn't be bothering you, I want to ask a help about the toolbox.
Anyway,thank you for giving a change to me describing my focus. I will wait your answer Thank you very much
Duhyun Cho (view profile)
It is honor to say to you Eric
Actually, I am deeply interested asymmetric MIDAS model in your paper "There is risk return tradeoff after all"
One of my focuses is finding empirical relations between risk and return though estimating ICAPM model in Asian Pacific stock market.
Anyway I finded a related toolbox manual
the ULR is that
http://pages.stern.nyu.edu/~ehedegaa/PDFs/MidasManual.pdf
However, there was only manual of a toolbox but I couldn't find original toolbox still.
If I wouldn't be bothering you, I want to ask a help about the toolbox.
Anyway,thank you for giving a change to me describing my focus. I will wait your answer Thank you very much
Eric (view profile)
Dear Duhyun:
Would you mind being more specific about asymmetric MIDAS  what exactly you are thinking of?
Thanks
Eric Ghysels
Duhyun Cho (view profile)
Thnak you very much for your kindness
I tried again as I mentioned before and there is no problem the error message has been completely removed.
If it wouldn't be annoying you, I want to ask one more question with respect to asymmetric MIDAS regression.
first, is this code available for asymmetric MIDAS? or needed to change some codes or syntax of this toolbox.
I tried to find asymmetric model form Eric Ghysels homepage and other authors of academic papers related to MIDAS model but this is not really easy task to find it.
could you give me an idea? I shall wait your answer
Hang Qian (view profile)
Hi Duhyun,
Thank you for catching that.
The error message at Line 392 pops up after parameter estimation. The estimation results have displayed on the screen. This line just makes date display more beautiful. The error comes from reshaping a vectorized empty matrix; it changes the row/column dimension of an empty matrix.
I have updated the codes. The error message should disappear.
Duhyun Cho (view profile)
Hi Qian
firstly, Thanks for uploading the toolbox
Actually, I wander how to use DL MIDAS model in this tool box.
I tried several times Ylag = 0 in the toolbox because, in my research, autoregression terms do not needed.
unfortunately, there is several error massage in matlab like
Error : MIDAS_ADL (line 392)
MixedFreqData.EstLagYdate = reshape(cellstr(datestr(MixedFreqData.EstLagYdate)),size(MixedFreqData.EstLagYdate));
is there any method to clean that error?
Hang Qian (view profile)
Hi Ruizhi,
I did not test and do not know whether the program can work properly using minute or second data, but you may have a try. DataXdate and DataYdate follow the MATLAB supported time format. For example, 01Mar2000 15:45:17 and 20000301 15:45:17 can be recognized by MATLAB.
Thank you.
Ruizhi Ma (view profile)
Hello! Really thanks for the upload! I'm curious about using intradaily data to forecast daily stock returns by MIDAS, how can I write the DataXdate and DataYdate ? Thank you!
Anni208 (view profile)
Thank you for the very fast answer!
I will follow your advice!
Hang Qian (view profile)
Hi Anni208,
The date string '01.04.1947' is not a supported MATLAB date format, so it cannot be parsed by the program. MATLAB has 14 supported formats, such as '01/04/1947', '19470104', '04Jan1947', 'Jan.01,1947', etc.. If you could change your date format to one of the supported formats, the error message will disappear.
You may refer to this page for the MATLAB date string format:
http://www.mathworks.com/help/matlab/ref/datevec.html
Thank you.
Anni208 (view profile)
Hello!
I'm very cuurious to try your code unfortunately while running appADLMIDAS1.m I receive the following error message:
Error using datevec (line 277)
Cannot parse date 01.04.1947.
Why is there a problem with datevec? Can you please help me with this?
Thanks in advance!
Anni208
WMendieta89 (view profile)
Thank you very much for your reply! It worked!
Thanks again for this great toolkit.
William M.
Hang Qian (view profile)
Hi WMendieta,
MIDAS uses a direct multistep forecast. For example, if we want a 3step ahead forecast, we specify a MIDAS model as
Y(t+3) = b0 + b1*Y(t) + b2*Y(t1) + ... + high frequency regressor terms X(j,ti), j=1,...,Nd, i = 0,1,2,...
Similarly, for a 5step ahead forecast, we use a model like
Y(t+5) = b0 + b1*Y(t) + b2*Y(t1) + ... + high frequency regressor terms X(j,ti), j=1,...,Nd, i = 0,1,2,...
By direct forecast, we mean the left hand side of the model is the hstep ahead dependent variable. This is in contrast to the iterated forecast in an autoregressive model.
Please refer to Section 2.3 of the MIDAS user guide for the multistep forecast:
http://www.unc.edu/~eghysels/papers/MIDAS_Usersguide_V1.0.pdf
For the software usage, put the lagged dependent variables in 'ExoReg' and then adjust the namevalue pair 'Horizon' accordingly.
Thank you.
WMendieta89 (view profile)
Hi! Thanks for uploading this toolbox! I wonder how do you perform hstep ahead forecast using this toolbox? I have performed 1 step ahead outofsample forecast but i´ve been unable to do so for hstep ahead forecasts
thanks in advanced,
WMendieta