##In this example: n=50; xbar=0.62; xgbar=0.46; s=0.4 #prior beliefs: a=2;b=1 c=3;d=1 library(nclbayes) posterior = mwgGamma(N=20000, initial=(a/b), innov=0.9, priorparam=c(2,1,3,1), n=50, xbar=0.62, xgbar=0.46, show=TRUE) mcmcAnalysis(posterior, rows=2, show=FALSE) plot(posterior, type="l") #What if we had a bad starting value for alpha? posterior = mwgGamma(N=20000, initial=50, innov=0.9, priorparam=c(2,1,3,1), n=50, xbar=0.62, xgbar=0.46, show=TRUE) mcmcAnalysis(posterior, rows=2, show=FALSE) plot(posterior, type="l") #What if the innovation variance was too high? Chain too "hot" (Acceptance rates too low) posterior = mwgGamma(N=20000, initial=(a/b), innov=90, priorparam=c(2,1,3,1), n=50, xbar=0.62, xgbar=0.46, show=TRUE) mcmcAnalysis(posterior, rows=2, show=FALSE) plot(posterior, type="l") #What if the innovation variance was too low? Chain too "cold" (Acceptance rates too high) posterior = mwgGamma(N=20000, initial=(a/b), innov=0.009, priorparam=c(2,1,3,1), n=50, xbar=0.62, xgbar=0.46, show=TRUE) mcmcAnalysis(posterior, rows=2, show=FALSE) plot(posterior, type="l") #Go back to the Goldilocks example, with bad starting value: posterior = mwgGamma(N=20000, initial=20, innov=0.9, priorparam=c(2,1,3,1), n=50, xbar=0.62, xgbar=0.46, show=TRUE) mcmcAnalysis(posterior, rows=2, show=FALSE) plot(posterior, type="l") #Burn-in of 50? Say 500 to be sure! And thin by 20?? posterior2 = mcmcProcess(input = posterior, burnin=500, thin=20) mcmcAnalysis(posterior2, rows=2) mcmcCi(posterior2)