The monarchs of France ruled from the establishment of Francia in 486 to 1870. The first race, or dynasty of kings, was the Merovingianingian dynasty, which ruled until 751, followed by the second race, the Carolingianingian dynasty, until 987 (with some interruptions).
We estimated the parameters of ruling duration for both races, using classical (frequentist’s) methods (https://rpubs.com/alex-lev/64247). Now we want to use Bayesian approach (http://www.indiana.edu/~kruschke/BEST/). Let’s do it!
Merovingian=c(447-458, 458-482, 482-511, 511-558,558-562, 562-566, 562-575, 566-584, 584-628, 628-637, 637-655, 655-668, 668-674, 674-678, 674-691, 691-695, 695-711, 711-716, 716-721, 721-737, 743-751)
Carolingian=c(628-639, 687-714, 714-741, 741-747, 747-751, 751-768, 768-771, 771-814, 814-840, 840-843, 843-877, 877-879, 879-882, 882-884, 884-887, 888-898, 898-922, 922-923, 923-936, 936-954, 954-986, 986-987)
Merovingian<-abs(Merovingian)
Carolingian<-abs(Carolingian)
\[ P(ÆŸ|D) = P(D|ÆŸ)P(ÆŸ)/P(D)\]
Here we produce by MCMC (Markov chain Monte Carlo) procedure the posterior distribution of the duration values parameters \(ÆŸ\) (means, difference of means and the effect size) given the data \(D\). Then we estimate correlations between duration values for both races and verify our results using diagnostics.
library(BayesianFirstAid)
#Random number generator seed
set.seed(12345)
#Bayesian alternative to the t-test
bs.fr<-bayes.t.test(x = Merovingian,Carolingian,n.iter = 50000)
plot(bs.fr)
#Bayesian alternative to the correlation test
bs.fr.2<-bayes.cor.test(x = Merovingian,Carolingian[1:21],n.iter = 50000)
plot(bs.fr.2)
#Some diagnostics for obtained results
diagnostics(bs.fr)
##
## Iterations = 601:17267
## Thinning interval = 1
## Number of chains = 3
## Sample size per chain = 16667
##
## Diagnostic measures
## mean sd mcmc_se n_eff Rhat
## mu_x 14.064 2.861 0.019 23226 1.000
## sigma_x 11.837 2.563 0.022 13659 1.001
## mu_y 13.547 3.050 0.018 27308 1.001
## sigma_y 13.151 2.392 0.017 19114 1.000
## mu_diff 0.517 4.095 0.024 28876 1.000
## sigma_diff -1.314 3.347 0.025 18678 1.000
## nu 30.407 28.396 0.323 7719 1.000
## eff_size 0.041 0.325 0.002 29983 1.000
## x_pred 14.087 13.728 0.063 46939 1.000
## y_pred 13.543 15.592 0.070 49869 1.003
##
## mcmc_se: the estimated standard error of the MCMC approximation of the mean.
## n_eff: a crude measure of effective MCMC sample size.
## Rhat: the potential scale reduction factor (at convergence, Rhat=1).
##
## Model parameters and generated quantities
## mu_x: the mean of Merovingian
## sigma_x: the scale of Merovingian , a consistent
## estimate of SD when nu is large.
## mu_y: the mean of Carolingian
## sigma_y: the scale of Carolingian
## mu_diff: the difference in means (mu_x - mu_y)
## sigma_diff: the difference in scale (sigma_x - sigma_y)
## nu: the degrees-of-freedom for the t distribution
## fitted to Merovingian and Carolingian
## eff_size: the effect size calculated as
## (mu_x - mu_y) / sqrt((sigma_x^2 + sigma_y^2) / 2)
## x_pred: predicted distribution for a new datapoint
## generated as Merovingian
## y_pred: predicted distribution for a new datapoint
## generated as Carolingian