Skip to contents

Obtain samples from the fitted LnGM model parameters.

Usage

# S4 method for ngvb.list
simulate(
  object,
  n.sampling = object@configs$n.sampling,
  components = c("LGM", "V", "ng"),
  improved.tail = FALSE,
  augmentation = 10
)

Arguments

object

An ngvb.list object (output of ngvb function).

n.sampling

Integer. Number of samples.

components

Vector containing c("LGM","V","ng","hyperpar"). If components contains "LGM" then it generates samples of \((\mathbf{x},\boldsymbol{\theta})\) using inla.posterior.sample. If it contains "hyperpar" then generate samples of \(\boldsymbol{\theta}\) using inla.hypearpar.sample. It it contains "V" or "ng" then generate samples from the mixing variables \(\mathbf{V}\) and \(\eta\) for each model component, respectively.

improved.tail

Logical. If TRUE generate leptokurtic samples of the the latent field \(\mathbf{x}\). It first generates samples of \((\mathbf{V},\boldsymbol{\theta})\) and then it generates samples of \(\mathbf{x} | \mathbf{V} , \boldsymbol{\theta}, \mathbf{y}\) (which is an LGM) by fitting an INLA model each time and generating n = augmentation samples. Slow. Reduce n.sampling for speed and increase augmentation to obtain more samples.

augmentation

Integer. If improved.tail = TRUE, then for each sample of \((\mathbf{V},\boldsymbol{\theta})\) generate n = augmentation samples of \(\mathbf{x} | \mathbf{V} , \boldsymbol{\theta} , \mathbf{y}\).

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)

 #Fit LnGM with ngvb
 LnGM <- ngvb(fit = LGM, selection = list(x=1:100))

 #Available methods
 summary(LnGM)
 print(LnGM)
 plot(LnGM)
 fitted(LnGM)
 samples <- simulate(LnGM)
 }