Page 1 of 1

H Mamaysky, M Spiegel, H Zhang - 2008RFS

Posted: Sun Apr 02, 2017 9:02 am
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

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

Posted: Mon Apr 03, 2017 11:28 am
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 55786 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}\]

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

Posted: Thu Apr 06, 2017 8:22 am
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

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

Posted: Thu Apr 06, 2017 9:19 am
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.

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

Posted: Thu Apr 06, 2017 10:03 am
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

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

Posted: Thu Apr 06, 2017 10:07 am
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.

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

Posted: Thu Apr 06, 2017 10:18 am
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

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

Posted: Fri Jun 30, 2017 4:11 pm
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

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

Posted: Fri Jun 30, 2017 4:17 pm
by TomDoan
Is this *their* data?

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

Posted: Sat Jul 01, 2017 8:03 am
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