Intended for use when derived quantities are calculated from monitored posterior samples, and you wish to combine them into the master mcmc.list, as though they were calculated and monitored during MCMC sampling. It is not advised to combine samples from two MCMC runs, because covariance of MCMC sampling would be lost.

post_bind(post1, post2, dup_id = "_p2")

Arguments

post1

A mcmc.list or matrix object.

post2

A mcmc.list or matrix object.

dup_id

If any node names are duplicated in post2, what should be appended to the end of these node names in the output? If this occurs a warning will be returned. Defaults to "_p2"

Value

A single mcmc.list object containing samples of the nodes from both post1 and post2.

Details

Some important things to note:

  • If the object passed to post1 is a matrix, post2 must be a mcmc.list, and vice versa.

  • That is, two mcmc.list objects are allowed, but not two matrix objects.

  • For matrix objects, nodes should be stored as columns and samples should be stored as rows. Column names should be present.

  • The objects passed to post1 and post2 must have the same number of chains, iterations, burnin, and thinning interval.

  • If the node names are empty (e.g., missing column names in a matrix), the node names will be coerced to "var1", "var2", etc. and a warning will be returned.

Examples

# load example mcmc.list data(cjs) # create two subsets from cjs: one as mcmc.list and one as matrix # also works if both are mcmc.list objects p1 = post_subset(cjs, "b0") p2 = post_subset(cjs, "b1", matrix = TRUE) # combine them into one mcmc.list head(post_bind(p1, p2))
#> [[1]] #> Markov Chain Monte Carlo (MCMC) output: #> Start = 11200 #> End = 12400 #> Thinning interval = 200 #> b0[1] b0[2] b0[3] b0[4] b0[5] b1[1] b1[2] #> 11200 1.275155 2.632859 1.860819 1.708103 0.8804635 0.5816252 0.8614059 #> 11400 1.308511 2.077802 1.518087 1.198710 0.9843441 0.2256074 0.2247939 #> 11600 1.338846 2.473211 1.358235 1.156759 0.8060235 0.2404454 0.4840000 #> 11800 1.654078 2.703028 1.498338 1.279799 1.0339362 0.2274518 0.2259571 #> 12000 1.118555 2.313318 1.819527 1.189711 0.9702624 -0.1491323 0.1556139 #> 12200 1.188926 2.653793 1.633183 1.539144 0.8438322 0.6062051 0.5515264 #> 12400 1.435538 2.278733 1.964918 1.591041 1.2019047 0.3159574 0.3208417 #> b1[3] b1[4] b1[5] #> 11200 0.8239888 0.39861080 0.5317726 #> 11400 0.3784981 0.28920212 0.2967755 #> 11600 0.3752674 0.08322373 0.2388848 #> 11800 0.2523410 0.27122306 0.2636806 #> 12000 0.9751497 0.26068558 0.3365969 #> 12200 0.5413188 0.47595031 0.5587080 #> 12400 0.3152420 0.31512589 0.3169262 #> #> [[2]] #> Markov Chain Monte Carlo (MCMC) output: #> Start = 11200 #> End = 12400 #> Thinning interval = 200 #> b0[1] b0[2] b0[3] b0[4] b0[5] b1[1] b1[2] #> 11200 0.9513008 2.230183 1.717250 1.331936 0.9250757 0.05417021 0.4390001 #> 11400 1.6928127 2.826040 1.759347 1.454606 0.9044431 0.42394348 0.3975913 #> 11600 1.2242501 1.793671 1.583339 1.433099 1.1032145 0.18602369 0.1505553 #> 11800 1.3131607 2.473142 1.413039 1.704727 1.0704131 0.52380389 0.6336967 #> 12000 1.2568403 2.431917 1.511853 1.335619 0.8002242 0.18640512 0.3021911 #> 12200 1.1885346 2.159410 1.998729 1.206818 1.0769668 0.20333442 0.3032018 #> 12400 1.5800930 2.848234 1.934709 1.690799 0.7312037 0.56845806 0.5701915 #> b1[3] b1[4] b1[5] #> 11200 0.3480821 0.6367954 0.3463908 #> 11400 0.4695228 0.2748809 0.5612210 #> 11600 0.2599839 0.3065281 0.2897665 #> 11800 0.6686813 0.6352755 0.7130645 #> 12000 0.7512421 0.3193195 0.6193875 #> 12200 0.2466794 0.2045726 0.4011949 #> 12400 0.5536434 0.5551727 0.5843163 #> #> attr(,"class") #> [1] "mcmc.list"