R/trace_plot.R

Defines functions trace_plot

Documented in trace_plot

#' Create a trace plot of posterior draws for a given parameter
#' 
#' @description  creates a trace plot for posterior draws
#' 
#' @param col column that contains the parameter posterior draws
#' @param Mlist list that contains posterior draws from several gibbs sampler runs
#' 
#' @importFrom grDevices png dev.off
#' @importFrom graphics plot lines
#' @importFrom stringr str_sub str_replace_all
#' 
#' @export

trace_plot=function(col,Mlist){
  
  colname=str_replace_all(col,"[.]","_")
  imagename=paste0("results/traceplots/",colname,".png")
  png(imagename)
  plot(Mlist[[1]][,col],type="l",xlab="Iterations",ylab=col)
  lines(Mlist[[2]][,col],col="red")
  lines(Mlist[[3]][,col],col="green")
  dev.off()
}
andrewpita/gibbsCapRecap documentation built on May 22, 2019, 5:08 p.m.