File: Chapter.8.7.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 (19 lines) | stat: -rw-r--r-- 474 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
###################################################
# Section 8.7  Is a Baseball Hitter Really Streaky?
###################################################

library(LearnBayes)

 data(jeter2004)
 attach(jeter2004)
 data=cbind(H,AB)
 data1=regroup(data,5)

 log.marg=function(logK) 
     laplace(bfexch,0,list(data=data1,K=exp(logK)))$int
 
 log.K=seq(2,6)
 K=exp(log.K)
 log.BF=sapply(log.K,log.marg)
 BF=exp(log.BF)
 round(data.frame(log.K,K,log.BF,BF),2)