Gauss_MCMC: MCMC Algorithm for conditional Gaussian likelihood

View source: R/source_MCMC.R

Gauss_MCMCR Documentation

MCMC Algorithm for conditional Gaussian likelihood

Description

Run the MCMC algorithm for a conditional Gaussian likelihood given (i) a function to initialize model parameters and (ii) a function to sample (i.e., update) model parameters. This is similar to the STAR framework, but without the transformation and rounding.

Usage

Gauss_MCMC(
  y,
  sample_params,
  init_params,
  nsave = 5000,
  nburn = 5000,
  nskip = 2,
  verbose = TRUE
)

Arguments

y

n x 1 vector of observations

sample_params

a function that inputs data y and a named list params containing

  1. mu n x 1 vector of conditional means (fitted values)

  2. sigma the conditional standard deviation

  3. coefficients a named list of parameters that determine mu

and outputs an updated list params of samples from the full conditional posterior distribution of coefficients and sigma (and updates mu)

init_params

an initializing function that inputs data y and initializes the named list params of mu, sigma, and coefficients

nsave

number of MCMC iterations to save

nburn

number of MCMC iterations to discard

nskip

number of MCMC iterations to skip between saving iterations, i.e., save every (nskip + 1)th draw

verbose

logical; if TRUE, print time remaining

Value

a list with the following elements:

  • coefficients the posterior mean of the coefficients

  • fitted.values the posterior mean of the conditional expectation of the data y

  • post.coefficients nsave posterior draws of the coefficients

  • post.fitted.values nsave posterior draws of the conditional mean of y

  • post.pred nsave draws from the posterior predictive distribution of y

  • post.sigma nsave draws from the posterior distribution of sigma

  • post.log.like.point nsave draws of the log-likelihood for each of the n observations

  • logLik the log-likelihood evaluated at the posterior means

  • WAIC Widely-Applicable/Watanabe-Akaike Information Criterion

  • p_waic Effective number of parameters based on WAIC

Examples

# Fixme


drkowal/rSTAR documentation built on July 5, 2023, 2:18 p.m.