H Mamaysky, M Spiegel, H Zhang - 2008RFS

Discussion of State Space and Dynamic Stochastic General Equilibrium Models
yancheng54
Posts: 6
Joined: Sun Apr 02, 2017 6:15 am

H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by yancheng54 »

Dear all,

Could anyone replicate the extended kalman filter approach in H Mamaysky, M Spiegel, H Zhang - Review of financial studies, 2008, may I kindly ask? Thank you very much.


All the best
Cheng
Attachments
Mamaysky et al. 2008RFS.pdf
(284.58 KiB) Downloaded 781 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by TomDoan »

That requires augmenting the state vector with a lag of F since it's F(t-1) that enters into the measurement equation, not F(t). The state and (linearized) measurement equation are:
ekf_mamaysky.gif
ekf_mamaysky.gif (5 KiB) Viewed 55783 times
In the measurement equation, the first term on the right in {...} is the "MU", and the matrix in [...] is the C. Both of those depend upon the expansion point, which I've written as F^{*,-1}_t. The paper says it's doing the expansion around the expectation of F(t-1|info through t-2), but you actually can use the expectation of F(t-1|info through t-1), since this is being evaluated at t, so all information through t-1 is a valid input. (That's why I chose a rather odd notation, to make clear that this is a time t calculation).

You can compute the expansion point as a side-effect of evaluating the CF function, as something like:

dec series[vect] xstates
clear(zeros) fexpand
*
frml cf = fexpand=%if(t==1,0.0,xstates(t-1)(2)),||0.0,otherstuff+2*bp*fexpand{0}||

The t==1 refers to the first entry in your estimation range, so you might need to change that. By definition, the pre-sample mean for F is zero. The "otherstuff" is all the terms in the C matrix which don't depend upon the expansion point. Use xstates as the state estimate parameter in your DLM instruction.

This is the TeX code for the description of the model above:

Code: Select all

\[\begin{array}{l}
 \left[ {\begin{array}{*{20}{c}}
   {{F_t}}  \\
   {{F_{t - 1}}}  \\
\end{array}} \right] = \left[ {\begin{array}{*{20}{c}}
   \nu  & 0  \\
   1 & 0  \\
\end{array}} \right]\left[ {\begin{array}{*{20}{c}}
   {{F_{t - 1}}}  \\
   {{F_{t - 2}}}  \\
\end{array}} \right] + \left[ {\begin{array}{*{20}{c}}
   1  \\
   0  \\
\end{array}} \right]{\eta _t} \\ 
 \{ {r_{Pt}} - {r_{ft}}\}  = \left\{ { - {k_t} + {{\bar \beta }_P}\left( {{r_{mt}} - {r_{ft}}} \right) - {b_P}{{\left( {F_t^{*, - 1}} \right)}^2}} \right\} + \left[ {\begin{array}{*{20}{c}}
   0 & {{{\bar \alpha }_P} + {c_P}({r_{mt}} - {r_{ft}}) + 2{b_p}F_t^{*, - 1}}  \\
\end{array}} \right]\left[ {\begin{array}{*{20}{c}}
   {{F_t}}  \\
   {{F_{t - 1}}}  \\
\end{array}} \right] + {\varepsilon _{Pt}} \\ 
 \end{array}\]
yancheng54
Posts: 6
Joined: Sun Apr 02, 2017 6:15 am

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by yancheng54 »

Dear Tom,

Thank you for your reply. Rats is still very new to me. I may need some time to absorb the detailed information you have given above. I was doing Gauss but found that the approximation could be unnecessary. I do not have their data so I was not able to replicate their results. Given your response above, I think it is possible there is some bugs in my codes. I am going to code in both Gauss and Rats to see the difference.

Best
Cheng
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by TomDoan »

If you have their Gauss code, they (based upon the description in the paper, and unnecessarily I believe) do the expansion using F(t-1)|t-2 rather than the correct F(t-1)|t-1.
yancheng54
Posts: 6
Joined: Sun Apr 02, 2017 6:15 am

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by yancheng54 »

Dear Tom,

The Gauss codes are programmed by myself, not theirs. I didnot do any approximation, and it works, which is not of my expectation. Perhaps I did not do it in a right way. I am debugging it.

Best
Cheng
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by TomDoan »

You have to do *some* approximation, because you can't Kalman filter with the square of a state variable in the measurement equation.
yancheng54
Posts: 6
Joined: Sun Apr 02, 2017 6:15 am

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by yancheng54 »

Dear Tom

That's exactly the same point which have been claimed by the authors of this paper. Maybe I have made some mistake. Anyway, thank you very much for your help and the detailed information.

Best
Cheng
yancheng54
Posts: 6
Joined: Sun Apr 02, 2017 6:15 am

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by yancheng54 »

Dear Tom

I think I have made some mistake. I am attaching the data, codes in Gauss 10.0 for your consideration. I am trying to code it in Rats but have no idea how to specify mu and C with the market return premium. In the user guide, it seems that both mu and C are not so complicated. Or did you mean that I should regress the estimated mu and C on the market return premium? Could you pls code it in Rats to check whether you get the same results if possible, may I kindly ask?

Best
Cheng
Attachments
MSZ2008RFS.txt
tentative codes in Gauss 10.0
(5.21 KiB) Downloaded 887 times
monthlydecilesfactorsdata.txt
data for table 5 on page249
(72.94 KiB) Downloaded 870 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by TomDoan »

Is this *their* data?
yancheng54
Posts: 6
Joined: Sun Apr 02, 2017 6:15 am

Re: H Mamaysky, M Spiegel, H Zhang - 2008RFS

Unread post by yancheng54 »

Dear Tom,

It is part of their data indeed. To be specific, this is their data of 10 monthly value weighted size deciles with Fama-French 4 factors for Table 2 (10+4=14 columns of data while the first one is date), which I have downloaded from CRSP, a standard database. They use 5-year non-overlapping window (every 60 months) from 1970.

All the best
Cheng
Post Reply