merge: Merge a mixture of 'inla'-objects

Description Usage Arguments Details Value Author(s) Examples

Description

Merge a mixture of inla-objects

Usage

1
2
3
4
     ## S3 method for class 'inla'
merge(x, y, ..., prob = rep(1,  length(loo)), verbose = FALSE)
     inla.merge(loo, prob = rep(1,  length(loo)), verbose = FALSE)
 

Arguments

x

An inla-object to be merged

y

An inla-object to be merged

...

Additional inla-objects to be merged

loo

List of inla-objects to be merged

prob

The mixture of (possibly unnormalized) probabilities

verbose

Turn on verbose-output or not

Details

The function merge.inla implements method merge for inla-objects. merge.inla is a wrapper for the function inla.merge. The interface is slightly different, merge.inla is more tailored for interactive use, whereas inla.merge is better in general code.

inla.merge is intented for merging a mixture of inla-objects, each run with the same formula and settings, except for a set of hyperparameters that are fixed to different values. Using this function, we can then integrate over these hyperparameters using (unnormalized) integration weights prob. The main objects to be merged, are the summary statistics and marginal densities (like for hyperparameters, fixed, random, etc). Not all entries in the object can be merged, and by default these are inheritated from the first object in the list, while some are just set to NULL. Those objectes that are merged, will be listed if run with option verbose=TRUE.

Note that merging hyperparameter in the user-scale is prone to discretization error in general, so it is more stable to convert the marginal of the hyperparameter from the merged internal scale to the user-scale. (This is not done by this function.)

Value

A merged inla-object.

Author(s)

Havard Rue hrue@r-inla.org

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
 set.seed(123)
 n = 100
 y = rnorm(n)
 y[1:10] = NA
 x = rnorm(n)
 z1 = runif(n)
 z2 = runif(n)*n
 idx = 1:n
 idx2 = 1:n
 lc1 = inla.make.lincomb(idx = c(1, 2, 3))
 names(lc1) = "lc1"
 lc2 = inla.make.lincomb(idx = c(0, 1, 2, 3))
 names(lc2) = "lc2"
 lc3 = inla.make.lincomb(idx = c(0, 0, 1, 2, 3))
 names(lc3) = "lc3"
 lc = c(lc1, lc2, lc3)
 rr = list()
 for (logprec in c(0, 1, 2))
     rr[[length(rr)+1]] = inla(y ~ 1 + x + f(idx, z1) + f(idx2, z2),
              lincomb = lc, 
              control.family = list(hyper = list(prec = list(initial = logprec))), 
              control.predictor = list(compute = TRUE, link = 1), 
              data = data.frame(y, x, idx, idx2, z1, z2))
 r = inla.merge(rr, prob = seq_along(rr), verbose=TRUE)
 summary(r)

INBO-BMK/INLA documentation built on Dec. 4, 2019, 11:43 p.m.