Mismatch for precision matrix construction

21 views
Skip to first unread message

Pulong Ma

unread,
Jun 5, 2025, 9:11:02 PM6/5/25
to R-inla discussion group
Hello, 

I was trying to construct the precision matrix using with inla.spde2.precision(), but I got two different answers. The first approach is to directly pass the parameter theta=(log(tau), log(kappa)) to get the precision matrix; the second approach is to pass theta=(0, log(kappa)), and then multiple the resulting precision matrix by tau. According to the equation on Page 4 of Lindgren and Rue (2015, Bayesian modeling with R-INLA), I should get the same precision matrix. However, the following test indicates that they are quite different. Am I missing something here? Thank you very much for any suggestions. 

set.seed(123)

#--- Set up 2D grid
n1 <- 15
n2 <- 15
n <- n1 * n2
coords <- as.matrix(expand.grid(x = seq(0, 1, length.out = n1),
                                y = seq(0, 1, length.out = n2)))
# Construct SPDE-based GMRF
mesh <- inla.mesh.2d(loc      = coords,
                     cutoff   = 0.05,          # drop duplicates
                     max.edge = c(0.05, 0.1),  # inner / outer edge length
                     offset   = c(0.08, 0.1))  # extends mesh beyond data
spde <- inla.spde2.matern(mesh, alpha = 2)  # nu=alpha - d/2
log_tau = log(2)
log_kappa = log(0.5)

# the precision matrix Q = tau^2 * Q_0, where Q_0=kappa^4 C + 2*kappa^2 G_1 + G_2
Q1 = inla.spde2.precision(spde, c(log_tau,log_kappa))
Q0 = inla.spde2.precision(spde, c(0,log_kappa))
Q2 = exp(log_tau) * Q0

norm(Q1-Q2,"F")

Thanks,
Pulong M

Finn Lindgren

unread,
Jun 6, 2025, 2:09:47 AM6/6/25
to R-inla discussion group
I think it’s as simple as noting that
  exp(log_tau) != tau^2
Use
  exp(2 * log_tau)
instead.

Finn

On 6 Jun 2025, at 03:11, Pulong Ma <mpu...@gmail.com> wrote:

Hello, 
--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/r-inla-discussion-group/1abc5823-afcc-4c09-9eb0-91754ad7e0f8n%40googlegroups.com.

Pulong Ma

unread,
Jun 6, 2025, 12:36:24 PM6/6/25
to R-inla discussion group
Thank you very much for correcting my silly mistake.  

Best,
Pulong

Reply all
Reply to author
Forward
0 new messages