#---------------------------------------------- # linear fit including inference on sigma and extrapolation # (same as done in OpenBUGS) # # GdA 27 marzo 2015 #---------------------------------------------- # function pausa pausa <- function() { cat ("\n >> Guarda il plot e dai enter per continuare\n") scan() } library(rjags) # the OpenBUGS files have been edited to assign # the names data and inits to the lists!! (can be done automatically?) source("fit_data_J.txt") # defines 'data' source("fit_inits_J.txt") # defines 'inits' model <- "fit_model.txt" jm <- jags.model(model, data, inits) update(jm, 100) # burn in to.sample <- c('m', 'c', 'sigma', 'muy1', 'y1') # variables of interest catena <- coda.samples(jm, to.sample, n.iter=20000) # sampling print(summary(catena)) pausa() # transform the chain in a dataframe catena.df <- as.data.frame( as.mcmc(catena) ) hist(catena.df$m, nc=100, col='blue') # etc. etc. pausa() plot(catena.df$m, ty='l', col='blue') pausa() plot(catena.df)