R/INLA_CPOplot.R

Defines functions INLA_CPOplot

Documented in INLA_CPOplot

#' Function to summarise criteria from an INLA model
#' 
#' @param m INLA model to summarise
#' @export
INLA_CPOplot <- function(m){
  d <- data.frame(Model = deparse(substitute(m)), CPO = m$cpo$cpo, PIT = m$cpo$pit) %>% 
    mutate(Observation = 1:n()) %>%
    tidyr::gather(type, value, CPO,PIT) %>% 
    ggplot() +
    geom_point(aes(Observation, y = value), alpha = 0.7) +
    facet_wrap(~type, scales = 'free')
  return(d)
}
jpablo91/Pabloverse documentation built on April 11, 2024, 2:54 p.m.