#Exercise 7.8
#install.packages("Rtools", repos = "https://cran.r-project.org/bin/windows/Rtools/.", dependencies = TRUE)

d = read.table("V:/PROMAX/PROMAX-Odd/Lecture/STK4051-9051/Lectures_Odd/Ex15/pigment.dat",header=T)
stanFileName="V:/PROMAX/PROMAX-Odd/Lecture/STK4051-9051/Lectures_Odd/Ex15/Exercise7_8_Rstan.stan"


dStan = list(I = 15 , 
             J = 2,
             moist = d$Moisture,
             batch = d$Batch,
             samp = d$Sample)

N=10000
nSamp=100
##MCMC  
fit1 = stan(file = stanFileName, data = dStan,iter=1.1*N, warmup=0.1*N,thin=N/nSamp, chains=4, 
            seed=231171,  refresh=10000,control=list(adapt_delta=0.80))

