R/plot_real_v_simulated.R

Defines functions plot_real_v_simulated

Documented in plot_real_v_simulated

#' PLot real versus model simulated data
#'
#' @param result fitted inla model
#' @param stack data stack
#' @param Data data model was fitted to
#' @param response_col name of column in data containing response data
#' @param filename file for plot to be saved to, default FALSE
#' @export
plot_real_v_simulated <- function(result, stack.est, Data, response_col, 
                                filename=NULL){
    if (!(is.null(filename))){
        png(filename)
    
        index <- INLA::inla.stack.index(stack.est,"est")$data
        lp <- result$summary.linear.predictor$mean[index]
        plot(lp[index],Data[[response_col]])

        dev.off()
    }else{
        index <- INLA::inla.stack.index(stack.est,"est")$data
        lp <- result$summary.linear.predictor$mean[index]
        plot(lp[index],Data[[response_col]])
    }
}
bjeffrey92/MyINLA documentation built on Aug. 12, 2021, 10:01 a.m.