scale.model: Scale an intrinsic GMRF model

Description Usage Arguments Value Author(s) Examples

Description

This function scales an intrinsic GMRF model so the geometric mean of the marginal variances is one

Usage

1
2
     inla.scale.model(Q, constr = NULL, eps = sqrt(.Machine$double.eps))
 

Arguments

Q

A SPD matrix, either as a (dense) matrix or sparseMatrix

constr

Linear constraints spanning the null-space of Q; see ?INLA::f and argument extraconstr

eps

A small constant added to the diagonal of Q if constr

Value

inla.scale.model returns a sparseMatrix of type dgTMatrix scaled so the geometric mean of the marginal variances (of the possible non-singular part of Q) is one, for each connected component of the matrix.

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
 ## Q is singular
 data(Germany)
 g = system.file("demodata/germany.graph", package="INLA")
 Q = -inla.graph2matrix(g)
 diag(Q) = 0
 diag(Q) = -rowSums(Q)
 n = dim(Q)[1]
 Q.scaled = inla.scale.model(Q, constr = list(A = matrix(1, 1, n), e=0))
 print(diag(INLA:::inla.ginv(Q.scaled)))

 ## Q is singular with 3 connected components
 g = inla.read.graph("6 1 2 2 3 2 2 1 3 3 2 1 2 4 1 5 5 1 4 6 0")
 print(paste("Number of connected components", g$cc$n))
 Q = -inla.graph2matrix(g)
 diag(Q) = 0
 diag(Q) = -rowSums(Q)
 n = dim(Q)[1]
 Q.scaled = inla.scale.model(Q, constr = list(A = matrix(1, 1, n), e=0))
 print(diag(INLA:::inla.ginv(Q.scaled)))

 ## Q is non-singular with 3 connected components. no constraints needed
 diag(Q) = diag(Q) + 1
 Q.scaled = inla.scale.model(Q)
 print(diag(INLA:::inla.ginv(Q.scaled)))
 

inbo/INLA documentation built on Dec. 6, 2019, 9:51 a.m.