Create Precision Matrices
makeprec.Rd
Creates precision matrices for gridded GMRF.
Usage
precmat.GMRFreglat(n,m, par, model = "m1p1", eps = getOption("spam.eps"))
Details
The function should be illustrative on how to create precision matrices for gridded GMRF. Hence, no testing (positive definiteness is done).
The model specification "m"
determines the complexity and
"p"
the number of parameters.
Please see the examples on the meaning of the different models.
Examples
as.matrix(precmat.GMRFreglat(4, 3, c(.4), 'm1p1'))
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] 1.0 -0.4 0.0 0.0 -0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0
#> [2,] -0.4 1.0 -0.4 0.0 0.0 -0.4 0.0 0.0 0.0 0.0 0.0 0.0
#> [3,] 0.0 -0.4 1.0 -0.4 0.0 0.0 -0.4 0.0 0.0 0.0 0.0 0.0
#> [4,] 0.0 0.0 -0.4 1.0 0.0 0.0 0.0 -0.4 0.0 0.0 0.0 0.0
#> [5,] -0.4 0.0 0.0 0.0 1.0 -0.4 0.0 0.0 -0.4 0.0 0.0 0.0
#> [6,] 0.0 -0.4 0.0 0.0 -0.4 1.0 -0.4 0.0 0.0 -0.4 0.0 0.0
#> [7,] 0.0 0.0 -0.4 0.0 0.0 -0.4 1.0 -0.4 0.0 0.0 -0.4 0.0
#> [8,] 0.0 0.0 0.0 -0.4 0.0 0.0 -0.4 1.0 0.0 0.0 0.0 -0.4
#> [9,] 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 0.0 1.0 -0.4 0.0 0.0
#> [10,] 0.0 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 -0.4 1.0 -0.4 0.0
#> [11,] 0.0 0.0 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 -0.4 1.0 -0.4
#> [12,] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.4 0.0 0.0 -0.4 1.0
as.matrix(precmat.GMRFreglat(4, 3, c(.4,.3), 'm1p2'))
#> [,1] [,2] [,3] [,4] [,5] [,6]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0.0 0.0 -0.2 -0.3 0.0 0.0 -0.4 1.0 0.0 0.0 -0.1 -0.3
#> [9,] 0.0 0.0 0.0 0.0 -0.3 -0.1 0.0 0.0 1.0 -0.4 0.0 0.0
#> [10,] 0.0 0.0 0.0 0.0 -0.2 -0.3 -0.1 0.0 -0.4 1.0 -0.4 0.0
#> [11,] 0.0 0.0 0.0 0.0 0.0 -0.2 -0.3 -0.1 0.0 -0.4 1.0 -0.4
#> [12,] 0.0 0.0 0.0 0.0 0.0 0.0 -0.2 -0.3 0.0 0.0 -0.4 1.0
# up to the diagonal, the following are equivalent:
cleanup( precmat.IGMRFreglat(3,4) -
precmat.GMRFreglat(3,4,1, 'm1p1'))
#> [1] 1 2 1 2 3 2 2 3 2 1 2 1
#> Class 'spam' (32-bit)