R/RunModel.R

#' RunModel()
#'
#' Use this function to run the model that was generated by ReadModel(). 
#' @param model The loaded dataframe structure generated by ReadModel().
#' @param iter The total number of steps for the simulation to take. Well have to try out several orders of magnitude to ensure convergence of the Markov Chain.
#' @param out.length The number of solutions to output for analysis. A solution is saved every iter/out.length steps.
#' @param iter.burn The number of steps to take before sampling solutions for the final output. (Typically some fraction of iter.)
#' @param jmp The relative distance between one step and the next. Larger the value the more likely a step to be rejected, and the smaller the step the more of them that will be required to reach convergence. (I adjust it to achive an acceptance ratio of ~0.234). 
#' @return solution of the xsample run as a dataframe.
#' @keywords MCMC
#' @export
#' @examples RunModel(model.A, iter=1e5, out.length=150, iter.burn=10000, jmp=2)
RunModel = function(model, iter=100000, out.length=100, burn.length=10000, jmp=1) {
    model$Aa = as.matrix(model$Aa)
    model$Ae = as.matrix(model$Ae)
    model$G = as.matrix(model$G)
    model$ba = as.vector(model$ba)
    model$be = as.vector(model$be)
    model$sdb = as.vector(model$sdb)
    model$h = as.vector(model$h)
    solution = MCMC.Sample(A=model$Aa, B=model$ba, E=model$Ae, F=model$be, G=model$G, H=model$h, sdB=model$sdb, iter=iter, outputlength=out.length, burn.length=burn.length, jmp=jmp)
    return(solution)
}
tbrycekelly/CCELIM documentation built on May 31, 2019, 7:27 a.m.