BayES BayES

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 effects, etc.



Syntax

Arguments and performed function



[W =] diagnostics( ["model"=m] );

Calculates and prints MCMC diagnostics for the model with id value m. If m is not provided then the function operates on the first 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 efficiency and the inefficiency factor (Chib2001) 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



[W =] plotdraws( p [,"model"=m] );

Creates a new figure 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 first model (in alphabetical order) in the current workspace.
If a left-hand-side id value, W, is provided then the title of the figure 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



[W =] test( <condition1>
[, <condition2>, ...]
);

Calculates and prints the number of times and percentage that conditions <condition1>, <condition2>, …, are satisfied, first individually and then jointly. These conditions can be expressed using general vectors. For example, <condition1> 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 nth element of v1 is greater than or equal to the nth element of v2, for n = 1,2,,N.

The test statement is most frequently used to test restrictions that involve the parameters of a model m. In this case <condition1> 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.

  • <condition1>, <condition2>, … must be logical conditions of the form:

    v1 <comparison operator> v2
    where v1 and v2 are vectors of equal length and <comparison operator> is one of the following:

    • >
    • >=
    • <
    • <=
    • ==



pmp( { m1, m2 [, m3, m4 ...] }
[, "priors"=p]
[, "logML_CJ"=true|false]
);

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 [, m3, m4 ...] 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.



[W =] mfx( ["point"=p]
[,"model"=m]
[,"type"=i]
[,"opt"=z]
);

Calculates and prints marginal effects 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-specific). 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 first model (in alphabetical order) in the current workspace.
If a left-hand-side id value, W, is provided then the contents of the marginal effects table are stored in W.

  • p must be either a vector of values indicating the point at which the marginal effects are to be evaluated or one of the following strings:
    • "mean"
    • "median"
    • "x_i"

    In the first case the marginal effects 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 effects to be calculated; the type of marginal effects available is model-specific (some models do not provide marginal effects at all) and the semantics of this argument are documented under each model
  • z must be a matrix and its meaning varies by model



[[p1, p2, ...] =] predict( ["point"=p]
[,"model"=m]
[,"stats"=true|false]
[,"type"=i]
[,"opt"=z]
[,"prefix"=f]
);

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-specific). 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 first 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 prefixed 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-specific (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 prefix 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  [,"model"=m] );

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 first model (in alphabetical order) in the current workspace.
This function is used to store observation-specific 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-specific 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 specific observations.
Model-specific documentation of the store function is provided in the section where the model is defined. 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(
["horizon"=h]
[, "W"=M]
[, "model"=m]
);

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 ×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 first 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 ×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( ["model"=m] );

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 difference 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 first model (in alphabetical order) in the current workspace.

  • m must be a model currently in memory



irf( ["horizon"=h]
[, "orthogonal"=true|false]
[, "scaled"=true|false]
[, "model"=m]
);

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 first 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


Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis