View source: R/autoplot_inla.R
autoplot.inla | R Documentation |
Replicate the plots produced by plot
using ggplot.
## S3 method for class 'inla' autoplot(object, which = c(1:3, 5), priors = FALSE, CI = FALSE, ...)
object |
An inla object. |
which |
Vector of integers selecting which plots (1 – 4) are wanted. |
priors |
Logical, plot priors as well. |
CI |
Plot credible intervals. TRUE for 95% CI or a numeric in [0, 1] |
... |
other arguments passed to methods |
The plot types are
Marginal plot for fixed effects
Marginal plot for hyper parameters
Marginal line plot for random effects
Marginal boxplot plot for random effects (more informative then 3, but gets big with lots of levels
## Not run: library(INLA) data(Epil) ##Define the model formula = y ~ Trt + Age + V4 + f(Ind, model="iid") + f(rand,model="iid") result = inla(formula, family="poisson", data = Epil, control.predictor = list(compute = TRUE)) plot(result) p <- autoplot(result) # Change the theme p <- p + theme_bw() # Add a title to a subplot p[[2]] <- p[[2]] + ggtitle('Hyper parameters') # Switch plot of fixed effects posteriors to not rescale x axis # If variables are on the same scale, this may provide a useful comparison p[[1]] <- p[[1]] + facet_wrap('var', scale = 'free_y') # Change colours etc. p[[1]]$layers[[1]] <- geom_line(colour = 'red', linetype = 2) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.