# Diagnostic checks for the latent Gaussianity assumption in R-INLA

`ng.check.Rd`

Computes the BF sensitivity measures \(s_0(\mathbf{y})\) and \(I_0(\mathbf{y})\) of the non-Gaussianity parameter at the base Gaussian model: \( \log \pi(\eta|\mathbf{y}) \propto (s_0(\mathbf{y}) - \theta_\eta)\eta - \frac{I_0(\mathbf{y})}{2} \eta^2 + \mathcal{O}(\eta^2)\), where \(\theta_\eta\) is the rate parameter of the exponential PC prior on \(\eta\).

## Usage

```
ng.check(
fit,
Dfunc = NULL,
h = NULL,
selection = NULL,
compute.I0 = FALSE,
compute.predictor = FALSE,
compute.fixed = TRUE,
compute.random = FALSE,
plot = TRUE
)
```

## Arguments

- fit
The inla object that fits the LGM.

- Dfunc
Function that receives as input the hyperparameter vector \(\boldsymbol{\theta}\) in internal scale and the output is \(\mathbf{D}(\boldsymbol{\theta})\), where \(\mathbf{D}\) is the dependency matrix that specifies the non-Gaussian latent field. If there is more than one latent component to be extended to non-Gaussianity, this should be a list of functions \(\mathbf{D}_i(\boldsymbol{\theta})\), where \(\mathbf{D}_i(\boldsymbol{\theta})\) is the dependency matrix that specifies component i.

- h
Predefined constant \(\mathbf{h}\) vector that contains the distance between locations or area of the basis functions. For models defined in discrete space this should be a vector of ones. If there is more than one latent component to be extended to non-Gaussianity, this should be a list of vectors \(\mathbf{h_i}\) where \(\mathbf{h_i}\) is the predefined constant vector of component i.

- selection
List which specifies which model components of the LGM are to be extended to non-Gaussianity. Same syntax as the argument

`selection`

of the function`inla.posterior.sample`

.- compute.I0
Boolean. If

`TRUE`

compute \(I_0(\mathbf{y}, \hat{\boldsymbol{\gamma}})\) (asymptotic variance of the reference distribution) and p-value.- compute.predictor
Boolean. If

`TRUE`

computes the sensitivity measures for each predictor: \(\partial_\eta E[z_i|\mathbf{y},\eta]\), where \(z_i\) is the i\(^th\) element of the linear predictor- compute.fixed
Boolean. If

`TRUE`

computes the sensitivity measures for each fixed effect. \(\partial_\eta E[z_i|\mathbf{y},\eta]\), where \(z_i\) is the i\(^th\) fixed effect- plot
Boolean. Generate diagnostic plots.

## Value

A list that for each model component in `selection`

returns:

`BF.check`

The BF sensitivities \(s_0(\mathbf{y})\) and \(s_0(\mathbf{y}, \hat{\boldsymbol{\gamma}})\), where \(\hat{\boldsymbol{\gamma}}\) is the posterior mode of the hyperparameters. The variance of the reference distribution for LGMS with Gaussian response is also shown.`BF.index`

The contribution of each index to the overall BF sensitivity.`sens.fixed.matrix`

Sensitivity matrix, containing \(\partial_{\eta_i}E[z_j|\mathbf{y},\eta_i]\), where \(z_j\) is the j\(^th\) fixed effect and \(\eta_i\) is the non-Gaussianity parameter of the i\(^th\) random effect`sens.fixed.matrix`

Sensitivity matrix, containing \(\partial_{\eta_i}E[z_j|\mathbf{y},\eta_i]\), where \(z_j\) is the j\(^th\) index of the linear predictor and \(\eta_i\) is the non-Gaussianity parameter of the j\(^th\) random effect.

If `plot = TRUE`

, the BF sensitivities \(d_i(\mathbf{y})\) for each index are shown, and also the BF sensitivity at the observed
data \(s_0(\mathbf{y}, \hat{\boldsymbol{\gamma}})\) is compared to \(s_0(\mathbf{y}^\text{pred}, \hat{\boldsymbol{\gamma}}) \sim N(0,\eqn{I_0(\mathbf{y}), \hat{\boldsymbol{\gamma}}})\). For