chainsum: Function to summarize chain results of MCMC simulation...

Description Usage Arguments Details Value Author(s) References Examples

Description

This function reports mean and desired quantiles of the samples obtained via Gibbs sampler of the posterior distribution of the parameters.

Usage

1
chainsum(chains, q = c(0.025, 0.5, 0.975), burn = NULL)

Arguments

chains

A matrix where mcmc simulations of the posterior distributions of the regression parameters given the data are stored. Rows correspond to mcmc simulation and columns correspond to the regression parameters. Parameters associated with f1 are denoted by btai (i=1,2,...), parameters associated with f2 are denoted by gmai (i=1,2,...). In this matrix also is stored the Deviance of each iteration.

q

Vector of desired quantiles.

burn

A vector indicating which samples must be discarded from the mcmc simulation

Details

This function can accept any kind of matrix but is highly recommended to pass only the matrix produced by bnlr, in order to avoid missuses.

Value

A matrix with summary statistics of the chains.

Author(s)

Nicolas Molano-Gonzalez, Marta Corrales Bossio, Maria Fernanda Zarate, Edilberto Cepeda-Cuervo.

References

Carlin, B. P. & Louis, T. A. (2009), Bayesian Methods for Data Analysis, 3rd edn, CRC Press, New York.

Gamerman, D. & Lopes, H. F. (2006), Markov Chain Monte Carlo: Stochastic Simulation for Bayesian Inference, 2nd edn, CRC Press, New York.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
utils::data(muscle, package = "MASS")
plot(muscle$Conc,muscle$Length)

###mean and variance functions
fmu<-function(param,cov){ param[1] + param[2]*exp(-cov/exp(param[3]))}
fsgma<-function(param,cov){drop(exp(cov%*%param))}

##Note: use more MCMC chains (i.e NC=10000) for more accurate results.
m1b<-bnlr(y=muscle$Length,f1=fmu,f2=fsgma,x=muscle$Conc,
z=cbind(1,muscle$Conc),bta0=c(20,-30,0),gma0=c(.5,.5),Nc=1200)
chainsum(m1b$chains,burn=1:200)

Example output

Loading required package: mvtnorm
Loading required package: numDeriv
          bta1      bta2       bta3 gma1 gma2      Dev
mean  29.11543 -34.19912 -0.4821620  0.5  0.5 583.8360
2.5%  27.88718 -36.40427 -0.6386765  0.5  0.5 581.1669
50%   29.10774 -34.19149 -0.4819698  0.5  0.5 583.2215
97.5% 30.46699 -32.05269 -0.3325274  0.5  0.5 589.6479

bnormnlr documentation built on May 2, 2019, 6:49 a.m.