summary.hmclearn: Summarizing HMC Model Fits

Description Usage Arguments Value References Examples

View source: R/methods.R

Description

summary method for class hmclearn

Usage

1
2
3
4
5
6
7
## S3 method for class 'hmclearn'
summary(
  object,
  burnin = NULL,
  probs = c(0.025, 0.05, 0.25, 0.5, 0.75, 0.95, 0.975),
  ...
)

Arguments

object

an object of class hmclearn, usually a result of a call to mh or hmc

burnin

optional numeric parameter for the number of initial MCMC samples to omit from the summary

probs

quantiles to summarize the posterior distribution

...

additional arguments to pass to quantile

Value

Returns a matrix with posterior quantiles and the posterior scale reduction factor statistic for each parameter.

References

Gelman, A., et. al. (2013) Bayesian Data Analysis. Chapman and Hall/CRC.

Gelman, A. and Rubin, D. (1992) Inference from Iterative Simulation Using Multiple Sequences. Statistical Science 7(4) 457-472.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Linear regression example
set.seed(521)
X <- cbind(1, matrix(rnorm(300), ncol=3))
betavals <- c(0.5, -1, 2, -3)
y <- X%*%betavals + rnorm(100, sd=.2)

f1 <- hmc(N = 500,
          theta.init = c(rep(0, 4), 1),
          epsilon = 0.01,
          L = 10,
          logPOSTERIOR = linear_posterior,
          glogPOSTERIOR = g_linear_posterior,
          varnames = c(paste0("beta", 0:3), "log_sigma_sq"),
          param=list(y=y, X=X), parallel=FALSE, chains=1)

summary(f1)

Example output

Summary of MCMC simulation

                   2.5%         5%        25%        50%        75%        95%
beta0         0.3761942  0.4648189  0.5155872  0.5325537  0.5497568  0.5781873
beta1        -1.0739748 -1.0488209 -1.0281105 -1.0118904 -0.9965476 -0.9627243
beta2         0.9617633  1.8882191  1.9997614  2.0164956  2.0314843  2.0521531
beta3        -3.0255286 -3.0154147 -2.9970442 -2.9807522 -2.9646554 -2.8305029
log_sigma_sq -3.2893269 -3.2522864 -3.1503169 -3.0392322 -2.9052983 -0.4878351
                  97.5%
beta0         0.5854330
beta1        -0.9602134
beta2         2.0591168
beta3        -1.8103326
log_sigma_sq  1.5343091

hmclearn documentation built on Oct. 23, 2020, 8:04 p.m.