Chapter 8, problem 3. ===================== I recommend you start the problem reading the data and putting it into a matrix format like that in the program on page 137 (that I handed out and is posted). That way, you can use the same commands to obtain many of the things asked in problem 3. You still will have to write some code after that. So here is how you could read the data and then put the matrix Y together for problem 3, chapter 8. ############### Read the data from the author's web site ############## y1<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school1.dat") y2<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school2.dat") y3<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school3.dat") y4<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school4.dat") y5<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school5.dat") y6<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school6.dat") y7<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school7.dat") y8<-scan("http://www.stat.washington.edu/~hoff/Book/Data/hwdata/school8.dat") ########Make a matrix Y with the school number Y[,1] and student scores Y[,2] ########## as in program p.137 Hoff. That way, you can use that program ### Y=matrix(c( rep( c(1,2,3,4,5,6,7,8),c(length(y1),length(y2),length(y3),length(y4), length(y5), length(y6), length(y7), length(y8)) ) , y1,y2,y3,y4,y5,y6,y7,y8), ncol=2) =============== Chapter 8, problem 3(a) The effective sample size can be found by using the following commands library(coda) effectiveSize(MST) effectiveSize(THETA) ============== Chapter 8, problem 3(c). R is a function of the parameters that you already generated in part (a). So just extract from part a what you need and compute that function. We have done this kind of things before, when you computed posterior odds, based on thetas that you had generated, or when we computed the difference between two thetas that we had generated. =============== Chapter 8, problem 3(d) In (d) you have to count how many of the theta7 are smaller than theta6 and which is the smallest theta at each iteration. Again, use what you found in part (a) and some code in R to figure this out. ============ Chapter 9, problem 3 I recommend you start by reading the data and putting it in the same format as the data analyzed in the program on section 9.2.2 that you have to use. Here are commands to set the y and the X matrix. data=read.table("http://www.stat.washington.edu/hoff/Book/Data/hwdata/crime.dat",header=T) attach(data) y=y X=cbind(M,So,Ed,Po1,Po2,LF,M.F,Pop,NW,U1,U2,GDP,Ineq,Prob,Time) If you do the following, you will have to scale and center the variables yourself library(MASS) data(UScrime) attach(UScrime) y=y X=cbind(M,So,Ed,Po1,Po2,LF,M.F,Pop,NW,U1,U2,GDP,Ineq,Prob,Time) ======