### B.14 Statements for post-estimation analysis

If the results of an estimated model are saved in memory (by providing an id value in the left-hand side of a model-estimation statement), these results become available for various types of post-estimation analysis. These include calculating and presenting MCMC diagnostics, testing hypotheses and comparing models based on Bayes factors, calculating marginal eﬀects, etc.

 Syntax Arguments and performed function $\left[$W =$\right]$ diagnostics( $\left[$"model"=m$\right]$ ); Calculates and prints MCMC diagnostics for the model with id value m. If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace. The reported diagnostics currently include: the header printed on top of every model estimated (number of observations, Gibbs parameters, log-marginal likelihood, etc.) an estimate of the Monte Carlo standard error for every model parameter an estimate of the relative numerical eﬃciency and the ineﬃciency factor (Chib, 2001) for every model parameter If a left-hand-side id value, W, is provided then the contents of the diagnostics table are stored in W. m must be a model $\left[$W =$\right]$ plotdraws( p $\left[$,"model"=m$\right]$ ); Creates a new ﬁgure window and plots four types of plots using the draws of paramater p from model m. These plots are: the history of the draws per chain the correlogram of the draws the histogram of the draws the kernel desnity of the draws per chain If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace.If a left-hand-side id value, W, is provided then the title of the ﬁgure window on which the function is plotting is stored in W. p must be the name of a parameter estimated by model m m must be a model currently in memory $\left[$W =$\right]$ test( $\left[$, , ...$\right]$ ); Calculates and prints the number of times and percentage that conditions , , …, are satisﬁed, ﬁrst individually and then jointly. These conditions can be expressed using general vectors. For example, could be: v1>=v2, where v1 and v2 are vectors of equal length, say $N$. In this case the test function would count the number of times the $n$th element of v1 is greater than or equal to the $n$th element of v2, for $n=1,2,\dots ,N$. The test statement is most frequently used to test restrictions that involve the parameters of a model m. In this case could be: m.x1<3, where test counts the number of times the parameter associated with variable x1 is smaller than 3 (note that scalar values are expanded to match the size of m.x1). If a left-hand-side id value, W, is provided then the contents of the printed table are stored in W. , , … must be logical conditions of the form: v1  v2where v1 and v2 are vectors of equal length and is one of the following: > >= < <= == pmp( { m1, m2 $\left[$, m3, m4 ...$\right]$ } $\left[$, "priors"=p$\right]$ $\left[$, "logML_CJ"=true|false$\right]$ ); Calculates and prints the posterior model probabilities of models m1, m2, …, assuming that the list of models provided is exhaustive. The posterior model probabilities are calculated using Bayes factors and the model prior probabilities provided in vector p. If the optional argument "logML_CJ" is set to true then Bayes factors are calculated using the Chib (1995)/Chib & Jeliazkov (2001) approximation of the marginal likelihood for the models this is available; otherwise, the Lewis & Raftery (1997) approximation is used for all models. m1, m2 $\left[$, m3, m4 ...$\right]$ must be models currently in memory p must be a vector of non-negative values that sum to unity, the length of which is equal to the number of models to be compared. The default value for p is set such that every model to be compared is given equal prior probability. "logML_CJ" must be either true or false. The default value for "logML_CJ" is false. $\left[$W =$\right]$ mfx( $\left[$"point"=p$\right]$ $\left[$,"model"=m$\right]$ $\left[$,"type"=i$\right]$ $\left[$,"opt"=z$\right]$ ); Calculates and prints marginal eﬀects of the type indicated by i, for model m, at the point indicated by p, while using z to pass any additional numerical input (model-speciﬁc). All arguments are optional and, therefore, the order in which they are provided does not matter.If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace.If a left-hand-side id value, W, is provided then the contents of the marginal eﬀects table are stored in W. p must be either a vector of values indicating the point at which the marginal eﬀects are to be evaluated or one of the following strings: "mean" "median" "x_i" In the ﬁrst case the marginal eﬀects are evaluated at the sample mean, in the second at the sample median and in the third at each data point (before being averaged for reporting). The default value for p is "mean". m must be a model currently in memory i must be a positive integer that controls the type of marginal eﬀects to be calculated; the type of marginal eﬀects available is model-speciﬁc (some models do not provide marginal eﬀects at all) and the semantics of this argument are documented under each model z must be a matrix and its meaning varies by model $\left[$[p1, p2, ...] =$\right]$ predict( $\left[$"point"=p$\right]$ $\left[$,"model"=m$\right]$ $\left[$,"stats"=true|false$\right]$ $\left[$,"type"=i$\right]$ $\left[$,"opt"=z$\right]$ $\left[$,"prefix"=f$\right]$ ); Generates predictions of the type indicated by i, for model m, at the point(s) indicated by p, while using z to pass any additional numerical input (model-speciﬁc). If "stats" is set to true, summary statistics for each prediction are also generated. All arguments are optional and, therefore, the order in which they are provided does not matter.If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace.If left-hand-side id values, [p1, p2, ...], are provided then the predictions and, possibly, their summary statistics, are stored in p1, p2, etc. p must be either a matrix of values indicating the points at which the predictions are to be made or string "x_i". In the latter case predictions are made at each data point in the dataset used by estimation and the results (point estimates and, possibly, summary statistics) are stored in the dataset with variable names preﬁxed by f. m must be a model currently in memory i must be a positive integer that controls the type of predictions to be generated; the type of predictions available is model-speciﬁc (some models do not provide a procedure for generating predictions at all) and the semantics of this argument are documented under each model z must be a matrix and its meaning varies by model f must be a valid id value and indicates the preﬁx in the variable names to be stored in the dataset if the "point"\ option is set to "x_i"; the default value for f is p_ store( e, varname  $\left[$,"model"=m$\right]$ ); Stores element e from model m to the dataset associated with m in variable varname. If a variable with the same name already exists in the dataset then its values are replaced by the values in e. If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace.This function is used to store observation-speciﬁc estimates to the datasets used for estimating the parameters of a model. Due to possible missing values in the original dataset, there is no guarantee that the observation-speciﬁc estimates in e will have an one-to-one relationship to the data contained in the dataset. store is, therefore, used to associate the values in e with speciﬁc observations. Model-speciﬁc documentation of the store function is provided in the section where the model is deﬁned. Not all models provide a store function. e must be an element of model m varname must be an id value m must be a model currently in memory [f1, f2, ...] = forecast( $\left[$"horizon"=h$\right]$ $\left[$, "W"=M$\right]$ $\left[$, "model"=m$\right]$ ); Calculates and stores h period ahead forecasts for the endogenous variables in model m, using the values in matrix M for the exogenous variables (if any). This function is available only for dynamic models, such as ARIMA, VAR, etc. All three arguments are optional and, therefore, the order in which they are provided does not matter.f1, f2, ... are $h\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}4$ matrices whose columns contain the expected values and standard deviations of the forecasts per endogenous variable, as well as the upper and lower bounds of the respective 90% credible intervals. Upon completion of the forecast function, these matrices are also made available as elements of model m, with id values constructed by prepending “f_" to the respective endogenous variable name.If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace. h must be a positive integer. The default value for h is 1. M must be a $h\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}K$ matrix, where $K$ is the number of exogenous variables in the model. If the model contains exogenous variables but "W" is not provided, then the sample means of the exogenous variables are used. If both "horizon" and "W" are provided then the number of rows of M must be equal to h. If only "W" is provided then the number of forecast periods is inferred from the rows of M. m must be a model currently in memory stabtest( $\left[$"model"=m$\right]$ ); Performs a stability test for model m. This function is available only for models that contain autoregressive terms (ARIMA and VAR, although not yet implemented for the VAR model). It works by treating the dynamic model as a diﬀerence equation and calculating the proportion of draws from the posterior for which the root of the characteristic polynomial with the maximum modulus lies within the unit circle.If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace. m must be a model currently in memory irf( $\left[$"horizon"=h$\right]$ $\left[$, "orthogonal"=true|false$\right]$ $\left[$, "scaled"=true|false$\right]$ $\left[$, "model"=m$\right]$ ); Calculates and plots h period impluse responses to a shock in the variables in model m. This function is available only for the VAR model. All four arguments are optional and, therefore, the order in which they are provided does not matter.If m is not provided then the function operates on the ﬁrst model (in alphabetical order) in the current workspace. h must be a positive integer. The default value for h is 10. "orthogonal" must be set to either true or false, indicating whether a shock on the orthogonalized or raw errors should be considered, respectively. The default value for "orthogonal" is true, in which case the shocks are orthogonalized using the Cholesky decomposition of the variance matrix, prior to calculating responses. "scaled" must be set to either true or false, indicating whether a shock of size equal to the standard deviation of the error or to a unit of the respective variable should be considered, respectively. The default value for "scaled" is true, in which case the shock is equal to the one standard deviation of the error. m must be a model currently in memory