• No results found

Markov Chain Monte Carlo Models

CHAPTER 6. MARKOV CHAIN MONTE CARLO MODELS 166

---USAGE: result = apm(results1,results2)

where: results1 = a structure returned by gmoment results2 = a structure returned by gmoment ---RETURNS: a structure:

results(i).pmean(k) = posterior mean for variable i for k = nse, nse1,nse2,nse3 results(i).nse(k) = nse for variable i

for k = nse, nse1,nse2,nse3 results(i).prob(k) = chi-sq test prob for variable i

for k = nse, nse1,nse2,nse3

---As an illustration, suppose we started our ols g sampler at different starting values. A structure variable can be used as input to ols g to set starting values for the sampler as illustrated in Example 6.5 below. Each call to the function will also use different seeds for the random number generators that produce the normal and chi-squared random deviate draws. To test convergence, we call the apm function with results structures returned by momentg based on the two sets of draws. We then use prt to print the means, NSE and chi-squared test results.

% --- Example 6.5 Using the momentg() function n=100; k=3; % set number of observations and variables randn(’seed’,10101);

x = randn(n,k); b = ones(k,1); % generate data set randn(’seed’,20201);

y = x*b + randn(n,1);

ndraw1 = 600; ndraw2 = 1100; nomit = 100;

r = [1.0 1.0 1.0]’; % prior b means R = eye(k); T = eye(k); % prior b variance

rval = 100; % homoscedastic prior for r-value prior.beta = r; prior.bcov = T;

prior.rmat = R; prior.rval = rval;

start1.b = zeros(k,1); start1.sig = 1.0; start1.V = ones(n,1);

result1 = ols_g(y,x,prior,ndraw1,nomit,start1);

gres1 = momentg(result1.bdraw);

start2.b = ones(k,1); start2.sig = 10.0; start2.V = start1.V;

randn(’seed’,30301);

result2 = ols_g(y,x,prior,ndraw2,nomit,start2);

gres2 = momentg(result2.bdraw);

result = apm(gres1,gres2);

prt(result)

Geweke Chi-squared test for each parameter chain First 33 % versus Last 67 % of the sample Variable variable 1

NSE estimate Mean N.S.E. Equality chi sq

i.i.d. 1.04442600 0.00285852 0.6886650

4% taper 1.04414401 0.00303774 0.6864577

8% taper 1.04428137 0.00303411 0.6934830

15% taper 1.04455890 0.00267794 0.6867602

Variable variable 2

NSE estimate Mean N.S.E. Equality chi sq

i.i.d. 0.97690447 0.00271544 0.9589017

4% taper 0.97686937 0.00233080 0.9581417

8% taper 0.97684701 0.00199957 0.9586626

15% taper 0.97683040 0.00172392 0.9614142

Variable variable 3

NSE estimate Mean N.S.E. Equality chi sq

i.i.d. 0.93683408 0.00298336 0.7947394

4% taper 0.93733319 0.00260842 0.7662486

8% taper 0.93728792 0.00243342 0.7458718

15% taper 0.93728776 0.00227986 0.7293916

Another useful function for examining MCMC output is pltdens, a func-tion from the graphing library that produces density plots. This funcfunc-tion is part of a public domain statistics toolbox written by Anders Holtsberg with the documentation altered to conform to that used by all Economet-rics Toolbox functions. Samples of MCMC draws can be used to produce posterior density plots with a simple call such as:

pltdens(result.bdraw(:,1));

% demo of pltdens options

bandwidth = 0.2; % a kernel density smoothing parameter option

positive = 1; % a flag for densities with zero mass at negative values kerneltype = 1; % a Gaussian kernel type

pltdens(result.sdraw,bandwidth,positive,kerneltype);

6.3 A heteroscedastic linear model

There is a history of Bayesian literature that deals with heteroscedastic and leptokurtic disturbances. A non-Bayesian regression methodology was introduced by Lange, Little and Taylor (1989), which assumes an indepen-dent Stuindepen-dent-t distribution for the regression disturbances. Geweke (1993) provides an equivalent Bayesian approach which he labels a heteroscedastic normal linear regression model. We adopt the approach of Geweke (1993) to extend our basic model from Section 6.2.

The regression model we wish to implement is shown in (6.14).

y = Xβ + ε (6.14)

CHAPTER 6. MARKOV CHAIN MONTE CARLO MODELS 168 ε ∼ N(0, σ2V ), V = diag(v1, v2, . . . , vn)

β ∼ N(c, T ) σ ∼ (1/σ) r/vi ∼ ID χ2(r)/r

r ∼ Γ(m, k)

Where y is an nx1 vector of dependent variable observations and X is an nxk matrix of explanatory variables. As before, we place a multivariate normal prior on β and a diffuse prior on σ. The parameters to be estimated are β, σ and the relative variance terms (v1, v2, . . . , vn), which are assumed fixed but unknown. The thought of estimating n parameters, v1, v2, . . . , vn, in addition to the k+1 parameters, β, σ using n data observations may seem quite problematical. However, a Bayesian approach is taken which assigns an independent χ2(r)/r prior distribution to the vi terms that depends on a single hyperparameter r. This allows us to estimate these additional n model parameters by adding the single parameter r to our model estimation procedure.

This type of prior has been used by Lindley (1971) for cell variances in an analysis of variance problem, and Geweke (1993) in modeling het-eroscedasticity and outliers. The specifics regarding the prior assigned to the Vi terms can be motivated by considering that the mean of prior, which we designate Ep equals unity, that is: Ep(1/vij) = 1, and the prior vari-ance also designated with the subscript p is: varp(1/vij) = 2/r. This im-plies that as r becomes very large, the prior reflects the special case where εi ∼ N(0, σ2In). We will see that the role of Vi 6= In is to robustify against outliers and observations containing large variances by downweighting these observations. Large r values are associated with a prior belief that outliers and non-constant variances do not exist.

We choose to control the values assigned to the hyperparameter r by assigning a Γ(m, k) prior distribution to this parameter. This distribution has a mean of m/k and variance m/k2, so using m = 8, k = 2 would assign a prior to r centered on a small r = 4 with variance of r equal to 2. For small values of r, we can see the impact of the prior distribution assumed for vij by considering that, the mean of the prior is r/(r− 2) and the mode of the prior equals r/(r + 2). Small values of the hyperparameter r allow the vij to take on a skewed form where the mean and mode are quite different.

This is illustrated in Figure 6.1 where distributions for vi associated with various values of the parameter r are presented.

As an intuitive motivation for the conditional distributions in this model,

0 0.5 1 1.5 2 2.5 3 0

0.2 0.4 0.6 0.8 1 1.2 1.4

prior probability density

Vi values

r=2 r=5 r=20

Figure 6.1: Prior Vi distributions for various values of r

note that, given values for V = diag(v1, . . . , vn), we could proceed to con-struct estimates for β and σ using a version of the Theil-Goldberger mixed estimator based on generalized least-squares. It is often the case with the Gibbs sampling methodology that complex estimation problems are simpli-fied considerably by conditioning on unknown parameters, that is, assuming these values are known.

The conditional posterior density for β is:

β|(σ, V ) ∼ N[H(X0V−1y + σ2R0T−1c) , σ2H]. (6.15) H = (X0V−1X + R0T−1R)−1

If we let ei= yi− x0iβ, the conditional posterior density for σ is [

Xn i=1

(e2i/vi)/σ2]|(β, V ) ∼ χ2(n) (6.16)

CHAPTER 6. MARKOV CHAIN MONTE CARLO MODELS 170

Related documents