Bivariate Markov switching auto regressive model

1 vue (au cours des 30 derniers jours)
Marco Santorsola
Marco Santorsola le 23 Mai 2022
Commenté : William Rose le 24 Mai 2022
Hi everyone, I need to run a bivariate Markov switching auto regressive model employing 2 time series of financial returns and I need to plot the smoothed probability of being in a bull state for each time series. The Matlab code is not returning this. Can anyone help me?

Réponses (1)

William Rose
William Rose le 23 Mai 2022
Please post the equations describing the evolution of the two variables of the bivariate Markov process. Since it is a switching auto regressive model, I assume that each variable can, at each time step, switch from one state to another. I assume that the probability of switching depends on the immediately preceding value of that variable (autoregressive). I assume the change of each variable with each time step, depends on both variables (bivariate) and depends on the state that each variable is in. Expalin if my assumptions are correct, and fill in the details.
Please define "being in a bull state". Two possibilities (among many) are 1. "The most common definition of a bull market is a situation in which stock prices rise by 20%, usually after a drop of 20% and before a second 20% decline." (Investopedia). This definition can only be identified retrospectively. 2. A bull state is the state of a variable in the model where the probability is greater that it will rise than that it will fall.
You said you want to plot the smoothed probability of being in a bull state, for each time series. What is going to be on the x-axis of your plot? If it is time during the time series, then at each time, the index either is or is not in a bull state. You would need to generate many time series to estimate the probability of being bull at each time.
  2 commentaires
Marco Santorsola
Marco Santorsola le 23 Mai 2022
Dear William, many thanks for getting back to me so quickly. Being in a bull state in my analysis means 2. A bull state is the state of a variable in the model where the probability is greater that it will rise than that it will fall. And you are correct on the x axis I have time.
Please also find attached the code I am using and the data I am trying to analyse. As you can see from the code I am running a Markov switching model with intercept and one autoregressive term. I am trying to identify 2 different states for each time series. The program is returning only one plot with smoothed probabiliy of the 2 states but I am not able to understand to which time series it refers and I seem not to get from the program the smoothed probability for the 2 time series.
Many thanks for your kind help
Marco
William Rose
William Rose le 24 Mai 2022
I tried running the code you sent and I got this error:
>> ms_ar_multivar_ex
Unrecognized function or variable 'MS_VAR_Fit'.
Error in ms_ar_multivar_ex (line 17)
Spec_Out=MS_VAR_Fit(dep,Lag,k,doIntercept,advOpt);
Please provide function MS_VAR_Fit and any other functions needed to run the code. I searched for ms_var_fit in the Matlab help, in case it is part of some toolbox I don't have, and I got no hits.
You said "As you can see from the code I am running a Markov switching model with intercept and one autoregressive term." I have read the code, and I do not see that. It seems that you are calling an external function, MS_Var_Fit, that does all the work. I don;t how that function works, or why it would fail. I am a bit familiar with Markov models but not an expert (attached note shows a more recent Markov analysis I did, not directly relevant to this problem). I expect to see a state vector and a state transition matrix, whose elements are probabilities, which add up to one for each column. I do not see a transiton matrix in your code.
Marco, I hope I don't sound rude. I hope you make progress. But I am afraid I will not be much help in diagnosing a problem with a third-party package that is not part of Matlab. If MS_Var_Fit does not work, and if you have exhausted its documentation, then I recommend contacting the author.
My questions, if we are to continue trying to understand this model:
Are t1 and t2 (columns in Excel) the log of daily returns on two securities?
Also, as I requested before, please provide the equations describing the evolution of the observed quantities t1 and t2, and their relation to the unobservable (hidden) states (bull and bear). Are there separate bull/bear states for t1 and t2? Or is there just one bull/bear state that controls both t1 and t2? If there are two bull/bear states, then I expect to see two 2x2 transition matrices. If there is just one bull/bear state, then I expect to see one 2x2 transition matrix. What does it mean to have an intercept in a switching model? What is the equation that does or does not have an intercept?

Connectez-vous pour commenter.

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by