1 About

This topic is not a regular topic. This page contains a set of exercises used as homework in INLA courses. When giving homework, refer to this page and the problem numbers. The solutions to these homeworks are not given out.

1.1 Packages

library(INLA)

2 A. Problems about precision matrices

2.1 Problem A.1. Draw GMRF graph

Draw the graph for the GMRF represented by the percision matrix \(Q\).

Q = matrix(c(1, 0, 1, 2, 0, 4, 0, 0, 1, 0, 3, 1, 2, 0, 1, 0), nrow=4, byrow=T)
cat("Q = \n")
## Q =
print(Q)
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    1    2
## [2,]    0    4    0    0
## [3,]    1    0    3    1
## [4,]    2    0    1    0

2.2 Problem A.2. Sample from precision matrix

The precision matrix \(Q\):

Q = matrix(c(1, 0, 1, 2, 0, 4, 0, 0, 1, 0, 3, 1, 2, 0, 1, 7), nrow=4, byrow=T)
cat("Q = \n")
## Q =
print(Q)
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    1    2
## [2,]    0    4    0    0
## [3,]    1    0    3    1
## [4,]    2    0    1    7

The cholesky factor of this \(Q\)is:

L = chol(Q)
cat("L = \n")
## L =
print(L)
##      [,1] [,2] [,3]  [,4]
## [1,]    1    0  1.0  2.00
## [2,]    0    2  0.0  0.00
## [3,]    0    0  1.4 -0.71
## [4,]    0    0  0.0  1.58

So we can produce \(Q\) from \(L\) in the following way:

print(t(L) %*% L)
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    1    2
## [2,]    0    4    0    0
## [3,]    1    0    3    1
## [4,]    2    0    1    7

Your task is to sample from the distribution \[u \sim \mathcal N(0, Q^ {-1}) \] without computing the inverse of \(Q\).

Compare the estimated covariance of your samples to the inverse of \(Q\).

2.3 Problem A.3. Calculate a precision matrix

The model for \(u\) is \[\begin{align} u_i - u_{i-1}&= \epsilon_i \qquad \text{for } i=2,3,4,5 \\ u_1 - u_5 &= \epsilon_1 \\ \epsilon_i &= \mathcal N(0, 3^2). \end{align}\] Write down the precision matrix for \(u\). This is \(Q\) in \[ u \sim \mathcal N(0, Q^ {-1}). \]

3 B. Problems about Latent Gaussian Models

3.1 Problem B.1.

Describe with a paragraph the first level of the 3-level hierarchy. I.e. the observation level, with the (observation) likelihood and the link function.

3.2 Problem B.2.

Describe with a paragraph the second level of the 3-level hierarchy. A.k.a. the latent variable, the linear predictor.

3.3 Problem B.3.

Describe with a paragraph the third level of the 3-level hierarchy. I.e. the hyper-parameters.

3.4 Problem B.4.

Explain why one of these is a valid Latent Gaussian Model (LGM) and the other is not.

\[\begin{align} \eta_i &= \beta_0 + X_{i} + U V_i \\ \eta_i &= \beta_0 + \beta_1 X_{i} + U_i V_i \end{align}\] Assume \[\begin{align*} y_i &\sim Poiss(\lambda_i = e^ {\eta_i}) \\ \beta_0 &\sim exp(1) \\ \beta_1 &\sim exp(1) \\ U &\sim \mathcal N(0, 1) \\ U_i &\sim \mathcal N(0, 1) \quad \text{for all } i \\ V_i &\sim \mathcal N(0, 1) \quad \text{for all } i, \end{align*}\] and that \(X\) is a known covariate.

4 C. Conceptual problems about INLA inference

4.1 Problem C.1.

Explain in a paragraph the difference between burn-in in an MCMC chain and how INLA searches for the posterior mode.

4.2 Problem C.2.

After we know the posterior mode in the hyper-parameter-space, what is the difference in how MCMC explores the posterior and how INLA explores the posterior?

4.3 Problem C.3.

A modeller wants to use the Gaussian likelihood with the following latent model \[\eta_i = ~ \beta_0 + X\beta + v_i \] with an iid model on \(v_i\), and uses

formula = y~ X + f(index, model="iid")

He complains that INLA is having trouble. What would you tell him?

5 D. Practical problems (not in space)

5.1 Problem D.1.

Use

data(Tokyo)
summary(Tokyo)
##        y              n          time    
##  Min.   :0.00   Min.   :1   Min.   :  1  
##  1st Qu.:0.00   1st Qu.:2   1st Qu.: 92  
##  Median :0.00   Median :2   Median :184  
##  Mean   :0.52   Mean   :2   Mean   :184  
##  3rd Qu.:1.00   3rd Qu.:2   3rd Qu.:275  
##  Max.   :2.00   Max.   :2   Max.   :366

and fit a time series over time with a binomial likelihood, where the number of trials is Tokyo$n. Improve this model by making the random effect cyclic. Try two different link functions (logit and probit) and compare the two linear predcitors and the two fitted values

5.2 Problem D.2.

Create a simulation-inference to understand the estimation in the previous problem. Do you think it is better to have several observations at each time point, or a larger n (and probably larger y values)?

Optional: Give a clear mathematical argument for your intuition.

6 E. Practical problems in space

6.1 Problem E.1.

Read and run the code in A first example of spatial data modeling (Calcium data). Change the two prior medians prior.median... and see what happens to the result.

6.2 Problem E.2.

Read and run the code in A first example of spatial data modeling (Calcium data). Change the mesh, plot the mesh plot(mesh), and see if the change impacts the results.