File: Chapter.8.8.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 (23 lines) | stat: -rw-r--r-- 548 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
###################################################################
# Section 8.8 A Test of Independence in a Two-Way Contingency Table
###################################################################

library(LearnBayes)

 data=matrix(c(11,9,68,23,3,5),c(2,3))
 data

 chisq.test(data)

 a=matrix(rep(1,6),c(2,3))
 a

 ctable(data,a)

  log.K=seq(2,7)
  compute.log.BF=function(log.K)
     log(bfindep(data,exp(log.K),100000)$bf)
  log.BF=sapply(log.K,compute.log.BF)
  BF=exp(log.BF)

round(data.frame(log.K,log.BF,BF),2)