autoplot.inla: Autoplot method for INLA objects

Description Usage Arguments Details Examples

View source: R/autoplot_inla.R

Description

Replicate the plots produced by plot using ggplot.

Usage

1
2
3
## S3 method for class 'inla'
autoplot(object, which = c(1:3, 5), priors = FALSE,
  CI = FALSE, ...)

Arguments

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

Details

The plot types are

  1. Marginal plot for fixed effects

  2. Marginal plot for hyper parameters

  3. Marginal line plot for random effects

  4. Marginal boxplot plot for random effects (more informative then 3, but gets big with lots of levels

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## 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)

INLAutils documentation built on Dec. 6, 2017, 5:06 p.m.