version 2.4.0.0 (1.07 MB) by
Hang Qian

Repack of Mi(xed) Da(ta) S(ampling) regressions (MIDAS) written by Eric Ghysels and collaborators

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 ADL-MIDAS type regressions. The package also includes two functions for GARCH-MIDAS and DCC-MIDAS 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,...)

Created with
R2015b

Compatible with any release

**Inspired:**
"MIDAS Analytic'' extension to the MIDAS MATLAB Toolbox

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Hang QianDear Erin,

The program assumes evenly spaced temporal aggregation. That is, we assume that every month has 30 days, not necessarily the calendar dates. It code works if your data are evenly spaced, but may not work well if there are different days in a month. Consider re-formatting your data/dates similar to the example files that come with the toolbox.

erin wenDear Hang Qian,

I used daily data(everyday, include weekend) and monthly data, so I set Period as 30. But when it comes to the third step(Repeat the monthly value throughout the days in that month), it showed that 'Index exceeds the number of array elements (0).' I changed the munber of Period, but it still don't work. May I ask what's wrong with my step?

Best wishes!

Hang QianDear Emiliya,

If you use the program MIDAS_ADL, you may adapt line 474 of

Results = bnls_adl_new(y,x,numofparams,output_type,polyconstr);

where numofparams = 1 provides an estimator with the one-parameter beta polynomial.

Emiliya KubataDear Hang Qian,

I need to use the beta polynomials Eq 5b weighting and to fix the w1 to 1. Could you please assist me with this question. Many thanks in advance!

Meriem mahseurThank you so much sir for your answer, i'm so gratful

Hang QianProfessor Ghysels kindly provides answers to some of our questions:

February 20: Dear Hang Qian, Please help me does the code of midas cointegrated var I(2) exist in matlab

thank you

Answer: It might be worth checking with Thomas Gotz of the Deutsche Bundesbank who wrote several papers on cointegration and MIDAS

Dec 8, 2020: Dear Hang Qian，

Thank you for your share. I have one question. I wonder if ADL-MIDAS, GARCH-MIDAS and DCC-MIDAS model can be used for cross-section analysis.Thank you.

It might be worth pointing to the paper which covers cross-sectional MIDAS:

Ball, Ryan T., Lindsey Gallo, and Eric Ghysels. "Tilting the evidence: the role of firm-level earnings attributes in the relation between aggregated earnings and gross domestic product." Review of Accounting Studies 24.2 (2019): 570-592.

Sept 10: Dear Hang Qian,

Thank you for your share.I read a lot of literature about MIDAS and found that most of them only gave preduction result, and did not give the regression result( the significance of each parameter). Does it mean that the regression result is not important and will not affect the prediction result？

I am really confused about this.

Thank you.

Cheng

Answer: The recent work by Babii, Ghysels and Striaukas introduces machine learning MIDAS regression models involving regularized regressions with sparse-group LASSO with formal hypothesis testing. See:

Babii, Andrii, Eric Ghysels, and Jonas Striaukas. "Machine learning time series regressions with an application to nowcasting." Available at SSRN 3503191 (2019). (forthcoming Journal of Business and Economic Statistics)

Babii, Andrii, Eric Ghysels, and Jonas Striaukas. "Inference for High-Dimensional Regressions With Heteroskedasticity and Auto-correlation." Available at SSRN 3615718 (2020).

Babii, Andrii, Eric Ghysels, and Jonas Striaukas. "High-Dimensional Granger Causality Tests with an Application to VIX and News." (2021).

Hang QianDear Meriem,

I wish you good luck in developing cointegrated MIDAS, which appears a promising research direction.

Meriem mahseurDear Hang Qian, Please help me

does the code of midas cointegrated var I(2) exist in matlab

thank you

Ahamuefula OgbonnaDear Hang Qian,

Thank you for your prompt response.

Hang QianDear Ahamuefula,

When we compare the log likelihood under different lag orders and determine the optimal lag order by some information criteria, we need to fix the number of observations used in parameter estimation. Otherwise, the log likelihood for the NumLag = 1 specification is likely to be the smallest. As we increase the number of lags, we reserve more data points for the pre-sample data, so that the number of data points in the estimation window reduce accordingly. Hope it helps.

Ahamuefula OgbonnaDear Hang Qian

I want to determine the optimal numLags to incorporate in my GARCH-MIDAS model. I adopted the approach of estimating the model with different numLags starting from 1 to 40 and then observed Loglikelihood, AIC and BIC values at each stated NumLag. All pointed to 1. What does this imply? Does it mean that I only require 1 lag to filter the secular component by MIDAS weights? Kindly, assist me. What is the appropriate Numlag specification for a day-month GARCH-MIDAS estimation?

Hang QianDear 蔷 黄,

I think the MIDAS toolbox is designed for time series analysis of data sampled at different frequencies. It would be creative work if you adapt the method for the cross-sectional data analysis.

蔷 黄Dear Hang Qian，

Thank you for your share. I have one question. I wonder if ADL-MIDAS, GARCH-MIDAS and DCC-MIDAS model can be used for cross-section analysis.Thank you.

Hang QianDear Carlos,

Yes, it is correct.

carlos ortegaDear Hang Qian, thanks a lot for your replies, may you be kind as to answer me a question, I compared the results from the "likelihood function" from the "nlh_garchmidas.m" file from Engle, and the log likelihood from your file "garchmidas.m", both give very similar results, but not exactly the same, is this correct? Best wishes.

Hang QianDear Carlos,

The "myfun" in the "garchmidas.m" is a function handle sent to the numerical optimization package. The function takes the model parameters as the inputs and returns the negative log likelihood function corresponding to those parameters. By minimizing the objective function, we obtain the maximum likelihood estimator.

carlos ortegaDear Huang Qian, thanks a lot for your answers, what is the minimize function "myfun" using line 297 in "garchmidas.m" file? What does it try to minimize? I mean in a nutshell? I just do not understand the code :(

Hang QianDear carlos,

The GarchMidas function returns the output variables Variance (T-by-1 conditional variance), LongRunVar (T-by-1 long-run component of conditional variance) and ShortRunVar (T-by-1 short-run component of conditional variance). You may put those variables in the MATLAB ‘plot’ function that plots those time series.

carlos ortegaDear Huang Qian, I already run the GarchMidas function, I got results, but how do I plot the the "Conditional volatility and its secular component" as Figure 1. P.35., in your help file "MIDAS_Usersguide_V2.3.pdf". Best wishes.

Hang QianDear Zhuofan,

I am not aware of a simple method of adding the macro economic variables, but you may consider adapting the code of DccMidas. At line 526, there is a local function fML, which compute the log likelihood of the model. In principle, your macroeconomic variable will have an impact on the log likelihood. So you may want to maximize the log likelihood with respect to the “x” term, as well as other parameters. It needs some work. Good luck!

Zhuofan XUDear Huang Qian,

Thanks for your kindness for answering our questions. We are currently doing our undergraduate final year project. and the code is really useful for us. We get some new problems there. The input arguments of DccMidas doesn't include "x", the macro economic variables, so is there any method to do the Dcc-midas fitting with macroeconomic variables? Do we just need to add a fisher transformation on long-run correlation? Could you please give us some suggestions and guidance? Thanks a million!

Hang QianDear Carlos,

It is not obvious to me that treatment to a dummy variable has to be different than a macroeconomic variable. I would put the dummy variable in the name-value pair 'X'. Also, you may want to try different settings of the name-value pair 'LogTau' and 'ThetaM'. If a dummy variable is really statistically different from a regular macroeconomic variable, a new model and code for estimating the model is needed. Thanks.

carlos ortegaDear Hang Qian, great code, thanks for sharing, I have read comments and noticed you wrote your garch-midas code allow using one "X" or the "RV", so mi question is, how can I include a dummy variable in the long run volatility, I assume the treatment to a dummy variable has to be different than a macroeconomic variable "X"? best wishes

Hang QianDear Zhuofan,

In a sense, the DCC MIDAS is a data driven model. The software does report the estimator covariance matrix(EstParamCov), of which the square root of the diagonal elements are the standard error of the parameters. The software also reports the conditional correlation matrix. The model is good for volatility forecast as well.

Zhuofan XUDear Hang Qian,

Thanks for your kindness to share this Toolbox. There is one thing I don't understand, is this DCC-MIDAS estimated by some data driven model so that we can not obtain the standard error for every parameters? We know nothing about data-driven actually, is this model not suitable to research the correlation but good for forecasting? Thanks!

XIAONI SUNHang QianDear zhou lan cheng,

If your data are good and the model fit is good, the weights will be positive. You may want to ignore bad model specifications in which the weights are negative. If you really want to impose the constraints, you may modify the code. When the numerical optimization program minimizes the least square, you could add a bound constraint to numerical optimization so that it searches a constrained parameter space for a minimized point for the least squares.

zhou lan chengDear Hang Qian,

Thank you for your reply. I have another question about parsimonious polynomial specifications. Theoretically, when we use Normalized exponential Almon lag polynomial, the weights should be positive. However, Sometimes when I run MIDAS_ADL.m with ExpAlmon, it turns out that the weights are negative. How should I deal with this problem？

Thanks a lot

Cheng

Hang QianDear Cheng,

MIDAS is primarily a prediction model that makes use of the high-frequency data information, which may be lost in the process of data aggregation. Therefore, MIDAS is likely to achieve better prediction compared to models that only use low-frequency data as predictors. The regression results are data driven, and the estimated coefficients are determined by data. It is not a structural econometric model, which may specify a rigid relation between the explanatory variables and the response variable. It may or may not be used for causal inference. We need to be careful if we wish to interpret the coefficient as the marginal effect of the explanatory variables. Thank you.

Hang

zhou lan chengDear Hang Qian,

Thank you for your share.I read a lot of literature about MIDAS and found that most of them only gave preduction result, and did not give the regression result( the significance of each parameter). Does it mean that the regression result is not important and will not affect the prediction result？

I am really confused about this.

Thank you.

Cheng

Hang QianDear Pei,

One possibility is Matlab downward compatibility. Newer version of Matlab may not work well with the old code. In that case, you may restore to an older software version. Another possibility is system language setting. As date format varies by region, the code only works for US English system language. So, check your operating system language.

PeiDear Hang Qian，

Thank you for your share. I have downloaded the toolbox before, and the functions and results worked and went very well. But when I run the same code with the same data recently, Matlab reported some errors, it seems there is some problems in the use of function datenum and datevec?

mistake use datenum(line 178)

DATENUM failed

error MIDAS_ADL>MIDAS_ExtendForecast (line 636)

DataYdateBig = datenum(DataYdate);

error MIDAS_ADL (line 418)

ExtendedForecast =

MIDAS_ExtendForecast(DataY,DataYdate,DataX,DataXdate,ExoReg,ExoRegDate,...

reason:

mistake use datevec (line 212)

can not find the month of one year

I have reinstalled the Matlab, but there still exist errors.

How could I adjust the code? or how could I solve this problem?

Thank you very much!

Pei

Hang QianDear chen shu,

You may check the output argument “CorrMatrix” and “LongRunCorrMatrix”, which corresponds to the correlation matrices. If it is not the variable you are looking for, you may step into the code, especially the subfunction “fML”, which analyzes the correlation structures and computes the likelihood function. Thank you.

Dear Mirko,

I cannot remember the exact data structure. It seems that the left hand side of the quantile regression is the n-period returns by aggregating y(t),...,y(t+period-1), while the right hand side of the equation is the lagged returns by extracting y(t-1),...,y(t-nlag). So you may want to format your data in that manner. See line 176 -186 for data processing.

Hang

Mirko CasamentoDear Hang Qian,

Thanks very much for the sharing of this precious toolbox. I am having issues with the implementation of MIDAS quantile regression. I need to regress y (low frequency data, i.e. monthly Industrial Production Index) on x (high frequency data, i.e. daily returns of a stock market index). Dataset is generated over the last 25 years, but obviously, being x at high frequency, there are 6500 observations for x and just 307 observations for IPI (y). Among inputs of the function MidasQuantile, it is specified that X must have the same length as Y, a T-by-1 vector. How is it possible? How can I solve this?

I am not an expert, I do apology for possible misinterpretation, but I have found no other ways to perform this regression with matlab. Thank you very much for the help.

chen shuDear Hang Qian,

Thanks for the sharing. I'm studying the DCC-Midas code. How can I get the rolling window out-of-sample 1 period forecast of the correlation matrix?

Hang QianDear Cheong,

When you write your own code, you may consider the debug mode of Matlab, where you can see the length of the response variable and your macroeconomic variable. Both grow in length in the FOR loop, but make sure that they are of the same length. Good luck!

Cheong Kin WanDear Hang Qian,

Thanks for your prompt reply. Appreciate. I am still stuck with the following command lines below. How do I connect the in-sample estimation command line below which is meant for GrachMidas RV:

% In-sample forecast validation

GarchMidas(y,'Period',period,'NumLags',numLags,'estSample',3130);

into the following command lines for GARCH-Midas with exogenous macro variable?

% Out-of-sample forecast

estParams = GarchMidas(y,'Period',period,'NumLags',numLags);

nForecast = 5;

yBig = [y;0];

for t = 1:nForecast

[~,~,Variance,LongRunVar] = ...

GarchMidas(yBig,'Period',period,'NumLags',numLags,'Params',estParams);

yPseudo = estParams(1) + sqrt(Variance(end));

yBig = [yBig(1:end-1);yPseudo;0];

end

Are yo able to help me to write the correct command line to be executed in MATLAB? TQVM.

Hang QianDear Cheong,

For the out of sample forecast, the exogenous macroeconomic variable must be of the same length as y. In the code, yBig is constructed with an increasing length, so the exogenous variable must expand its length in the FOR loop as well. Thank you.

Hang

Cheong Kin WanDear Hang Qian,

I used the following command lines for GARCH-Midas RV and manage to get the in-sample estimation and post-sample forecasting. But for the case of GARCH-Midas with a macroeconomic variables, I cannot get the post-sample forecasting output with the following command lines. Can you enlighten me on how I should go about or is there a need to modify this command lines below?

% In-sample forecast validation

GarchMidas(y,'Period',period,'NumLags',numLags,'estSample',3130);

% Out-of-sample forecast

estParams = GarchMidas(y,'Period',period,'NumLags',numLags);

nForecast = 5;

yBig = [y;0];

for t = 1:nForecast

[~,~,Variance,LongRunVar] = ...

GarchMidas(yBig,'Period',period,'NumLags',numLags,'Params',estParams);

yPseudo = estParams(1) + sqrt(Variance(end));

yBig = [yBig(1:end-1);yPseudo;0];

end

VarianceForecast = Variance(nobs+1:nobs+nForecast);

LongRunVarForecast = LongRunVar(nobs+1:nobs+nForecast);

Hang QianDear Hamid,

Input parser is a core Matlab function. Its syntax was updated a few years ago, so there is a downward compatibility issue. You may want to update your Matlab to the most recent version to use the toolbox. Thank you.

Hamid MuiliDear Qian, I am new to MATLAB so I have a little bit of problem when running the Demo. Both for Midas quantile and DCC midas. The error output for quantile midas " undefined function 'add parameter for input arguments of type 'input parser'.. I'm using MATLAB 2013a

Hang QianDear Marwa,

If you would like to incorporate exogenous regressors, you may take a look at the DccMidas code and look for a subfunction fML, in which the log likelihood is computed. The exogenous regressor will shift the log likelihood. It is somewhat challenging to adapt the code. Good luck!

Marwa TalbiDear Hang,

I want to ask how can i incorporate the exogenous variable to the DCC-MIDAS model? Is it the same way as in the garch-midas?

Thank you

钊杰 薛Hang QianDear zhou lan cheng,

As the number of days varies in a month and the software assumes a specific number of high frequency lags, it is just an approximation to the calendar day/month aggregation. Missing values are indicated by NaNs, which will be piecewise deleted by the software when it runs regressions. Thanks.

zhou lan chengDear Huang,

I try to use MIDAS_ADL.m for daily/month data. I have some questions:

1.Since the number of trading days is different each month, how can I ensure the correspondence between the low frequency data and the high frequency data?

2. Whether MIDAS_ADL.m is the same as GarchMidas.m, the missing values in high-frequency data should be represented by NAN?

Thanks

Ameer FahmiHang QianDear Ameer,

The warning messages indicate that your data poorly fit the model, and the software is unable to provide you a good estimator. You may consider revising the model specifications.

Ameer FahmiI reset the 'thetaM' to true, but the model still failing to estimate short-run and long-run components

Ameer FahmiI'm trying to use MIDAS GARCH with daily stock returns and exogenous regressor in quarterly frequency, I matched the quarterly series with daily series then I used the following function

[estParams,EstParamCov,Variance,LongRunVar,ShortRunVar,logL] = GarchMidas(y,'X', xDay,'Period',66,'NumLags',10);

But I keep getting this warning

Warning: Reset the Name-value pair 'thetaM' to true, so that theta and M could be negative.

> In GarchMidas (line 193)

Warning: FMINCON failed... Switch to FMINSEARCH. Error Message: Objective function is undefined at initial point. Fmincon cannot continue.

> In GarchMidas (line 303)

Warning: Covariance matrix of estimators cannot be computed precisely due to inversion difficulty.

> In GarchMidas (line 311)

Warning: Matrix is singular to working precision.

> In GarchMidas (line 313)

What does this mean?

Aulia Uswah AffaniYes, thanks for the reply!

Hang QianDear Aulia,

The number of lags for the exogenous regression can be any number, which does not necessarily be 24.

Aulia Uswah AffaniDear Hang,

In GARCH-MIDAS, the NumLags for the exogenous regressor take the value of 32. What is this based on? Isn't it supposed to be 24 lags, the same as the GARCH-MIDAS for the realized volatility?

Thanks for your reply!

Hang QianHi Aulia,

I guess you are the best person to debug your own code. You may check the row/column orientation of your data xDay and y. Also, make sure there are no missing values in those data. You could set a break point at the place where the error message occurs to inspect the size of the variables. Just my two cents. Good luck!

Aulia Uswah AffaniHi Huan,

I run the in-sample forecasting for the macroeconomic variable with this code:

GarchMidas(y,'Period',period,'NumLags',numLags,'estSample',3000,'X',xDay);

where I put the Day for the specification. But I got an error message :

Unable to perform assignment because the left and right sides have a different number of elements.

Error in GarchMidas (line 380)

RegMatBig(1:nobs) = RegressorFull(:);

Number of xDay and y in my case is the same (4289 observations)

Thank you!

Hang QianDear Aulia,

By default, GarchMidas code uses realized variance for forecasting. There is a name/value pair where you can specify one macroeconomic variable instead.

Aulia Uswah AffaniDear Hang,

I'm quite confused by the in-sample and out-sample forecasting. If I want to forecast stock market volatility and run your GARCH-MIDAS code, is it going to forecast the number based on realized variance or is it going to forecast using macroeconomic variables? I want to know which macroeconomic variables have more power to forecast the stock volatility, and if compare with the historical stock return, which one is better to forecast.

Thanks in advance!

Hang QianHi Aulia,

You surely can run MIDAS regression with subsamples, but some initial data points will be sacrificed due to the lagged terms. If you have a model with two equations, one for the conditional mean and the other for the variance, you will have to write your own code. Good luck.

Aulia Uswah AffaniDear Hang,

There are some questions that I would like to know the answer to :

1) In the paper, Eric split the data into different sample interval. How can I do that?

2) In the paper, we also have two components, level and variance for macroeconomic variables. How can I achieve this?

Thanks for the help!

Hang QianDear ry ws,

DCC_MIDAS is a multivariate model with many parameters, which does not work for all datasets and model specifications. You may try a different starting value or optimization setting to see if the results improves. It needs some work, of course. Thank you.

ry wsDear Qian:

I'm a newer to MATLAB. When I ran the MARCH-MIDAS, everything went quite well. But when I ran DCC-MIDAS in this toolkit on my two variables data, the software reported a = 0 and b = 0 with probability 1. Also the CorrMatrix and the LongRunCorrMatrix are identical. So what I could do to improve the significancy of this result? Thank you so much.

Hang QianDear zhou lan Cheng,

GarchMidas has a name/value pair Beta2para for two MIDAS polynomial specifications. For other polynomial, you will have to write your own code. The warning messages indicate convergence issues, which is common. You may consider different starting values or model specifications. Thank you.

zhou lan chengDear Qian,

Thank you for your toolbox.I have two questions for you.

1.When I run GarchMidas.m, I want to change the MIDAS polynomial specification. How can I do it?

2.In your GARCH-MIDAS example, I changed 'NumLags' and I found out that sometimes it turned out that "Covariance matrix of estimators cannot be computed precisely due to inversion difficulty. " and sometimes it turned out that "Solver stopped prematurely.fmincon stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 3000 (the default value)." So, whether ‘NumLags’ is determined according to the information criterion from the passed result?

Thanks.

Cheng

Hang QianDear Xifan,

It is challenging to modify the code of the toolbox. You may set a break point at the line that generates the error message and inspect the matrix dimension and make changes if necessary. Good luck.

XifanDear Qian,

I am trying to use my own data to get a multivariate Dcc Midas, and I change some number in the codes, the program 'appDCCMIDAS1.m' run well. However, when I set the default value of 'MorePara' as true to get different ‘a’ and 'b' for each variable, the wrong message come out as:

要执行 RESHAPE，请勿更改元素数目。

出错 shi_appDCCMIDAS1 (line 50)

LongRunCorrMatrix = reshape(LongRunCorrMatrix,49,nobs)';

It seems that the number of elements in 'LongRunCorrMatrix' has changed I don't know how to make it work, can you help me out?

Sincerely

Hang QianDear Aulia,

I really have no experience with asymmetric and extreme volatility.

Aulia Uswah AffaniDear Qian,

I want to apply MIDAS with asymmetric and extreme volatility effect on your matlab functions. Do you have any references on how to do that?

Hang QianHi Kago,

Sorry, I have no experience in MIDAS with panel data regression. My understanding is that MIDAS is typically used with long time series with many observations, but in a typical panel data setting, T is short while n is large?

Hang QianDear Xifan,

I guess you need to write the customized program for DCC-Midas combined with Var. Good luck!

Kago MatlhakuHi Hang can the MIDAS be extended to use in Panel Regression. Please bear with me I hope my question does not sound silly!

XifanDear Hang, thanks for sharing. If I want to use Dcc-Midas model combined with a Var model to analyze exchange rate linkage problems among several countries (including daily and monthly exchange rates), can I use the codes in the toolbox? Your answer would be appreciated.

Hang QianDear Pei,

You could try m equals 4, but week/month aggregation is not as evenly spaced as month/quarter aggregation, as there could be different number of weeks in a month. The code may or may not work in that case, at least it would not correspond to the true calendar dates. Commercial software may better handle those complicated date situations. You may take a look at Eviews functionalities?

PeiDear Hang,

I want to apply the MIDAS model by weekly and monthly data. So in my study the m=4. I have already formed the weekly data by 01/07,01/14,01/21,01/28, ……，and formed the monthly data by 01/28,02/28,…….Since my m is 4 not 3, when I run the MIDAS_ADL.m, do I need to change some code?Thank you!

Sincerely,

Pei

Hang QianDear Chi,

The variable nobs is defined in line 46 of appGARCHMIDAS1.m. That is,

nobs = size(y,1);

Thank you.

Chi ZhangDear Hang

When I input ’xDay = NaN(nobs,1)‘ as the pdf shows, matlab reminds me 'nobs is not a defined function or variable', can you tell me where I overlook？

thanks a lot！

Hang QianDear Chi,

The symbol you saw is a matlab syntax, saying omitting an output argument. The variable nobs represents the number of observations. Thanks.

PeiDear Qian, I see, I can construct the forecast function using the estimated parameters. Thanks a lot.

Chi ZhangDear Hang

about [¬,yDate] = xlsread('NASDAQCOM.xls','A22:A11669')，what is ¬？

about xDay = NaN(nobs,1)，while I cannot find the definition of nobs?

thank you

Hang QianDear Pei,

The outputs of the function MIDAS_ADL contains the forecast results: OutputForecast is a struct recording the results of forecasts, including point forecast on low frequency data and RMSE. If that is not what you are looking for, the functions in the toolbox return the estimated parameters. Therefore, you can construct a fitted model and do some customized out-of-sample forecast. Thank you.

PeiDear Qian, Thanks for your share, gain much . While, I am wondering how to make the out-sample forecast? Estimate model using all data, then for h=1,2,3, we can get the 1st out-sample forecast of low frequency data. Is this part contented in the toolbox? Thanks!

Hang QianDear Fehmi,

The choice is random, not based on a rule, because it is problem specific and data specific. You could try as many candidates values as possible.

Fehmi ÖzsoyDear Huang,

I know the initial conditions are represented as alpha0,etc. However, I asked how the default values are chosen as 0.5, 0.01 etc. I mean in the code for example alpha0 is chosen as 0.05. But I wonder why it is not chosen as 0.01 or else. Is the choice random or based on a rule? I asked that because I need to picked up an initial coefficient value for the variable that I want to add. thanks again.

Hang QianDear zhenyu,

I am not sure about the causes of the warning message. It appears that the matrix does not have a full rank? Some datasets might not be suitable for some polynomial specifications. Maybe you could experiment changing some settings like 'AlmonDegree'? The software returns the weights in OutputEstimate, so you could plot it manually.

zhenyuDear Huang,

I have two questions for you.First is that in midas_adl, the result reports:RCOND = 2.059260e-18。

> In ols (line 29)

In almon_adl_new (line 31)

In MIDAS_ADL>MIDAS_Estimate (line 549)

In MIDAS_ADL (line 324)

In appADLMIDAS1 (line 30)

The second is that in midas_adl,when generating a plot of weights, there is no figure of Almon lag polynomial of order 3. Instead, it becomes the figure named "MIDAS:Normalized beta density with a zero last lag". Thank you!

Hang QianDear Fehmi,

In GarchMidas, the initial values can be specified by the name-value pairs like 'Mu0', 'Alpha0', 'Beta0', etc. They are default values like 0.05, 0.9, 0.1, etc. The initial values need to be carefully experimented by users for specific applications. I would try as many initial values as possible, and compare which one yields the best results. It would be challenging to modify the code by adding more variables. You could start with the subfunction fML in GarchMidas, which computes log likelihood of GARCH-MIDAS and returns the conditional variance. It would need some work, of course. Good luck!

Fehmi ÖzsoyDear Huang,

I have two questions for you,first one is how the initial values of coefficients is determined as in the codes? Is there a special way to determine or are they randomly picked up? The second one is that I want to modify the Garch midas code with adding the same macroeconomic variable outside the variance. I mean adding the variable with a coefficent to mean of y.(and of course I need to estimate this coefficient too) Where do I need to start with? Thank you.

Hang QianDear huimin,

In the GarchMidas code, you may take a look at the subfunction fML, which computes the log likelihood and the conditional variances. When there are more factors, the additional parameters will change the log likelihood function. It might be challenging to adapt the code. Good luck!

wang huiminDear Huang,

I want to know how to write the code of multi factor garch-midas model?

Thank you!

Hang QianYes, of course. M-language syntax changes with new releases. I am not a user a MacBook, but the date format in Mac version of EXCEL spreadsheet might not be exactly the same as those on others’ computers. The date format also differs in different regions of the world.

zhenyuDear Huang,

I ran this toolbox, using version of matlab2019b on my MacBook and got a lot of errors, such as a date import error using xlsread. For software compatibility, should I run the older version of matlab on Windows, such as version 2015b? Thank you!

Hang QianDear zhenyu,

The code works for evenly-spaced data. For day-month aggregation, it uses a fixed number of days, say 22, which is not necessarily the calendar date. The code support regressions with one high frequency variable. Consider forecast combination if you have more than one variables. Thanks.

zhenyuDear Huang,

1.I want to use the daily high-frequency data to predict the monthly low-frequency data, but the number of days included in each month is different. Could this toolbox support this? 2.Could this toolbox support multivariate high frequency variable regression? Thank you!

Hang QianHi Chi,

Yes, the date and time must be consistent. If you use GarchMidas, the input is a numeric vector, and thus no requirement on the minimum time interval. If you use MIDAS_ADL, the input are dates and values. The code has limited ability to parse date and time. It works for simple cases like month-quarter mixed frequency, but it may not work well for unevenly spaced data.

Fehmi ÖzsoyDeat Huang, thank you for answer. I reset all date settings. Everything works fine. You are great. I really appreciate your help.

Hang QianDear Fehmi,

The error message you saw is produced by an internal MATLAB function datevec, which converts date and time to vector of components. This function is not part of the toolbox. It appears that MATLAB does not recognize your date format “08.02.1971”, which could be Aug 2, 1971 or Feb 8, 1971, depending on the timing convention of your country. The date format is determined by the language setting of your operating system. You may try to modify the dates in your data file or the language setting.

Fehmi ÖzsoyDear Hang,

Thank you for your response. I have a further question. When I tested the appgarchmidas1, everthing worked perfectly with only a realized variance. However, when the ind. prod. is included, the codes were crashed due to not parsing the first date of the sample. I have this message even if I read the command myself in command window :

Error using datevec (line 276)

Cannot parse date 08.02.1971.

Error in appGARCHMIDAS1 (line 64)

[~,yDateMonth] = datevec(yDate);

How can we solve this problem? Thank you.

Chi Zhanghi, Hang

I use this toolkit to study high-frequency data in the stock market. I have two questions for you. First, do the dates and times have to be consistent? Because the stock market has trading days and trading hours, and the data is inconsistent in certain time periods, can the toolkit recognize it, or do I have to convert it into consecutive dates and intraday time to return? Secondly, what is the minimum time interval that can be accepted, I see the example is 1 day. But I use high-frequency data for hours, half an hour, 15 minutes, and 5 minutes. Can the tool support it?

thank you!

Hang QianHi Fehmi,

I am not the owner of the data. If you search “Replication data for: Stock Market Volatility and Macroeconomic Fundamentals”, you will find the original code at Harvard Dataverse.

Fehmi ÖzsoyHi Huang Qian, I am interested in your Garch-midas codes. as I understood from the article, the data was adjusted to use. Is there a viable data to test your codes and compare the results with the results of the article? Thank you for your consideration.

Marwa Talbizhijian huanHi Huang Qian,

We are waiting for new version of Midas.

Thank you.

Hang QianHi lanlan,

I think the residuals equal the observations minus the conditional mean. That is, y - mu. The estimated mu is reported in the first element of estParams. If you would like to standardize the residuals, you could divide it by the square root of the conditional variances, which are also reported by the software. Thank you.

lanlanHi Hang,

It's my pleasure to use your MIDAS toolbox. in the pdf, it said we can construct the standard residual in the process of GARCH-MIDAS. However,I read all of the codes, and I can estimate all the paras, I still can't get the standard residual in the equatation of the GARCH-MIDAS.

Looking forward to your reply!

Emma YoungHi Hang,

Thank your for your reply!

I will have a try.

Best wishes.

Emma

Hang QianHi Emma,

It appears that there are some ill-conditioned matrices (e.g., some variables extremely large or small) that triggered the warnings. I do not know the exact reason, but it might help to rescale the data, say, by normalizing them. You could also consider some parsimoniously model specifications.

Emma YoungHi Hang,

Thanks for your toolbox. When I run the code(DCC-MIDAS) with my own data. There is a wrong"Automatic gradients might be falsely computed. Capitalize arithmetic operator and utility function names.". I try to solve it, but failed. Would you mind tell me why? And also there is a "Covariance matrix of estimators cannot be computed precisely due to inversion difficulty. ". I am confused.

Looking forward to your reply!

Thank you!

Emma YoungHang QianHi Peng-Fei Dai,

The code supports a univariate macroeconomic variable. I do not have the code for more exogenous variables. You could consider forecast combination and model averaging. Each model corresponds to a regression with one variable, and then take the weighted average of predictive results.

Emma YoungPeng-Fei DaiHi Hang,

Thanks for your toolbox. I have used the toolbox to sovle some problems. I have a question somebody else have asked before. Prof. Ghysels published a paper "Stock market volatility and macroeconomic fundamentals"(2013,RES). In this paper, Prof. Ghysels sovled the equations(16) and (17) for different theta, showing the results in table 6 and 7. The two equations are about the multiple macro-factors on the right hand in the MIDAS equation (the longrun component). However, the MIDAS toolbox could just solve the problem with univariate macro-factor.

Best Regards

Brody Dai

Emma YoungHi Hang,

Thank your for your kindly reply! I want to know if the “fML" is ”function [logL,CorrMatrix,LongRunCorrMatrix] = fML(params,Resid,CrossResid,ResidCorr,period,nlagCorr,adjustLag,zeroLogL,beta2Para,rollWindow)“? In your code, what you compute is RV(realized variances). I think what I should modify is change this RV to a macroeconomic variable, which can be found in other paper(On the macroeconomic determinants of long-term volatilities and correlations in U.S. stock and crude oil markets wrote by Christian Conrad and etc.). So if I want to modify the RV, it is a big challenging for me? Because I need to cut the compute of RV and add macroeconomic variable to the model.

Another people told me that your toolbox can add macroeconomic variable to the model. So I am a little confused, because I can't find the macroeconomic variable in your toolbox, but she told me she can.

Thank you for your kindness!

Best Wishes,

Emma Young

Peng-Fei DaiHi Hang,

Thanks for your toolbox. I have used the toolbox to sovle some problems. I have a question somebody else have asked before. Prof. Ghysels published a paper "Stock market volatility and macroeconomic fundamentals"(2013,RES). In this paper, Prof. Ghysels sovled the equations(16) and (17) for different theta, showing the results in table 6 and 7. The two equations are about the multiple macro-factors on the right hand in the MIDAS equation (the longrun component). However, the MIDAS toolbox could just solve the problem with univariate macro-factor.

Beat Regards

Brody Dai

Hang QianHi Emma,

If you would like to add macroeconomic variables, you could modify the likelihood function by adding those variables, or write your own code for likelihood evaluation. If you could read DccMidas.m, there is a subfunction fML for likelihood evaluation. It is a bit challenging to modify the code, but the idea is to shift the conditional mean of the Gaussian densities by those exogenous variables.

Emma YoungHi hang,

Thanks for your toolbox. I am a new in matlab. I need use DCC-MIDAS to finish me paper, but I found that in your example of dcc-midas there isn't macroeconomic variable like CPI monthly. I want to add macroeconomic variable in the model to finish my research. Would you mind tell me what should I do to solve this problem? I notice some people asked you something about ext variable. I don't know if we have the same question.

Thanks again!

Emma Young

Hang QianHi Xuewei,

Yes, our GARCH-MIDAS program assumes that the disturbance term is normally distributed, so we compute log likelihood using the Gaussian density. In the GARCH-MIDAS program, there is a line of code looks like

% Compute GARCH-MIDAS log likelihood

logLMatrix = -0.5 .* ( log(2*pi.*Variance) + ResidSq ./ Variance);

If you’d like to use t distribution, you can replace the Gaussian density by the t-density.

Hope it helps,

Hang

XueweiHi Hang,

Is the disturbance term in GARCH-MIDAS model obeys normal distribution? I want to modify it to t distribution. How should I modify the code?

Kind Regards

Xuewei

John M. MashHi Hang,

I greatly appreciate your kindness. I will try to select the best name-value pairs to estimate the model.

Thanks again.

Hang QianHi John,

Yes, it is possible, as the model you are using is a complicated model, which cannot be as robust as a simple one like the linear regression. You could experiment on some different starting values by resetting the name-value pairs 'Mu0', 'Alpha0', 'Beta0', etc. If you could find a better starting value, the numerical optimization might work better. I would start from a smaller model with minimum lag orders, say two variables in a system with just one lag.

John M. MashHi Hang,

I really appreciate your suggestions. Following your advise, I try to set 'NumLagsVar' equal to 1. However, the stander error of the parameter cannot be estimated as follows:

mu 0.0011641 Inf 0 1

alpha 0.092243 Inf 0 1

beta 0.34799 Inf 0 1

theta 0.10806 Inf 0 1

w 23.078 Inf 0 1

m 0.025596 Inf 0 1

a 3.8105e-05 Inf 0 1

b 0.99996 Inf 0 1

w 5.0013 Inf 0 1

Is there any possibility that the data set is not suitable for the model.

Thanks again!

Hang QianHi John,

Yes, for monthly/yearly aggregation, 'Period' is 12, meaning 12 months in a year.

You may reduce 'NumLagsVar', which is the number of years of lags in the GARCH-MIDAS model. I would try 'NumLagsVar' equal to 1, as we usually do not have many observations for monthly/yearly aggregation. It would be safer to include smaller amount of lagged values.

John M. MashHi Hang,

Thank you for your quickly reply.

I try to omit the name-value pair 'ZeroLogL', but it does not work better.

I want to make sure whether the code is suitable for monthly/yearly aggregation and if setting the 'Period' to 12 (means there are 12 months in one year) is correct?

Could you give me some more advice about how to set the parameters for the estimation of monthly/yearly aggregation?

Best wish

Hang QianHi John,

Could it be a tool large 'ZeroLogL' value? It resets likelihood values of the specified dates to zero, but in a monthly/yearly aggregation, we usually do not have many data points. Does it work better if you omit the name-value pair 'ZeroLogL'?

John M. MashHi Hang,

Thank you for your code of DCC-MIDAS model.

I want to use the model to deal with monthly/yearly aggregation.

I try to set the period equal 12 as:

DccMidas(Data,'Period',12,'NumLagsVar',12,'NumLagsCorr',1,'options',options,'ZeroLogL',1:3600,'mu0',0.001);

However, the massage of “Covariance matrix of estimators cannot be computed precisely due to inversion difficulty” is shown and the t-value cannot be estimated.

Could you give me some advice about how to change the monthly data to yearly data?

Best wish

Chang LiuHi Hang,

Thank you very much for the insight. I will look into it.

Best regards,

Chang

Hang QianHi Chang,

For the toolbox functionalities, GarchMidas, DccMidas and MidasQuantile, there are name-value pairs that allow users to overload the default starting values. MIDAS_ADL is a wrapper of the original code and thus it is not easy to reset the starting values. However, if you could read and parse MATLAB code (including the programs in the subfolders), you may search code for numerical optimization programs like FMINUNC or FMINCON, where a required input must be the starting values and it also accepts optimization options of various kinds. If you could locate them, it would be your control panel. In principle you could directly modify any values there to have the full control over the nonlinear least squares or maximum likelihood estimation. Thank you.

Chang LiuHi Hang,

I really appreciate your suggestion. Could you tell me where to change the starting values for the optimizer?

Hang QianHi Chang,

When you run into convergence issues, it could be helpful to try a different starting value for numerical optimization and/or tune the optimizer configuration parameters. From the regression outputs, I saw that the first parameter of exponential Almon model is not well-behaved, as its standard error was not reported (perhaps it was a non-positive value implied by the Hessian matrix). In that case, you might consider various starting values other than the current one (i.e., -0.3994).

Chang LiuHi Hang,

I am trying to replicate Table 2 of Ghysels, Santa-Clara, and Valkanov (2005), i.e., regressing monthly excess returns of the stock market on variances estimated using daily excess returns, and keep running into convergence issues, especially regarding the two exponential almon coefficients. Also, the weights on the daily returns seem to decay at a faster rate than reported in the paper. Do you have any suggestions? Below is my output for your reference.

Frequency of Data Y: 1 month(s)

Frequency of Data X: 1 day(s)

Start Date: 01-Jan-1928

Terminal Date: 01-Dec-2000

Mixed frequency regression time frame:

Reg Y(01/31/28) on X(01/31/28),X(01/30/28),...,X(04/01/27)

Reg Y(02/29/28) on X(02/29/28),X(02/28/28),...,X(04/29/27)

...

Reg Y(12/31/00) on X(01/02/01),X(12/29/00),...,X(01/04/00)

Warning: The estimated parameter covariance matrix is not positive definite.

> In MIDAS_ADL (line 383)

In GSV2005 (line 45)

MIDAS: Normalized exponential Almon lag polynomial

'' ' Estimator' 'SE' 't-stat'

'Const' [ 0.0052] [ 0.0017] [ 3.0009]

'HighFreqSlope' [ 3.1202] [ 0.3762] [ 8.2930]

'ExpAlmon1' [ -0.3994] [ NaN] [ NaN]

'ExpAlmon2' [ 0.0015] [1.5861e-07] [9.1563e+03]

Goodness of fit: 0.14343

Noise variance: 0.00263

Log likelihood: 1361.5782

Akaike criteria: -5201.1367

Bayesian criteria: -5182.0353

RMSE Exp Almon: 0.0423

Your help will be greatly appreciated.

Hang QianDear Xuewei,

When the numerical optimizer cannot find a local optimum point, the Hessian is not necessarily negative definite, and then the matrix inversion may encounter problems. As a result, there could be a warning message that indicates singular matrix. You may consider experimenting with alternative optimization settings and other starting values for numerical optimization. Thank you.

XueweiDear Hang,

When I estimate the GARCH-MIDAS model with the exogenous regressor, the command window reports " Warning: Covariance matrix of estimators cannot be computed precisely due to inversion difficulty. and Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.224222e-18. " What‘s the meaning of this? Can you help me ??

Kind Regards,

Xuewei Zhou

Hang QianDear Jiaying,

If the software reports the probability of a = 1, it indicates that the data fit the model poorly, as the estimated parameter is not significant at all. Sometimes the numerical optimizer does not find a good solution. You may want to tune the model by resetting some of the name-value pairs like the starting value specifications for numerical optimization. For example, 'CorrA0' sets the MLE starting value for a. If the data really bad, it is possible that the software fails to find the numerical MLE.

jiaying wuDear Hang,

Thank you for your this toolbox to apply for DCC-MIDAS model, and I am new to the Matlab. I have a question to this code.

I am trying to apply 5 variables into the Data at the same time. I saw the Input Arguments for Data which is allow to put the T-by-n multivariate observation data. I try to change the file of appDCCMIDAS1:

CorrMatrix = reshape(CorrMatrix,25,nobs)'; (line 40)

LongRunCorrMatrix = reshape(LongRunCorrMatrix,25,nobs)'; (line 41)

In the first step estimation of GARCH-MIDAS, it runs perfectly. However, the problem is in the second estimation that the probability of a = 1, I assume this result is wrong. Do I need to change anything default setting for DCC-MIDAS code?

Regards,

Jiaying

Hang QianDear Cheng,

The problem you identified is common, but there is no good solution. The shape of the objective function is complicated and the numerical optimization solvers may not be able to find the maximum point. The software attempts to switch to a different solver if one solver fails. However, it is possible that no solvers manage to find the solution. Whether a non-convergent model can be used or not depends on how the model is used. If it is mainly a predictive tool, maybe it still severs for practical purposes, especially when over-fitting is a concern and it is not a bad idea to stop the training process earlier. However, for statistical inference (e.g. test the significance of an estimator), a non-convergent model cannot be used, because the theoretical properties of an M-estimator critically depend on the fact that the estimator is the maximum of the objective function.

zhou lan chengDear Hang Qian,

Thanks for you quick reply. I had some problems when I run the GARCH-MIDAS and DCC-MIDAS with my data.

1.I've tried multiple starting values when i run the GARCH-MIDAS. Most of the time it turns out "Covariance matrix of estimators cannot be computed precisely due to inversion difficulty.". Sometimes theta and m are not significant, and RMSE is almost always around 100. Does that mean I shouldn't use this model？

2.About DCC-MIDAS, no matter how I change the initial value, the result is always "FMINCON failed... Switch to FMINSEARCH." and "Covariance matrix of estimators cannot be computed precisely due to inversion difficulty. " How can I deal with these problems？

Best Regards,

Cheng

Hang QianDear Cheng,

When you put m = 5, it is approximately the day-week aggregation. The software ignores the NA values in the data, and uses the most recent 5 lagged values as the regressor. To run a MIDAS model, you may call the function MIDAS_ADL. The example files appADLMIDAS1 - appADLMIDA5 illustrate the functionalities. Thanks.

zhou lan chengDear Hang Qian,

Thanks for your tool box. I have two questions when i ues the toolbox.

1. I got weekly data as the dependent variable and daily data as the explanatory variable. m=5, but some data miss because of holidays. Accoring to the Usersguide, NA values should be used. I am a little confused.Wouldn't that make a big difference?

2. How to run MIDAS model in the toolbox?

Best Regards,

Cheng

Hang QianDear Anand,

I am not a Mac user and do not know how dates are handled in that operating system. Just now I run appADLIDAS1.m on a Windows machine with MATLAB 2018b, everything worked fine. It produced good outputs. There is no error. Maybe you could try the code on another machine?

anand singhDear Hang Qian,

Many Thanx for your quick reply. My language setting is US, English. you may like to see my output. I have emailed my output screenshot on matlabist@gmail.com

Best Regards,

Anand

Hang QianDear Anand,

Is it caused by the language setting of your operating system, if it is not U.S. English? In that case, the format of the spreadsheet could be different, especially for the date and time format. MATLAB may not be able to read the date and could generate an error.

anand singhDear Hang Qian,

Many Thanx for your quick reply. I am currently facing the below error, while running the example code with the your example data in (appADLIDAS1.m, appADLIDAS2.m, appADLIDAS3.m, and appADLIDAS4.m). I am using MAC and Matlab 2018b. The error which shown are given below:

The logical indices contain a true value outside of the array bounds.

Error in MixFreqData (line 89)

DataYdate = DataYdate(mask);

Error in MIDAS_ADL (line 264)

MixedFreqData = MixFreqData(DataY,DataYdate,DataX,DataXdate,xlag,ylag,horizon,estStart,estEnd,dispTime);

Please guide the possible reason for this error.

Best Regards,

Anand

anand singhDear Hang Qian,

Many Thanx for your quick reply. I am currently facing the below error, while running the example code (appADLIDAS1.m, appADLIDAS2.m, appADLIDAS3.m, and appADLIDAS4.m). I am using MAC and Matlab 2018b. The error which shown are given below:

Error in MixFreqData (line 89)

DataYdate = DataYdate(mask);

Error in MIDAS_ADL (line 264)

MixedFreqData = MixFreqData(DataY,DataYdate,DataX,DataXdate,xlag,ylag,horizon,estStart,estEnd,dispTime);

Best Regards,

Anand

Hang QianDear Anand,

Thank you for your interest in GARCH-MIDAS. Currently the code works with realized volatility or a macroeconomic variable. I do not have the code for multiple-variable regressions. Having multiple high-frequency series in a single MIDAS regression may run into near-colinearity issues which may impair the non-linear estimation procedure. For that reason Andreou et al. (2013) suggest using one series for potentially a large panel of high-frequency data and perform forecast combinations.

anand singhDear Hang Qian,

Many Thanx for this amazingly good toolbox on GARCH-MIDAS. I am new to this toolbox.

I would like to study on 3-4 Macro-variable. I tried to edit fML, and RV in GARCH-MIDAS, but failed. Is it possible for you to elaborate more on detail step to follow for addition of new macro-variable. Is it possible for you to publish another code with option to add more macro-economic variable code for benefit of others who want to study on GARCH-MIDAS but unable to correctly edit the code.

Hang QianDear wang huimin,

The GARCH-MIDAS can make use of either realized volatility or an exogenous variable, but not both. It appears that in Step 2, the GARCH-MIDAS process describes EPI only. The code does not describe RV+EPI, but you may try forecast combination if you have many exogenous variables.

wang huiminDear Huang Qian,

Hypothesis: we study on the Impact of Economic Prosperity Index, IP and Inf on Stock Market.

Step 1 Estimate the GARCH-MIDAS model and extract the volatilities

[estParams, EstParamCov, Variance, LongRunVar] = GarchMidas (y,'Period', period,'NumLags', numLags);

Step 2 Estimate the GARCH-MIDAS model with the exogenous variable

[estParams, EstParamCov, Variance, LongRunVar] = GarchMidas (y,'Period', period,'NumLags', 32,'X', xDay,'ThetaM', 1)

Is this GARCH-MIDAS process to describe RV+EPI or EPI only?

Question 1. If step 2 is used to describe the GARCH-MIDAS model with RV+EPI. If there are many other exogenous variables such as IP, inf, etc., will other exogenous variable replace EPI to create corresponding GARCH-MIDAS model? And just take the step 1 again to create GARCH-MIDAS model with EPI?

Question 2. If step 2 is only used to describe the GARCH-MIDAS model with EPI. How to modify the GARCH-MIDAS procedure of RV+EPI?

Hang QianDear wang huimin,

The name-value pair 'NumLags',32 means the number of lags in filtering the secular component by MIDAS weights. It is measured in terms of 'period' (in this example, it is 22, as in a day-month aggregation).

wang huiminDear Huang Qian,

Thank you for your answer! In addition, I want to ask you that what does 32 represent in estimating the GARCH-MIDAS model with the exogenous regressor?

[estParams,EstParamCov,Variance,LongRunVar] = GarchMidas(y,'Period',period,'NumLags',32,'X',xDay,'ThetaM',1);

Hang QianDear wang huimin,

The Name-value pair 'estSample',8000 represents splitting the data in two parts: the first part (i.e., from observation 1 to 8000) is used for parameter estimation, while the second part is reserved for one-step-ahead variance forecast and validation. The default value is that the entire series is used for parameter estimation and the forecast step is skipped. If you specify a value smaller than the sample size, then some observations will be reserved for forecast.

wang huiminDear Huang Qian,

What does 8000 represent in the sample forecast validation in Example1.

GarchMidas(y,'Period',period,'NumLags',numLags,'estSample',8000);

What does 8000 represent?

Hang QianDear Elbert,

I think the sum of the long-run correlation matrix and short-run correlation matrix is the total conditional correlation matrices. The software reports two of them, so you could obtain the third one by subtracting from the total correlation. Thanks.

Elbert LiuDear Hang Qian,

Many thanks for the toolbox. May I know how to get the short-run correlation matrix of DCC-MIDAS package? I can see that the output has long-run correlation matrix, but how can I make the short run one also available? Thank you.

Elbert

Hang QianDear Xuewei,

Yes, you are right. The code works for one covariate. If you really want to add more, you could adapt the code, especially in the local function fML, which computes log likelihood of GARCH-MIDAS. The variable params is a vector of unknown parameters in the model. If you have more variables, the length of the vector will increase accordingly. It does need some work for the sure. However, you may run into near-collinearity issues which may impair the non-linear estimation procedure if too may high frequency predictors are added. You may consider forecast combinations of multiple models, each of which contains a high frequency predictor. Thank you.

XueweiCHAO HUXueweiDear Hang,

Thanks for the toolbox. I find the code just run the one covariable in the GARCH-MIDAS. I want to add more macroeconomic variables into the GARCH-MIDAS. How should I modify the code? Thanks.

wang huiminDear Hang,

Thank you so much! Finally, I understand that my excel version is different, just change the format.

Hang QianDear wang huimin,

I have not seen that issue before. The function nanmean is in the Statistics and Machine Learning Toolbox. You may want to check if the toolbox is properly installed on your computer, and nanmean is not overloaded by another user-contributed function. You could validate the function by typing 'edit nanmean'. Also try to run the example file appGARCHMIDAS1, and compare the data format of the time series (i.e., y) with your data. Make sure it is formatted as a numeric column vector. You could also try to remove NaN values in the series manually. Thanks.

wang huiminDear Hang,

I tried to run the NASDAQ Composite Index program you wrote.

[estParams,EstParamCov,Variance,LongRunVar] = GarchMidas(y,'Period',period,'NumLags',numLags);

Unable to perform assignment because the left and right sides have a

different number of elements.

Error in GarchMidas (line 199)

y(isnan(y)) = nanmean(y);

How to change it?

Hang QianDear Robert,

Regarding the covariance matrix, it is common to see non-invertibility of the estimator covariance matrix. The most likely reason is the optimizer does not reach a local maximum, and the Hessian is not negative definite. There is no good solution to that problem, but you could try to fine-tune the optimization, say by a different starting value or a different optimizer setting.

As for the quotes of the paper, I would plug the coefficients w1 and w2 into the MIDAS polynomial (maybe the Beta density function?) and check if the corresponding weights are 0.1375 and 0.2755.

Robert AkungaRobert AkungaHi Hang, Another question, I am trying to interpret the results and need help with the following statement from the Engle 2013 paper 'Since the weighting function with w1 = 15.65 and w2 = 3.37 puts 0.1375 on the first lag and 0.2755 (which is the maximum weights) on the second lag of PPI level, we find that a one percent increase of inflation at the current quarter would increase the next quarter market volatility

by e0.28·0.1375 − 1 = 0.04 or 4%'. My query is how are they calculating the figures 0.1375 and 0.2755? Thanks.

Robert AkungaDear Hang,

Thanks for the code, love it.

Quick question, I'm running the GARCH MIDAS example on the data you've provided and when I run the option with macroeconomic variables I get a message on my covariance matrix of estimators, 'Warning: Covariance matrix of estimators cannot be computed precisely due to inversion difficulty'. Kindly assist, thanks.

Hang QianDear Kianoosh,

The ADL-MIDAS model explained in the user guide is the standard MIDAS model. See Andreou, Ghysels, and Kourtellos (2013). If you would like to estimate a variant of ADL models such as the paper you mentioned in the link you provided, I guess the best approach is to contact the authors for a copy of the reproduction code? Thank you.

kianoosh jahanmardiDear Hang Qian,

I don't understand the guide inside the Toolbax.

I want to estimate an ADL model.(Like this: https://www.sciencedirect.com/science/article/pii/S0140988317302657 )

Please introduce an paper that Matlab estimates for this model. And I can use its code.

Thank you

Hang QianDear Buelent,

The log likelihood reported by the package has the usual interpretation - higher value indicates a better fit. The reported value does not multiply by minus 1. The package calls fmincon for numerical optimization, but the conversion between maximization and minimization is handled internally. There is no impact on the user interface. The AIC and BIC criteria are computed as

aic = -2*logL + 2*numParam;

bic = -2*logL + numParam.*log(nobs);

Lower values of AIC and BIC indicate a better fit.

Buelent UendesDear Hang Qian,

I have a question regarding the reported LLF and its interpretation. As the LLF objective function is negative for the GARCH-MIDAS model, one needs to maximize the negative function or minimize -*LLF (multiply by minus 1 and then minimize it). The package uses fmincon (therefore finding a minimum). If I get the code correctly, the objective function for the GARCH-MIDAS is multiplied by -1 before finding the minimum. The reported LLF are all positive. Is then the interpretation to correct, to say that lower reported LLF indicate a better fit (in the sense higher value of the originial negative likelihood function?). Or am I mixing things up and the normal interpretation (higher positive likelihood function => better fit) stays in this GARCH-MIDAS package the same? Also, what is the correct interpretation of the BIC and AIC value for this package. Normally, lower values indicate a better fit and vice versa. If you could answer asap, I would be very happy.

Hang QianDear Zhou Changfeng,

If you could modify the GarchMidas program, you may add more covariates to the regression. In the code, there is a local function fML, which computes the log likelihood function of the model. The variable RV represents realized volatility or macroeconomic variables. If you have more variables, you could expand the length of RV (and more parameters to be estimated as well). The output of fML, namely the log likelihood value, will be sent to a MATLAB numerical optimization program fmincon/fminsearch. It needs some work, but you can have a try. Thank you.

Zhou ChangfengDear Hang Qian,

I want to add two covariates in the GARCH-Midas Model,how to revise the code?Thanks for your reply.

zhil hHang QianDear zhil,

There is really not much advice I can offer for panel-data MIDAS, as our code works solely for time series data. If you could write your own program, you may consider: 1) difference variables to remove unit-specific fixed effect; 2) impose MIDAS parameter constraints (i.e., force the regression coefficients decay by a MIDAS polynomial); 3) stack the differenced data as if they were cross-sectional regression data, and 4) call a nonlinear optimization package to do nonlinear least squares estimation. Just my two cents. Good luck!

zhil hDear Hang Qian,

Could you advise me how should I deal with this problem: My data is a panel data with 31 units from 2000 to 2017, y is annual data, x1 is quarter data, x2 is monthly data, x3 is daily data. Might you help me and tell me how to analyze the effect of x1, x2, and x3 on y respectively by using MIDAS? Thanks. I am looking forward your reply.

Duc Hong HoangHang QianDear Duc Hong Hoang,

I think it is easier to fix the data so that all periods have same number of trading days, then the weights will be the same for all months. An interpretation of MIDAS regression is that the high frequency data are weighted by the fixed number of lags (say 22). In that case, the regression does not necessarily correspond to the true calendar dates.

It would be challenging to modify the code. In that case, we will have to assign slightly different weights to each day in a month, depending on how many days in a particular month. If we consider irregular patterns like the leap years and holidays, that would make things more complicated.

Check the output variable MixedFreqData, which shows the structured high/low frequency data matrix used by the regression.

Duc Hong HoangDear Hang Qian,

Could you advise me how should I deal with the fact that the number of day in a month or quarter is not fixed. I mean that January may have 20 days, February have 21 days, March have 22 days and so on. Should I fixed the data so that all period have same number of trading days or I can modified the code to accommodate for that problem. Thanks

Hang QianDear Ben,

DCC-MIDAS model is fitted by maximum likelihood, and the unknown parameters are optimized by numerical procedures. If you want to add exogenous variables to DCC-MADIS, you could modify the likelihood function. In the code, there is a local function called fML, in which you could insert the exogenous component into the objective function. It needs some work, but in principle you could customize the code to your own model. You could enter the debugging mode of MATLAB, and see how the objective function is optimized internally.

Ben WanDear Hang Qian,

How can I add exogenous variables to DCC-MADIS so that we can get the result of 5 parameters estimation instead of 3 parameters?

Thank you very much in advance,

Ben.

MaartenHang QianDear Maarten,

It is a good question. The assumption on the normalized weights summing up to one helps us compare MIDAS with the traditional regression with temporally aggregated series. With the normalized weights we formulate a linear combination of high frequency series, which is the analogue to the aggregated series under a flat weight.

The weights reported by the software are the unnormalized weights. In practice, the way to obtain the normalized weights is to divide the unnormalized weights by their sum. The sum corresponds to the coefficients of the linearly combined high frequency series.

Looking at line 561 of the program MIDAS_ADL, we see how the fitted values are computed by the unnormalized weights:

yfit = estParams(1) + EstX * weightsNN + EstLagY * estParams(end-ylag+1:end);

If we are interested in the normalized weight, just compute weightsNN / sum(weightsNN).

Hope it helps,

Hang

MaartenDear Hang Qian,

Thank you for the toolbox. While running the example code (appADLIDAS1.m) as well as my own code with my own data, I noticed a possible issue with the estimated weights from the MIDAS regression. I found that when using the normalized beta density and normalized exponential Almon lag polynomials, the weights do not appear to be normalized i.e. that the weights do not sum up to one and the value of the first weight is often more than one. From my understanding from the user guide (V2.3) and MIDAS models, these weights are assumed to be within the unit interval and sum to one. Could you please explain why the estimated weights violate this assumption?

Thank you in advance.

Hang QianHi Aya,

In the MIDAS regression, lagged x and y are treated differently. Lagged y of {3,4} indicates that y(t-3) and y(t-4) are standard predictors in the regression and their coefficients are free of constraints. However, the coefficients of lagged x are assigned MIDAS weights to prevent parameter proliferation. We cannot choose specific lags we wish to include, because MIDAS requires a certain coefficients decay pattern, while exclusion of some lags means coefficients taking a value of zero.

Aya GhalayiniHi Hang Qian,

Thank you for the toolbox support again.

I understand that in the ADL MIDAS, the ylag can be chosen {3,4} or any other lags we specifically want to include in the regression. What about xlag, is there any reason why can't we choose the specific lags we wish to include? Say I want to include the 5th and 8ths lag of X for some reason, is there a way to do this or I will have to do some changes in the code?

Thank you very much in advance,

Aya

Hang QianHi Aya,

Thanks for your interest in the toolbox. Yes, you are right. Different versions and platform may yield somewhat varied numeric results. It is good to hear that you figured out the spreadsheet data problem.

Aya GhalayiniHi Hang Qian,

I just figured out that using MATLAB on MAC sometimes have a problem when dealing with reading from excel. It turned out that some of the data were read as string so imported as NaN. Therefore, I used the following code before using the data:

for idx = 1:numel(raw2)

if isnumeric(raw2{idx})

raw2{idx} = num2str(raw2{idx});

end

end

It solved the problem!

Thank you for this Toolbox, very beneficial and user-friendly!

Aya GhalayiniHi Hang Qian,

I am a new user to this toolbox. I am using MAC and Matlab 2018b. I started by replicating the user guide. I am not getting the exact results for the GARCH-MIDAS as the one included in the user guide. The results are not hugely different but are not approximately equal. Could you please explain why would that be possibly the case?

Thank you very much in advance!

Much appreciated.

YanyanHang QianHi Chen Shu,

There is really no good way to address the invertibility problem of the covariance matrix. It mostly occurs when the numerical optimization program cannot find a better parameter vector that maximizes the likelihood function. Sometimes it helps to start from a simpler model and get a reasonable initial value for a more sophisticated model. I would also inspect the properties of the data. For example, are there any collinearity issues? Does a subset of data work for the regression?

chen shuHi Hang Qian,

Thanks for the toolbox. When I run the DCC MIDAS code, results in the first step GARCH part is fine, but in the second step DCC part, it says that "Warning: Covariance matrix of estimators cannot be computed precisely due to inversion difficulty and Warning: Matrix is close to singular or badly scaled." The standard error is infinity and actually I think there are no iterations at all. The reported "a,b,w" is exactly the initial value. I've tried many combinations of lags and initial value, but none of them works. Do you have any ideas why and how should I solve this problem? Is it more possibly due to the properties of my data process or the model specification?

chen shuHang QianHi John,

The warning message on the estimator covariance matrix is common. Usually it indicates that the numerical methods do not converge to a local optimum point. There is no good solution, but you may try to modify the starting values or model specification.

Hang QianHi Gary,

People have different opinions on the lag order selection. In my view, I would use more lags if the sample size is large. After all, weights for higher order lags are smaller.

garyHi Hang Qian

Thanks for your answer，and there may be another question about how to decide the number of lags K？

John WongThank you sir, may I ask also why when I run this code, "[estParams,EstParamCov,Variance,LongRunVar] = ...

GarchMidas(y,'Period',period,'NumLags',32,'X',xDay,'ThetaM',1)"; it says that "Warning: Covariance matrix of estimators cannot be computed precisely

due to inversion difficulty.

> In GarchMidas (line 311)

Warning: Matrix is close to singular or badly scaled. Results may be

inaccurate. RCOND = 3.369565e-17.

> In GarchMidas (line 313)"?

Hang QianHi John,

The tilde operator in [~, yDate] and [~, yDateMonth] means suppressing unused variables from the output arguments. It can be replaced by anything, but MATLAB code analyzer will issue a warning on the used variables. The variable nobs is defined in the previous sections of the code. That is, nobs = size(y,1); The code needs to be run from the beginning of the program appGARCHMIDAS1.m.

John WongJohn WongSir, in the command

% Repeat the monthly value throughout the days in that month

[:,yDate] = xlsread('NASDAQCOM.xls','A22:A11669');

[:,yDateMonth] = datevec(yDate);

xDay = NaN(nobs,1);

count = 1;

for t = 1:nobs

36

if t > 1 && yDateMonth(t) 6= yDateMonth(t-1)

count = count + 1;

if count > length(xMonth)

break

end

end

xDay(t) = xMonth(count);

end

what code is supposed to replace the : in the [:, yDate] and [:, yDateMonth]? Also, why does it keep saying that there is an undefined function or variable nobs?

Hang QianHi Gary,

Thank you for your interest in the toolbox. In GARCHMIDAS, there is a local function midasBetaWeights that computes the MIDAS weights. This function is called by the objective function fML. To see the weights in a fixed window estimation, you may modify the code by adding an output argument to fML, say in line 432, add

[logL,Variance,ShortRun,LongRun, weights] = fML(…)

Then in line 387, put

[~,Variance,ShortRunVar,LongRunVar, weights] = fML(…)

Finally, change the signature of GARCHMIDAS so that it returns the weights like

[estParams,EstParamCov,Variance,LongRunVar,ShortRunVar,logL, weights] = GarchMidas(…)

garyHi Hang Qian

Thanks for your toolbox. I have a question that how i can get the figure aboout weighting functions in GARCHMIDAS?

Hang QianHi Ying,

The MIDAS_ADL function can handle calendar days in a month, which does not always have the same number of days. The software returns an output variable MixedFreqData, from which you can inspect how the mixed frequency data (response and explanatory variables) are structured. The warning message could show in some data set. Ideally, at a local minimum of the least squares, the Hessian matrix is supposed to be negative definite. However, the numeric optimization program may stop at a saddle point where the Hessian is not negative definite. As a result, when the negative Hessian is inverted, the covariance matrix cannot be computed reliably. Sometimes the warning message disappears if the model specification is modified slightly.

YingHi Hanq Qian,

Thanks for your toolbox. I'm a very new user of midas approach. I have the problem about when using month-date data, if I need to keep the number of days of every month equivalent? When I apply MIDAS_ADL funtion to month-date data to replicate Ghysels E , Santaclara P , Valkanov R . There is a Risk-Return Tradeoff After All[J]. Journal of Financial Economics, 2005, 76(3):509-548, I received the warning "The estimated parameter covariance matrix is not positive definite." But I don't know if it's because of the data or some other reasons.

All the best

YING Wu

yuexian tangDear 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 GARCH-Spline model.

All the best

Yuexian Tang

Hang QianDear Yuexian,

Sorry, I do not have GARCH-Spline code. Perhaps the best way to get the code is to contact the authors?

yuexian tangDear Hang Qian,

Thanks for your reply. Do you know where to get the code for the GARCH-Spline model (Engle and Rangel, 2008) because I want to make a comparison between the GARCH-SPLINE and GARCH-MIDAS model in terms of forecasting performance.

All the best

Yuexian Tang

Eric GhyselsDear 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, 207-230.

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 regression-based set of Granger causality tests in a mixed frequency data setting.

Sincerely,

Eric Ghysels

Hang QianDear 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 LueDear 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 QianDear 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 apple-to-apple comparison and the log likelihood values are monotonously decreasing with more lags.

Hope it helps,

Hang Qian

yuexian tangDear Hang Qian,

When I run the original code of GARCH-MIDAS 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 QianDear 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 gradient-based maximum likelihood optimization. The GARCH-MIDAS 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 short-run component of the conditional variance can be specified as Egarch, and the long-run component is determined by the realized volatility or macroeconomic series, which is specified as a MIDAS regression.

yuexian tangDear Huang Qian,

when I read the code of GARCH-MIDAS, 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 LueHang QianHi 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 name-values pairs for adjusting the starting values, like 'Mu0', 'Alpha0', 'Beta0', 'Theta0', etc.

Zhou ChangfengHi 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 DengHi 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 GhyselsDear Chengtao:

Regarding extensions of the DCC-MIDAS 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 QianHi Chengtao,

It is good to know that you are extending the DCC-MIDAS 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 DCC-MIDAS, 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 positive-definite constraints. Good luck!

Best,

Hang Qian

Chengtao DengHI Hang Qian

Thank you for your timely reply! I tried to change the univariate GARCH model to make it become a GARCH-X 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 (1-a-b-x)>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 stock-bond portfolios: international evidence". In this article they introduced a dcc-rc-x model that I think is helpful to our discussion. Look foward to your reply.

Hang QianDear Chengtao,

The toolbox function DccMidas follows a two-step model specification and estimation strategy. Conditional variances are obtained from the univariate GARCH-MIDAS models with the long-run 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 name-value pair 'X'. Perhaps macroeconomic data could be inserted in the first-step univariate regressions?

Chengtao DengDear 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 QianDear xiaohui,

When we change the name-value pair 'LogTau', we switched to a different model specification (in which long-run volatility is modelled in logarithm). Similarly, resetting 'Beta2Para' leads to a model where we use two-parameter Beta MIDAS polynomial instead of one-parameter Beta polynomial. Different model can give us different results. Setting an appropriate starting value for MLE is a trial-and-error process. A good starting value needs to be close enough to the true (but unknown) value of parameter.

xiaohui zhaoDear 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 P-value of the theta changed a lot (the significant value to insig, while the insig-parameter changed to significant value). And when I changed the starting value of the 'Theta0' the P-value 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 QianDear 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 name-value 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 zhaoDear 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 QianDear 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 Name-value pair ''thetaM'' is set to true. In that case, the parameter theta and m in the long-run volatility component can be either positive or negative.

karim belcaidDear 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 Name-value 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 QianHi Fu Wang,

Sorry for the confusion. The GarchMidas function has a name-value pair 'X' for macroeconomic data that determines the long-run 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 name-value pair 'X' when GarchMidas is called. I am not sure if really works, but you are encouraged to try this name-value pair. Also, the name-value 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 name-value pairs related to initialization. It is good to try various values to make the numeric optimization works well.

Fu WangHi Hang Qian

Continuing the discussing of dcc-midas 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 dcc-midas 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 dcc-midas model .

Hang QianHi 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.

ClaireHi, 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 QianDear qiu luo,

When we set 'thetaM' to true, the program does not take the squares for the parameter theta and m in the long-run 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 name-value pair, whose default value is due to compatibility for the original code that comes with the journal article.

qiu luoDear 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 Name-value 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 QianHi Fu Wang,

I am not sure how to add exogenous variables into DCC-MIDAS. 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 general-purpose software program, it might not work well as we expected.

Fu Wanghi Hang Qian

thank you for providing the DCC-MIDAS code. There is a problem confusing me for a long time .that is how can we add the X into the DCC-MIDAS model just like the Garch-MIDAS 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 QianHi qinmeng,

Thank you for clarification. Maybe you are right, though I am not sure.

qinmeng qindear Hang,

ρ dfi is the（d,f）element of ρ i, then day t in month i

Hang QianHi 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 qindear 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 QianHi 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 gradient-free 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 LeHi 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 p-value for estimated parameters based on Newey-West 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 QianDear Ruobing Liu,

If the estimated long-run variance looks unreasonable, I would check parameter estimation first, as the long-run 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 macro-variable never changes values over time, perhaps no regression can generate meaningful estimation results.

Hang QianHi 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 (1-j/n)^(theta-1), 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 QianHi hellocate,

The number 0.7071 represents sqrt(2)/2. We inverse the normal c.d.f. to obtain the p-value, 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 re-scale the variable so that the results are more interpretable.

Ruobing LiuDear 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 long-run variance is pretty big, which is larger than 1, for the model without the macroeconomic variables, the long-run variance is pretty small, about 0.0001. I want to know is the difference normal?

hellocateHello 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 LeHi 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 KanjooHang QianDear 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 near-colinearity issues which may impair the non-linear 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): 240-251.

qinmeng qinDear 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 QianHi 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.

ClaireHi 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 QianHi Stefan,

Yes, with lagged y included as additional predictors, it is an ADL-MIDAS model.

StefanThanks 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 ADL-MIDAS isn't it?

Hang QianHi Stefan,

A baseline MIDAS model consists of a low-frequency dependent variable y and a high-frequency explanatory variable x. The regressors involve lagged x.

A DL-MIDAS model consists of a low-frequency dependent variable y, a high-frequency 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.

StefanHello Qian,

I looked at the manual once more and got another question. What is the difference between the DL-MIDAS 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!

StefanThank you very much for your fast reply Hang Quian and Prof. Ghysels!

Hang QianHi 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 mis-specifications and therefore inconsistent parameter estimates. In an ADL-MIDAS there is no restriction between the AR parameter(s) and the MIDAS polynomial parameters.”

Hang QianHi 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 high-frequency predictors, but with low-frequency autoregressive predictors the software appears well-behaved.

StefanHello Hang Quian,

thanks for the toolbox! I'm just a little bit confused about the ADL-MIDAS 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 ADL-MIDAS) and a standard MIDAS equation augmented with an autoregressive lag. Why does the problem not occur here? Thanks for your help!

Hang QianHi 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 well-defined problem.

In the U.S., the commonly used value format is 7.26 (seven point twenty-six), which is also used by MATLAB software.

mantuhi 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 QianHi 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 non-convergence of the numeric solver. There is no good solution, but you may try different starting values for the parameters by resetting the name-value pairs 'Alpha0', 'Beta0', etc. You may also consider more accurate gradient computation, by setting the name-value pair 'Gradient'. If the data really fit the model poorly, consider alternative model specifications such as adding/subtracting some lags by the name-value pair 'NumLags', resizing the estimation window by the name-value pair 'EstSample'.

mantuhi 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 QianDear Ruobing,

The default behavior of the software is to restrict one MIDAS parameter to unity.

There is a name-value pair 'Beta2Para', which is a logical value that indicates two-parameter Beta MIDAS polynomial.

Ruobing LiuDear Hang

I have one question about the GARCH-MIDAS model and the MIDAS toolbox. Based on the MIDAS Matlab toolbox equation 3.24, the GARCH-MIDAS 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 GhyselsDear Erik:

Both EViews and midasr allow for multiple HF regressors (even with different frequencies). Multi co-linearity 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 StenbergHi,

I wonder how/why Eviews can handle these near-collinearity 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 QianHi Ruobing,

When the name-value 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 GARCH-MIDAS is computed.

Ruobing LiuDear Hang

Thank you so much for your toolbox, I have problems with the GARCH-MIDS model. As I run the regression to obtain the long-run 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 QianDear Alberto,

I am not sure if it could resolve your problem, but you may consider the following: 1) resetting the name-value pair 'ThetaM' to 1, which indicates not taking squares for the parameter theta and m in the long-run volatility component; 2) resetting the name-value 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.

EricAlberto:

I forwarded your questions to Bumjean Sohn who will be able to help you

Eric

Alberto GrassiDear Hang,

Thank you for your toolbox. I have problems with the GARCH-MIDAS 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 QianThank 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 near-colinearity issues which may impair the non-linear 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): 240-251.”

Andrianos TsekrekosExcellent work. Thanks for sharing. How would one go about extending the code to multiple high-frequency variables (even just for the umidas option?

Hang QianHi 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 SandovalHi there, I hope you are keeping well. I am novice about GARCH-MIDAS 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 QianHi Sebastian,

The GARCH-MIDAS 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 name-value 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 kHi,

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 GARCH-MIDAS 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 QianHi 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.

mantuHi 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 'yyyy-mm-dd' 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 QianDear 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 GARCH-MIDAS model specification. For the software, the name-value pair 'X' specifies macroeconomic data that determines long-run conditional variance. If X is not specified, realized volatility will be used.

hellocateDear 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 QianHi lu chen,

As its name suggests, QuasiCorrMatrix is a quasi-correlation matrix in which the diagonal elements have not been normalized to one, because the elements of the matrix are time-varying. 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 chenHi 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 QianHi 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.

mantuHi 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 QianHi Amar,

That sounds interesting, but the model you described is not MIDAS. It is a new model that requires

your own estimation method.

amar soebhagHello 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.

mantuooo ok, thank you Qian you re very helpfull

Hang QianHi mantu,

Our GarchMidas MATLAB program supports one-parameter and two-parameter Beta polynomial, using the name-value pair 'Beta2Para', which is a logical value that indicates two-parameter 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.

mantuHi Qian and my economist fellas, I ve solve the matlab but I couldnt figure out how beta lags work in GARCH-MIDAS model. I ve tried to use ϕk(ω) beta lag formulate to figure out how does beta lags solve in engle-ghysels-sohn 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)^(w1-1) *(1-k/K)^(w2-1))/(∑(j=1 to K)(j/K)^((w1-1)) * (1-k/K)^(w2-1) ) → beta lags

Hang QianHi 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 GARCH-MIDAS program) by more advanced global optimization tools.

Ting XIAHi, Hang.

Thanks for your suggestion.

Resetting the AdjustLag and fine-tuning 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 QianDear Ting XIA,

Thank you for your interest in our DCC-MIDAS 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 day-month 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 fine-tune the optimization options by the name-value 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 XIADear Hang,

Thank you for your excellent toolbox.

I come across a problem which troubles me a lot when running the Dcc-midas 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 QianDear Pingjun,

I think multiple-period forecast can be achieved by setting the name-value 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.

dengpingjunDear 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 'h-step-ahead' forecasting. I read the manual in this toolbox, but I cannot find the corresponding augment associated with 'h-step-ahead' forecasting. How can I adjust the input augments’ settings of 'MIDAS_ADL' for this purpose.

Hang QianDear 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.

dengpingjunDear 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:end-1))*100;

DataYgrowth = log(DataY(2:end)./DataY(1:end-1))*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 'h-step-ahead'? Can you give me a reply?

Best regards

Pingjun Deng

Hang QianHi tr206,

'thetaM' is an optional input argument, as a name-value 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 long-run volatility component. The default is false (they are squared). So if those two parameters are allowed to be negative, reset the name-value pair 'thetaM' to true.

tr206Hi Hang,

I am running the GarchMidas for a macroeconomic variable and I sometimes get the warning

Warning: Reset the Name-value 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 QianHi 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 name-value 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 name-value pairs 'Mu0', 'Alpha0', 'Beta0', etc. for resetting the initial values. As for the lag order selection, you may profile the results under different lag-order 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 GrassiDear Hang,

I am coming across some troubles while I'm comparing the Garch-midas 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 Qiantr206 - In the toolbox, there is a utility function ForecastCombine.m, which handles forecast combination of ADL-MIDAS 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 general-purpose software cannot cover them.

tr206Dear 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?

EricDear 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 near-colinearity issues which may impair the non-linear 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): 240-251.

Hang QianHi 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 GARCH-MIDAS model and then combine them manually.

tr206Hi 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 Garch-Midas model. Nevertheless, you are saying that forecast combination of different models could be a reasonable workaround? Are you refering to FORCASCOMB in Matlab?

Ruiting ChenHi 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 QianHi tr206,

The program only supports one high-frequency 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.

tr206Hi 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 QianHi 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.

Amor-Aniss BenmoussaHello, I think there is an error in the code. For example, for a two-quarter 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 QianHi Alberto,

The paper you mentioned used different software/programs, and I wrote a MATLAB program GarchMidas last year, just to illustrate the idea of GARCH-MIDAS 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 GrassiHello 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 QianHi 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.

mantuHello 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 XIAHello Hang

Thank you for your advice “Also consider setting the name-value 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 QianHi Anup,

Matlab 2011b is an old version that does not support some name-value 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.

czbx51Hi 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 24-Mar-2003 due to lagged regressors. Reset start date to 24-Mar-2003 ". But it cannot run with the exoregs. I cut Y to the suggested starting date and it works well.

Anup ChowdhuryDear Qian,

Many thanks for uploading this fantastic resource. I am using Matlab2011b version and getting following error messeages:

For ADL-MIDAS:

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 GARCH-MIDAS:

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 QianHi 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.

czbx51Hi 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 QianHi Ning,

The toolbox supports multi-step 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 out-of-sample forecast after DataY is exhausted.

ning xuHi Hang,

First, Thanks for uploading this toolbox! Especially the ADL-MIDAS is very useful to me.

I wonder how do you perform h-step ahead forecast using this toolbox? I have referred to the MIDAS user guide for the multi-step forecast, but I still don't understand how to operate. Can you give me an example?

Thank you.

Hang QianHi 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 RyanHi Hang,

Thank you for the nice toolbox. Whe I ran the code of the GARCH-MIDAS model, no problem emrged. When I ran the DCC-MIDAS 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 QianHi 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 QianHi 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 high-frequency 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.

YuDear Hank,

I want to estimate a two-component(or more components ) GARCH-MIDAS model, e.g., two or more macroeconomic fundamentals once in a GARCH-MIDAS model.

Is it possible?

Thank you very much!

Sebastian BenteleHi 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 AR-process 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 lyuHang QianHi Johann,

I am sorry but there is no such magic function that could identify the appropriate starting values for numeric optimization.

johann guenkelHi 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 QianYes, increasing the number of iterations may help convergence. For GarchMidas.m and DccMidas.m, there is a name-value 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 guenkelHi 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 guenkelHi 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 QianHi 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 guenkelHi 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 QianTing -

The name-value 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 name-value pair 'LogTau' if the regressor X is other than the realized volatility.

Ting XIAHello 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 QianTing - 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 XIAHi 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 LExcellent 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 LSam RollandThank you Hang

It was my date configuration for the Y-data. I had chosen different representations of quarterly data. Eventually worked with a 1 lead configuration.

Hang QianHi 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 RollandHello Hang

I am trying to run a basic nowcast (Horizon= -2) variation of the model, using MIDAS1- My Y-Data goes to 2016-06-30, and my X-Data goes to 2016-08-31. However, when I try and run the model at EstEnd: 2016-06-30, there is no OutputForecast produced, and when I take it back (say, a year), it only goes to my last Y-Date. Why would this be, and where should I be looking to make it that I can produce a forecast for 2016-09-31?

Thanks in advance

Hang QianHi 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 LeHi 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 AbbasHang QianYes, 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 RollandHi 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 out-of-sample 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 QianProf. 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 co-linear, 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 QianHi 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 RollandHello 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 QianHi 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 GuoHello,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 QianHi 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 name-value pairs. Also, turn on 'Gradient' and try to set the FMINCON 'Options' and see how alternative numeric optimization algorithms work.

Chen RyanHello,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 GARCH-MIDAS and DCC-MIDAS 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 GARCH-MIDAS and DCC-MIDAS models? Thank you!

Jasonhi 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

JasonHI Hang Qian

I am using 2014a matlab ,is it possible that the error is caused by the version difference?

thank you

Hang QianHi 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.

JasonHi Hang Qian

I am using the DCC-midas command. I follow the

the code in the user guide

options = optimoptions('fmincon','Algorithm','active-set');

[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 QianHi 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 BlanchetHello,

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 QianHi Amor-Aniss,

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.

Amor-Aniss BenmoussaHello , 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 ZhangHi Hang Qian,

Thank you very much.

Stephen

Hang QianHi 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 274-283 by whatever estimation method.

Thank you.

Stephen ZhangHi 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 Garch-Midas, 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 AiHang QianHi 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 gomezHello:

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 TopiDear Hang Qian,

Dear Eric,

many thanks for your responses.

Regards,

Topi

EricDear 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 QianDear 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 TopiDear 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 QianDear Test Topi,

The DCC MIDAS codes support an arbitrary number of series. Just provide a T-by-n matrix input to the function DccMidas(...). The output variables CorrMatrix and LongRunCorrMatrix should be n-by-n-by-T. 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 TopiDear Hang Qian,

many thanks for the DCC MIDAS code. However, I wonder if it is possible to change the tri-variate code for DCC MIDAS in order to estimate a bi-variate DCC MIDAS model? Should I replace the output arguments for CorrMatrix and LongRunCorrMatrix?

EricDear Raphael:

In the ADL-MIDAS 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 U-MIDAS or MIDAS with stepfunction - in which case one uses again information criteria

Raphael ZagagliaHi, 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 QianHi 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!

HafizeHi 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 t-values 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 QianHi 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 cross-equation 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 DCC-MIDAS regression.

Joyce LHi!

Thanks a lot for this matlab package.

I am studying DCC-Midas 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 QianHi 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 DoanHi 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'mm-dd-yyyy 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.67E-06

01/03/1974 0.000474398

01/04/1974 7.40E-05

01/07/1974 6.41E-05

Hang QianHi Daisy,

Daily-monthly aggregation is unbalanced, and I am not sure if the program’s data-date conversion routine can work properly in that case. However, you may try Xlag = 22 so as to approximate daily-monthly 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 DoanHi 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.67E-06

01/03/1974 0.000474398

01/04/1974 7.40E-05

01/07/1974 6.41E-05

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

ququxiHi 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 QianHi EMEL,

It appears that your MATLAB does not recognize the ‘private’ folder. It might be caused by some global preference that overloads the default file-system 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 ODABASIHi 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 QianHi Xiaojun,

Though the software supports a single macroeconomic variable, the GARCH-MIDAS 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 6-by-n estimated parameters for [mu;alpha;beta;theta;w;m] obtained from univariate GARCH-MIDAS models

Chu xiaojunHi 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 QianHi Aniss,

The codes address one high frequency regressor. In your case, one quarterly variable with one or more yearly variables. Thank you.

Amor-Aniss BenmoussaHello,

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 QianHi KK Chen,

The MIDAS toolbox supports multiple low frequency regressors. Users may specify the name-value pairs 'ExoReg' and 'ExoRegDate', where the former is a matrix of low-frequency 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 ChenHi Qian,

May I know if the MIDAS function supports multi-factors 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 TwireHi 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);

Amor-Aniss BenmoussaHi Hang Qian,

Thanks you!

I solved the problem, which came from the convertion of time in excel to Matlab.

Amor

Hang QianHi 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 Non-Zero: 0.3311

RMSE Exp Almon: 0.3395

RMSE U-MIDAS: 0.3272

RMSE Stepfun: 0.3245

RMSE Almon: 0.3376

Thank you.

Amor-Aniss BenmoussaHi 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:end-1,2))*100;

DataYgrowth = log(DataY(2:end,2)./DataY(1:end-1,2))*100;

DataYdate = DataY(2:end,1);

DataXdate = DataX(2:end,1);

DataX=DataXgrowth;

DataY=DataYgrowth;

Thank you,

Amor

Hang QianHi Nicolas,

I wrote the GARCH-MIDAS 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 pre-treat the data have to be exactly the same).

Also, I feel that GARCH-MIDAS 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 SoemerHallo,

First of all thanks for the toolbox. Especially the GARCH-MiDaS 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

wangHi Hang Qian,

Thanks for your rely!

Best regards,

wang

Hang QianHi 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 one-step forecasting period.

Thank you.

wangHi 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:end-1);yPseudo;0];

end

wangHi Hang qian,

Thank you very much for your rely.

Hang QianHi Wang,

Thanks for your interests in the toolbox. In reply to your question about the out-of-sample 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 GARCH-MIDAS variances recursion is given by g(i,t) = (1-a-b) + a * (y(i-1,t)-mu)^2/tau + b*g(i-1,t). In an out-of-sample forecast, the squared yPseudo works as if it were the squared y(i-1,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.

wangHi Hang Qian,

thanks for your wondeful toobox. In Out-of-sample forecast, yPseudo = estParams(1) + sqrt(Variance(end)); why not is yPseudo = estParams(1) + sqrt(Variance(end))*Resid.

Di MoHang QianThe “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 MoHi Hang Qian,

Thank you for the quick reply. I have received another wrong message when running the GARCH-Midas Command. The error is as follows:

Undefined function or variable 'nobs'.

Do you have any suggestions on this?

Kind Regards

Di

Hang QianHi 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 MoHi 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','interior-point','Display','notify-detailed');

Could you give me some advice on this please?

Thank you very much!

Best,

Di

Hang QianHi 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 YudhistiraHi 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 QianHi 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 QianHi 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.

jenniferThanks 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 HuangHi 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 QianHi 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 name-value 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 StephanThank 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 4-6 I get a similar error for models 1-3.

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

SaeedThanks 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

EricDear 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

SaeedDear 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.

EricDear 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

PhilippeHello,

Is it possible with this code to run multivariate MIDAS regressions? If not, how could it be implemented?

Regards,

Philippe

EricDear Du-hyun:

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 ARCH-type 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

Du-hyun ChoIt 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

Du-hyun ChoIt 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

EricDear Du-hyun:

Would you mind being more specific about asymmetric MIDAS - what exactly you are thinking of?

Thanks

Eric Ghysels

Du-hyun ChoThnak 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 QianHi Du-hyun,

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.

Du-hyun ChoHi 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 QianHi 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, 01-Mar-2000 15:45:17 and 2000-03-01 15:45:17 can be recognized by MATLAB.

Thank you.

Ruizhi MaHello! Really thanks for the upload! I'm curious about using intra-daily data to forecast daily stock returns by MIDAS, how can I write the DataXdate and DataYdate ? Thank you!

Anni208Thank you for the very fast answer!

I will follow your advice!

Hang QianHi 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', '1947-01-04', '04-Jan-1947', '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.

Anni208Hello!

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

WMendieta89Thank you very much for your reply! It worked!

Thanks again for this great toolkit.

William M.

Hang QianHi WMendieta,

MIDAS uses a direct multi-step forecast. For example, if we want a 3-step ahead forecast, we specify a MIDAS model as

Y(t+3) = b0 + b1*Y(t) + b2*Y(t-1) + ... + high frequency regressor terms X(j,t-i), j=1,...,Nd, i = 0,1,2,...

Similarly, for a 5-step ahead forecast, we use a model like

Y(t+5) = b0 + b1*Y(t) + b2*Y(t-1) + ... + high frequency regressor terms X(j,t-i), j=1,...,Nd, i = 0,1,2,...

By direct forecast, we mean the left hand side of the model is the h-step 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 multi-step 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 name-value pair 'Horizon' accordingly.

Thank you.

WMendieta89Hi! Thanks for uploading this toolbox! I wonder how do you perform h-step ahead forecast using this toolbox? I have performed 1 step ahead out-of-sample forecast but i´ve been unable to do so for h-step ahead forecasts

thanks in advanced,

WMendieta