ggplot_inla_residuals2: Plot residuals against covariate values for INLA model using...

Description Usage Arguments Examples

View source: R/plot_inla_residuals.R

Description

Plot residuals against covariate values for INLA model using ggplot2

Usage

1
2
ggplot_inla_residuals2(inla.model, observed, CI = FALSE, se = TRUE,
  method = "auto")

Arguments

inla.model

An inla object

observed

The observed values

CI

plot credible intervals for each residual

se

Plot a ribbon showing the standard error of the smoother.

method

What method should be used for the smoother. Defaults to loess unless data is large. Other options include 'gam', 'loess', 'lm'. See geom_smooth for details.

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
26
## Not run: 
 library(INLA)
 data(Epil)
 observed <- Epil[1:30, 'y']
 Epil <- rbind(Epil, Epil[1:30, ])
 Epil[1:30, 'y'] <- NA
 ## make centered covariates
 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, link = 1))
 ggplot_inla_residuals2(result, observed)
 

 data(Seeds)
 l <- nrow(Seeds)
 Seeds <- rbind(Seeds, Seeds)
 Seeds$r[1:l] <- NA


 formula = r ~ x1 * x2 + f(plate, model = "iid")
 mod.seeds = inla(formula, data=Seeds, family = "binomial", Ntrials = n, 
                  control.predictor = list(compute = TRUE, link = 1))
 ggplot_inla_residuals2(mod.seeds, na.omit(Seeds$r / Seeds$n), method = 'lm')
 
## End(Not run)

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