Learn R Programming

ASV (version 1.1.4)

ReportMCMC: Summary statistics, diagnostic statistics and plots.

Description

This function reports summary statistics of the MCMC samples such as the posterior mean, the posterior standard deviation, the 95% credible interval, the expected sample size, the inefficiency factor, the posterior probability that the parameter is positive. Further it plots the sample path, the sample autocorrelation function and the estimated posterior density.

Usage


ReportMCMC(mx, dBm = NULL, vname = NULL)

Value

Mean

The posterior mean of the parameter

Std Dev

The posterior standard deviation of the parameter

95%L

The lower limit of the 95% credible interval of the parameter

Median

The posterior median of the parameter

95%U

The upper limit of the 95% credible interval of the parameter

ESS

Expected sample size defined as the MCMC sample size divided by IF

IF

Inefficiency factor. See, for example, Kim, Shephard and Chib (1998).

CD

p-value of convergence diagnostics test by Geweke (1992). H_0:mean of the first 10% of MCMC samples is equal to mean of the last 50% of MCMC samples vs. H_1:not H_0.

Pr(+)

The posterior probability that the parameter is positive.

Further, it plots the sample path, the sample autocorrelation function and the posterior density for each parameter.

Arguments

mx

nSim x m matrix where nSim is the MCMC sample size and m is the number of parameters.

dBm

The bandwidth to compute the inefficient factor. Default value is the maximum integer less than or equal to 2*sqrt(nSim)+1.

vname

The vector of variable names. Default names are Param1, Param2 and so forth.

Author

Yasuhiro Omori

References

Kim, S., Shephard, N. and S. Chib (1998) "Stochastic volatility: likelihood inference and comparison with ARCH models", The Review of Economic Studies, 65(3), 361-393.

Geweke, J. (1992), "Evaluating the accuracy of sampling-based approaches to calculating posterior moments,"" in Bayesian Statistics 4 (ed J.M. Bernardo, J.O. Berger, A.P. Dawid and A.F.M. Smith), Oxford, UK.

Examples

Run this code
nobs = 80; # n is often larger than 1000 in practice.
mu = 0; phi = 0.97; sigma_eta = 0.3; rho = 0.0;
h  = 0;   Y = c();

for(i in 1:nobs){
  eps = rnorm(1, 0, 1)
  eta = rho*sigma_eta*eps + sigma_eta*sqrt(1-rho^2)*rnorm(1, 0, 1)
  y   = eps * exp(0.5*h)
  h   = mu + phi * (h-mu) + eta
  Y   = append(Y, y)
}

# This is a toy example. Increase nsim and nburn
# until the convergence of MCMC in practice.

nsim = 500; nburn = 100;
vhyper = c(0.0,1000,1.0,1.0,0.01,0.01)
out  = sv_mcmc(Y, nsim, nburn, vhyper)
vmu = out[[1]]; vphi = out[[2]]; vsigma_eta = out[[3]]; mh  = out[[4]];
myname = c(expression(mu), expression(phi),expression(sigma[eta]))
ReportMCMC(cbind(vmu,vphi,vsigma_eta), vname=myname)

Run the code above in your browser using DataLab