File: BinomialInference.R

package info (click to toggle)
r-cran-learnbayes 2.15.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,864 kB
  • sloc: sh: 15; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
### R code from vignette source 'BinomialInference.Rnw'

###################################################
### code chunk number 1: BinomialInference.Rnw:17-20
###################################################
library(LearnBayes)
beta.par <- beta.select(list(p=0.5, x=0.2), list(p=0.75, x=.28))
beta.par


###################################################
### code chunk number 2: BinomialInference.Rnw:32-33
###################################################
triplot(beta.par, c(6, 4))


###################################################
### code chunk number 3: BinomialInference.Rnw:40-43
###################################################
beta.post.par <- beta.par + c(6, 4)
post.sample <- rbeta(1000, beta.post.par[1], beta.post.par[2])
quantile(post.sample, c(0.05, 0.95))


###################################################
### code chunk number 4: BinomialInference.Rnw:50-51
###################################################
predplot(beta.par, 10, 6)


###################################################
### code chunk number 5: BinomialInference.Rnw:60-65
###################################################
n <- 20
s <- 0:n
pred.probs <- pbetap(beta.par, n, s)
plot(s, pred.probs, type="h")
discint(cbind(s, pred.probs), 0.90)