Approximate inference of latent non-Gaussian models (LnGMs)
ngvb.RdFinds the posterior distribution of the hyperparameters \(\boldsymbol{\theta}\), latent field \(\mathbf{x}\),
mixing variables \(\mathbf{V}\), and non-Gaussianity parameters \(\eta\) of latent non-Gaussian models (LnGMs)
using INLA and variational Bayes approximations. These LnGMs are flexible extensions
of latent Gaussian models (LGMs). The LnGMs are specified either through
an INLA object (fit) that fits an LGM or through a list of configurations (manual.configs).
Run `devtools::build_vignettes("ngvb")` and `vignette("ngvb")` to see several use cases.
Arguments
- fit
The inla object that fits the LGM.
- manual.configs
Not necessary if
fitis provided. List containing:inla.fit.VFunction that receives as input the mixing variables \(\mathbf{V}\) and the output is an inla object that fits the LGM \((\mathbf{x},\boldsymbol{\theta} | \mathbf{V}, \mathbf{y})\).DfuncFunction 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.hPredefined 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
selectionof the functioninla.posterior.sample.- alpha.eta
Numeric. Rate parameter of the exponential prior of the non-Gaussianity parameter \(\alpha\). Should be a vector with the same dimension as the number of model components to extend.
- n.sampling
Numeric. Number of samples uses in several sampling task throughout the SVI or SCVI algorithm.
- d.sampling
Logical. If
TRUEthe expectations \(d_i = E([\mathbf{D}\mathbf{x}]_i^2)\) are computed by sampling (slower). IfFALSE(default) uses the mixture Gaussian approximation of \(\mathbf{x}\) obtained in INLA.- method
Character. Should be
"SCVI","SVI", or"Gibbs"if the algorithm should be the structural and collapsed variational inference algorithm (faster) or the structural variational inference algorithm (slower), or a Gibbs sampler (even slower), respectively.- fast
Logical. If
TRUEthen INLA will be run with the empirical Bayes mode and several control variables will be turned off to improve the speed of the algorithm.- verbose
Logical. If
TRUEprint the posterior mean of \(\eta\) and plot the posterior mean of \(\mathbf{V}\) at each iteration.- history
Logical. If
TRUEsave LGM inla object of each iteration. IfFALSEonly save the LGM inla object of the last iteration.- V.init
List of numeric vectors. Initial values for \(\mathbf{V}\). By default \(\mathbf{V}=\mathbf{h}\).
- eta.init
Numeric vector. Initial values of \(\eta\). By default eta.init = 0.5.
- iter
Integer. Maximum number of iterations.
- stop.rel.change
Numeric. Stop the algorithm when the relative change in the posterior mean of \(\eta\) is smaller than
stop.rel.change.
Value
An S4 object containing the outputs. Slots are accessed with @. These are:
historyList containing summaries and inla objects (ifhistory = TRUE) of each iteration (except the last one).LGMinla object containing summaries and marginals of the latent field \(\mathbf{x}\) and hyperparameters \(\boldsymbol{\theta}\) of the last iteration.summary.mixingData frame containing summaries of the mixing variables \(\mathbf{V}\).summary.ngData frame containing summaries of the non-Gaussianiy parameters \(\eta\).configsList containing the LnGM model specifications
Examples
if (FALSE) {
#Here we fit an RW1 latent process to the jumpts time series
plot(jumpts)
#Fit LGM with INLA
LGM <- inla(y ~ -1 + f(x, model = "rw1"),
data = jumpts)
#Check adequacy of latent Gaussianity assumption
check.list <- ng.check(fit = LGM)
#Fit LnGM with ngvb
LnGM <- ngvb(fit = LGM)
#Available methods
summary(LnGM)
print(LnGM)
plot(LnGM)
fitted(LnGM)
samples <- simulate(LnGM)
}