90 lines
5.6 KiB
HTML
90 lines
5.6 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||
|
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Description of posterior_moments</title>
|
||
|
<meta name="keywords" content="posterior_moments">
|
||
|
<meta name="description" content="stephane.adjemian@ens.fr [09-09-2005]">
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||
|
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||
|
<meta name="robots" content="index, follow">
|
||
|
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<a name="_top"></a>
|
||
|
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > posterior_moments.m</div>
|
||
|
|
||
|
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||
|
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||
|
|
||
|
<h1>posterior_moments
|
||
|
</h1>
|
||
|
|
||
|
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||
|
<div class="box"><strong>stephane.adjemian@ens.fr [09-09-2005]</strong></div>
|
||
|
|
||
|
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||
|
<div class="box"><strong>function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info) </strong></div>
|
||
|
|
||
|
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||
|
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-09-2005]
|
||
|
Computes posterior mean, median, variance, HPD interval, deciles, and density from posterior draws.</pre></div>
|
||
|
|
||
|
<!-- crossreference -->
|
||
|
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||
|
This function calls:
|
||
|
<ul style="list-style-image:url(../matlabicon.gif)">
|
||
|
<li><a href="kernel_density_estimate.html" class="code" title="function [abscissa,f] = kernel_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)">kernel_density_estimate</a> % This function aims at estimating a continuous density. A kernel density</li><li><a href="mh_optimal_bandwidth.html" class="code" title="function optimal_bandwidth = mh_optimal_bandwidth(data,n,bandwidth,kernel_function)">mh_optimal_bandwidth</a> % This function gives the optimal bandwidth parameter of a kernel estimator</li></ul>
|
||
|
This function is called by:
|
||
|
<ul style="list-style-image:url(../matlabicon.gif)">
|
||
|
<li><a href="GetPosteriorParametersStatistics.html" class="code" title="function GetPosteriorParametersStatistics()">GetPosteriorParametersStatistics</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="PosteriorIRF.html" class="code" title="function PosteriorIRF(type)">PosteriorIRF</a> stephane.adjemian@ens.fr [09-25-2005]</li></ul>
|
||
|
<!-- crossreference -->
|
||
|
|
||
|
|
||
|
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||
|
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)</a>
|
||
|
0002 <span class="comment">% stephane.adjemian@ens.fr [09-09-2005]</span>
|
||
|
0003 <span class="comment">% Computes posterior mean, median, variance, HPD interval, deciles, and density from posterior draws.</span>
|
||
|
0004 <span class="keyword">global</span> options_
|
||
|
0005
|
||
|
0006 xx = xx(:);
|
||
|
0007 xx = sort(xx);
|
||
|
0008
|
||
|
0009
|
||
|
0010 post_mean = mean(xx);
|
||
|
0011 post_median = median(xx);
|
||
|
0012 post_var = var(xx);
|
||
|
0013
|
||
|
0014 n = length(xx);
|
||
|
0015 m = round((1-options_.mh_conf_sig)*n);
|
||
|
0016 k = zeros(m,1);
|
||
|
0017 jj = n-m;
|
||
|
0018 <span class="keyword">for</span> ii = 1:m
|
||
|
0019 k(ii) = xx(jj)-xx(ii);
|
||
|
0020 jj = jj + 1;
|
||
|
0021 <span class="keyword">end</span>
|
||
|
0022 [kmin,idx] = min(k);
|
||
|
0023 hpd_interval = [xx(idx) xx(idx)+kmin];
|
||
|
0024
|
||
|
0025 post_deciles = xx([round(0.1*n) <span class="keyword">...</span>
|
||
|
0026 round(0.2*n)<span class="keyword">...</span>
|
||
|
0027 round(0.3*n)<span class="keyword">...</span>
|
||
|
0028 round(0.4*n)<span class="keyword">...</span>
|
||
|
0029 round(0.5*n)<span class="keyword">...</span>
|
||
|
0030 round(0.6*n)<span class="keyword">...</span>
|
||
|
0031 round(0.7*n)<span class="keyword">...</span>
|
||
|
0032 round(0.8*n)<span class="keyword">...</span>
|
||
|
0033 round(0.9*n)]);
|
||
|
0034
|
||
|
0035 <span class="keyword">if</span> ~info
|
||
|
0036 density = [];
|
||
|
0037 <span class="keyword">else</span>
|
||
|
0038 number_of_grid_points = 2^9; <span class="comment">% 2^9 = 512 !... Must be a power of two.</span>
|
||
|
0039 bandwidth = 0; <span class="comment">% Rule of thumb optimal bandwidth parameter.</span>
|
||
|
0040 kernel_function = <span class="string">'gaussian'</span>; <span class="comment">% Gaussian kernel for Fast Fourrier Transform approximaton.</span>
|
||
|
0041 optimal_bandwidth = <a href="mh_optimal_bandwidth.html" class="code" title="function optimal_bandwidth = mh_optimal_bandwidth(data,n,bandwidth,kernel_function)">mh_optimal_bandwidth</a>(xx,length(xx),bandwidth,kernel_function);
|
||
|
0042 [density(:,1),density(:,2)] = <a href="kernel_density_estimate.html" class="code" title="function [abscissa,f] = kernel_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)">kernel_density_estimate</a>(xx,number_of_grid_points,optimal_bandwidth,kernel_function);
|
||
|
0043 <span class="keyword">end</span></pre></div>
|
||
|
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||
|
</body>
|
||
|
</html>
|