posterior_density.Rd
This function calculates the (proportional) posterior density for MCMC samples from a Rank-Clustered BTL model.
posterior_density(
Pi,
mcmc,
a_gamma,
b_gamma,
lambda,
groupwise = FALSE,
log = FALSE
)
A matrix of preference orderings ("rankings"), such that the (i,j) entry is the index of the jth-most preferred object according to judge i. If groupwise=TRUE
, then the index corresponds to the jth-most preferred object among those in row i; if groupwise=FALSE
, it is assumed that all unranked objects (if any) are less preferred than those which are ranked.
The matrix output of the mcmc_BTL
or mcmc_RCBTL
functions.
A numeric for the first hyperparameter (shape) in a Gamma prior on each worth parameter.
A numeric for the second hyperparameter (rate) in a Gamma prior on each worth parameter.
A numeric for the Poisson hyperparameter on the number of non-empty clusters in the partition of worth parameters.
A boolean to indicate whether the observed rankings are complete/partial rankings (FALSE
; default) or groupwise comparisons (TRUE
).
A boolean to indicate whether the log posterior densities should be returned. Default to FALSE
.
A ggplot(s) of side-by-side violin plots for each omega_j.
Pi <- rBTL(I=30,omega=c(4^2,4^2,4^1,4^1,4^0))
mcmc <- mcmc_RCBTL(Pi=Pi,J=5,a_gamma=5,b_gamma=3,lambda=1,num_iters=200,chains=2,seed=1)
#> [1] "Estimating chain 1 of 2."
#> [1] "Estimating chain 2 of 2."
posterior_density(Pi = Pi, mcmc = mcmc, a_gamma=5, b_gamma = 3, lambda=2, log=TRUE)
#> [1] -126.3716 -126.5416 -126.8098 -126.3436 -126.5039 -126.4160 -126.5985
#> [8] -126.8791 -126.7412 -128.6697 -127.2009 -127.3381 -128.0358 -128.5143
#> [15] -128.6929 -127.5382 -128.0034 -127.7355 -127.1463 -126.8760 -128.7427
#> [22] -126.3038 -124.1475 -125.7513 -124.3975 -125.0978 -126.3594 -127.3736
#> [29] -126.6644 -126.3989 -124.8051 -123.8942 -126.8327 -126.8241 -125.8453
#> [36] -126.0199 -123.9892 -124.3003 -124.3205 -123.9124 -126.2566 -125.3246
#> [43] -125.6791 -124.7753 -127.8962 -124.1079 -123.6695 -124.5170 -123.2638
#> [50] -123.1269 -125.2762 -123.8151 -123.1095 -124.1767 -124.4463 -123.4808
#> [57] -123.4970 -125.0229 -124.4279 -123.7341 -122.9499 -123.9114 -124.0001
#> [64] -124.3248 -123.6125 -124.8948 -122.9762 -122.8901 -124.0178 -123.0650
#> [71] -123.2721 -123.6053 -126.6660 -124.2982 -124.1198 -124.0355 -127.4646
#> [78] -126.6826 -124.7733 -123.5702 -122.9837 -124.5593 -123.7722 -124.2312
#> [85] -123.7473 -123.2241 -123.0652 -122.9747 -124.2844 -123.7765 -123.0701
#> [92] -124.9466 -125.2419 -124.3361 -122.9006 -123.5622 -122.7474 -122.9540
#> [99] -123.1470 -123.0015 -123.7097 -125.3162 -123.4124 -125.8124 -123.0772
#> [106] -123.3598 -123.7744 -122.6808 -126.1650 -127.8699 -126.5709 -127.0383
#> [113] -126.0557 -126.6056 -127.1940 -123.2476 -121.3615 -121.3492 -121.1768
#> [120] -122.0632 -122.1101 -122.2952 -124.6273 -125.1179 -124.4016 -124.3510
#> [127] -123.0874 -123.1878 -122.9104 -122.9335 -124.8085 -123.8579 -126.3693
#> [134] -125.6656 -124.1796 -124.2960 -123.3588 -124.1082 -125.3488 -126.7792
#> [141] -125.8488 -124.7969 -124.2065 -123.8645 -125.0631 -123.6923 -123.3330
#> [148] -123.0851 -124.8095 -123.7295 -122.4388 -122.3889 -122.9644 -121.1440
#> [155] -121.8445 -122.1669 -121.6993 -121.2405 -123.7852 -122.4489 -121.4214
#> [162] -121.9392 -121.5087 -122.7675 -123.2116 -121.9368 -123.0940 -122.2190
#> [169] -123.9729 -125.8010 -124.3985 -127.3685 -126.0321 -125.1478 -123.2537
#> [176] -122.1710 -121.4152 -122.3215 -121.2994 -123.9544 -124.1282 -123.2656
#> [183] -128.3609 -124.4173 -123.5006 -126.2657 -124.4345 -125.8084 -122.8690
#> [190] -123.9205 -125.6643 -125.3230 -121.8707 -122.4552 -121.3830 -121.5369
#> [197] -123.6868 -122.4003 -120.7351 -120.6303 -121.0862 -121.3713 -121.0599
#> [204] -120.7137 -122.1245 -124.1123 -125.4239 -130.6874 -125.0936 -125.3034
#> [211] -120.9667 -122.8216 -123.6955 -120.1254 -121.1750 -120.7308 -120.2508
#> [218] -121.8937 -123.0934 -121.7731 -123.7022 -123.0239 -123.3387 -121.9730
#> [225] -120.4022 -123.1028 -123.1992 -121.0739 -120.7999 -120.4655 -120.7444
#> [232] -121.1304 -120.1269 -120.6934 -119.9501 -120.0716 -120.1427 -120.8012
#> [239] -120.1870 -120.3777 -120.7822 -120.6735 -120.2058 -120.2417 -120.1931
#> [246] -121.2092 -120.5276 -120.6087 -120.3596 -120.9910 -121.7082 -121.3760
#> [253] -122.9371 -122.5907 -122.5770 -122.5974 -122.9555 -124.9002 -125.2213
#> [260] -127.7800 -123.7002 -124.0290 -123.3362 -123.8760 -123.4859 -123.6981
#> [267] -125.1618 -123.1270 -123.2820 -123.4421 -123.2180 -122.3008 -122.2459
#> [274] -122.1676 -123.3365 -122.5782 -121.9254 -124.0332 -123.2802 -126.7438
#> [281] -125.3375 -125.3779 -128.5189 -124.7454 -124.3297 -128.2644 -126.0763
#> [288] -122.2642 -122.4650 -121.4966 -120.5782 -120.6089 -120.1247 -119.9015
#> [295] -120.6312 -120.6408 -120.9740 -122.0389 -120.5891 -120.9412 -121.0932
#> [302] -123.7539 -121.0529 -121.9519 -120.7390 -121.6419 -121.6511 -120.7219
#> [309] -120.4028 -120.8286 -120.0908 -120.8594 -122.2132 -123.3191 -123.4321
#> [316] -123.4245 -120.6172 -125.1680 -121.0455 -120.1926 -122.7070 -122.2534
#> [323] -125.6742 -121.9398 -121.8502 -120.8087 -121.5082 -124.1336 -121.3550
#> [330] -123.0028 -121.8170 -121.2077 -121.3480 -120.6185 -123.2644 -122.9270
#> [337] -122.6345 -124.2886 -123.5914 -121.2951 -120.2767 -120.5919 -121.3720
#> [344] -120.9369 -122.3663 -122.6896 -122.3772 -122.8883 -121.5930 -123.1003
#> [351] -120.6087 -121.1725 -120.7240 -121.4863 -122.3809 -122.5590 -121.5133
#> [358] -121.7414 -121.5246 -121.6786 -120.9292 -121.7488 -121.3903 -123.6521
#> [365] -125.4424 -121.9363 -123.3165 -125.0307 -124.1367 -123.0239 -124.3748
#> [372] -123.1759 -121.5968 -121.0497 -122.7614 -121.6024 -123.6474 -124.1990
#> [379] -122.5254 -123.2577 -121.7243 -122.2222 -121.9262 -122.5818 -122.8083
#> [386] -123.3679 -126.9856 -124.4524 -123.7568 -123.5499 -123.4103 -123.4166
#> [393] -124.7225 -125.7445 -126.9478 -123.9068 -123.0484 -123.2360 -125.1846
#> [400] -123.8091