q1q2l: Calculate Posterior Model Density, q1(.), Normalised Density,...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/q1q2l.R

Description

Calculates the posterior model density, q1(.), normalised density, q2(.), and their ratio, l(.), for a set of simulated parameters.

Usage

1
q1q2l(bug, sims, ymean, hmean = NULL, MU, COV, P = NULL)

Arguments

bug

A BUGS model created in the tsbugs package.

sims

A data.frame of simulated parameter values with column names labelled according to output from the R2OpenBUGS package.

ymean

A data.frame of mean values for $y$, the fitted mean process. Columns represent time and rows represent simulations.

hmean

A data.frame of mean values for $h$, the fitted volatility process. Columns represent time and rows represent simulations. This argument is not used.

MU

A vector of the mean parameter values (over a simulated data set)

COV

A matrix of parameter variance-covariances (over a simulated data set)

P

A data.frame of model fits for each binary parameter, used in the simulation of equivalent parameters from a normalised density. Rows represent simulation number, and columns binary parameters. Only necessary for random variance shift models.

Details

Returns a data.frame with three columns. The first column returns q1(.), the second q2(.) and third l(.) for a given set of simulations. Will only operate for simulations from BUGS models with either constant variance, stochastic volatility or a random variance shift created in the tsbugs package. This function is intended to be run twice in order to obtain 1) q1(w1) and q2(w1) based on a unnormalised MCMC simulation (w1) and 2) q1(w2) and q2(w2) based on a simulations from a normalised density (w2).

Values of q1 are based on posterior model densities calculated in either the dcvts, dsvts or drvts. Values of q2 are based on densities of a multivariate normal distribution (using MU and COV in the dmvnorm function of the mvtnorm package) when the BUGS model (bug) has a constant variance or stochastic volatility component. When BUGS model has a random variance shift component, the q2 density is estimated using the dmvnb function.

The data.frame outputs can be directly used as input into the bridge function to obtain estimates of normalising constants.

Value

A data.frame with columns:

q1

Unnormalised Density.

q2

Normalised Density.

l

Ratio of q1 and q2.

Author(s)

Guy J. Abel

References

Abel, G.J., Bijak, J., Forster, J.J., Raymer J., Smith P.W.F. and Wong, J.S.T. (2013) Integrating uncertainty in time series population forecasts: An illustration using a simple projection model. Demographic Research. 29 43 1187-1226 doi:10.4054/DemRes.2013.29.43

Alan Genz, Frank Bretz, Tetsuhisa Miwa, Xuefei Mi, Friedrich Leisch, Fabian Scheipl, Torsten Hothorn (2012). mvtnorm: Multivariate Normal and t Distributions. R package version 0.9-9994. http://CRAN.R-project.org/package=mvtnorm

Meng, X.-L., & Wong, W. H. (1996). Simulating Ratios of Normalizing Constants via a Simple Identity: A Theoretical Exploration. Statistica Sinica, 6, 831-860.

See Also

dcvts, dsvts, drvts, dmvnb, dmvnorm, bridge

Examples

1
2
3
4
5
6
## Not run: 
# demo example with constant variance models for differenced growth rate
# of England and Wales population as used in Abel et. al. (2013)
demo("cv_bma", "tsbridge")

## End(Not run)

tsbridge documentation built on May 30, 2017, 1:14 a.m.