### a set of linear order constraints:
### x1 < x2 < .... < x6 < .50
A <- matrix(
c(
1, -1, 0, 0, 0, 0,
0, 1, -1, 0, 0, 0,
0, 0, 1, -1, 0, 0,
0, 0, 0, 1, -1, 0,
0, 0, 0, 0, 1, -1,
0, 0, 0, 0, 0, 1
),
ncol = 6, byrow = TRUE
)
b <- c(0, 0, 0, 0, 0, .50)
### check whether a specific vector is inside the polytope:
A %*% c(.05, .1, .12, .16, .19, .23) <= b
### observed frequencies and number of observations:
k <- c(0, 3, 2, 5, 3, 7)
n <- rep(10, 6)
### count prior samples and compare to analytical result
prior <- count_binom(0, 0, A, b, M = 5000, steps = 1:4)
prior # to get the proportion: attr(prior, "proportion")
(.50)^6 / factorial(6)
### count posterior samples + get Bayes factor
posterior <- count_binom(k, n, A, b, M = 2000, steps = 1:4)
count_to_bf(posterior, prior)
### automatic stepwise algorithm
prior <- count_binom(0, 0, A, b, M = 500, cmin = 200)
posterior <- count_binom(k, n, A, b, M = 500, cmin = 200)
count_to_bf(posterior, prior)
Run the code above in your browser using DataLab