Hello

 

I wonder whether someone can tell me what I am doing wrong.  Here is the
code (from Bayesian Computation with R - Chapter 2.3.R) that I am trying to
run 

 

####################################

# Section 2.3 Using a Discrete Prior

####################################

 

 graphics.off() # Close all graphics

 rm(list=ls())  # Clear all variables

 

 library(LearnBayes)

 library(lattice)

 

 p = seq(0.05, 0.95, by = 0.1)

 prior = c(1, 5.2, 8, 7.2, 4.6, 2.1, 0.7, 0.1, 0, 0)

 prior = prior/sum(prior)

 windows()

 plot(p, prior, type = "h", ylab="Prior Probability")

 

 post = pdisc(p, prior,c(11, 16))

 print(round(cbind(p, prior, post),2))

 

 # Lattice Library

 PRIOR=data.frame("prior",p,prior)

 POST=data.frame("posterior",p,post)

 names(PRIOR)=c("Type","P","Probability")

 names(POST)=c("Type","P","Probability")

 xydata=rbind(PRIOR,POST)

 

 windows()

 
xyplot(Probability~P|Type,data=xydata,layout=c(1,2),type="h",lwd=3,col="blac
k")  # Last command

 

Although there is no warning or error msg after running the code
(source("Chapter.2.3.R"), nothing shows up on the second window. However
when I issue the last command after the prompt on the command line a
graphics shows up.  What could be wrong?

 

Many thanks

 

Ed

 

 

 

 

 


	[[alternative HTML version deleted]]

