Merge pull request #1134 from JohannesPfeifer/bvar_mdd

Save marginal data density from BVAR in oo_
time-shift
Stéphane Adjemian 2016-03-15 12:39:10 +01:00
commit 5a91b601a2
2 changed files with 8 additions and 2 deletions

View File

@ -169,7 +169,7 @@ $$\left[
$$\left[ $$\left[
\begin{array}{cc} \begin{array}{cc}
0 & 0 \\ 0 & 0 \\
0 & 0 0 & 0
\end{array} \end{array}
\right] \right]
= =
@ -499,7 +499,7 @@ The syntax for computing the marginal density is:
The options are those described above. The options are those described above.
The command will actually compute the marginal density for several models: first for the model with one lag, then with two lags, and so on up to \textit{max\_number\_of\_lags} lags. The command will actually compute the marginal density for several models: first for the model with one lag, then with two lags, and so on up to \textit{max\_number\_of\_lags} lags. Results will be stored in a \textit{max\_number\_of\_lags} by 1 vector \texttt{oo\_.bvar.log\_marginal\_data\_density}.
\subsection{Forecasting} \subsection{Forecasting}

View File

@ -29,6 +29,10 @@ function bvar_density(maxnlags)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global oo_
oo_.bvar.log_marginal_data_density=NaN(maxnlags,1);
for nlags = 1:maxnlags for nlags = 1:maxnlags
[ny, nx, posterior, prior] = bvar_toolbox(nlags); [ny, nx, posterior, prior] = bvar_toolbox(nlags);
@ -39,6 +43,8 @@ for nlags = 1:maxnlags
log_dnsty = posterior_int - prior_int - 0.5*ny*lik_nobs*log(2*pi); log_dnsty = posterior_int - prior_int - 0.5*ny*lik_nobs*log(2*pi);
oo_.bvar.log_marginal_data_density(nlags)=log_dnsty;
skipline() skipline()
fprintf('The marginal log density of the BVAR(%g) model is equal to %10.4f\n', ... fprintf('The marginal log density of the BVAR(%g) model is equal to %10.4f\n', ...
nlags, log_dnsty); nlags, log_dnsty);