wishart_model: Wishart-related Models

Description Usage Arguments Details Value Examples

Description

Defining a wrapper object class wm_model that can represent Wishart, Normalised Wishart, Inverse Wishart, and Normalised Inverse Wishart

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
wm_model(type, V = NULL, df = NULL, V_chol = NULL, lower_chol = FALSE)

wm_latent(model, W = NULL, W_chol = NULL, lower_chol = NULL, ...)

wm_chol(model, latent, lower_chol = NULL, ...)

wm_matrix(model, latent, ...)

wm_matrix_jacobian(model, latent, symmetric = TRUE, h = 1e-04, ...)

wm_chol_jacobian(
  model,
  latent,
  symmetric = TRUE,
  h = 1e-04,
  lower_chol = NULL,
  ...
)

wm_moments_linear(
  model,
  mean_latent = rep(0, model$N_latent),
  cov_latent = sparse_identity(model$N_latent),
  order = c(2, 1),
  h = 1e-04,
  ...
)

wm_density(
  model,
  latent = NULL,
  W = NULL,
  W_chol = NULL,
  lower_chol = NULL,
  log = FALSE
)

Arguments

type

Either 'wishart', 'nwishart', 'iwishart', 'niwishart'

V

The matrix parameter for the distribution

df

The degrees-of-freedom parameter for the distribution

V_chol

The Cholesky factor of V. Type must match the lower_chol parameter

lower_chol

logical; For wm_model, whether the internal representation should use lower triangular Cholesky factors. For other methods, determines what Cholesky type input is or output should be returned as, with NULL inheriting the internal model setting. Default for wm_model is FALSE, for other methods default is NULL.

model

A wm_model object

W

A symmetric matrix valid for the value space of the model type

W_chol

The Cholesky factor of a matrix valid for the value space of the model type. Only one of W and W_chol may be given.

...

Further parameters passed on to other methods

latent

A numeric vector of length model$N_latent for the latent representation of a model outcome

symmetric

logical; If TRUE, use symmetric finite differences to compute derivatives

h

positive delta for finite differences

mean_latent

Expectation vector for the latent variables

cov_latent

Covariance matrix for the latent variables

order

A vector of two integers defining the Taylor expansion orders used for linearised moment calculations for expectation and variance, respectively. Can be either 1 or 2. Default: c(2, 1)

log

If TRUE, return the log-density, Default: FALSE

Details

For wm_moments_linear, the further ... parameters are passed on to wm_matrix_jacobian.

The wm_density() method requires the CholWishart::lmvgamma function from the CholWishart package.

Value

wm_model() returns a wm_model object that encapsulates the parameters of one of the four Wishart model types, as defined by type.

wm_latent() returns the latent variables for the representation of a (W/NW/IW/NIW) matrix, given either the matrix itself in W, or its Cholesky factor in W_chol.

wm_chol() returns the Cholesky factor of a (W/NW/IW/NIW) matrix.

wm_matrix() returns a (W/NW/IW/NIW) matrix.

wm_matrix_jacobian() returns the Jacobian for the (column-)vectorised (see cvec()) matrix with respect to the latent variables.

wm_chol_jacobian() returns the Jacobian for the column-vectorised (see cvec()) Cholesky matrix with respect to the latent variables, with type determined by the lower_chol setting.

wm_moments_linear() returns linearised approximations of propagated mean and standard deviation of the Wishart matrix given mean and covariance of the latent variables.

wm_density() returns the density or log-density (if log == TRUE) for W, or the W matrix constructed from a Cholesky factor W_chol

Examples

1
2
3
4
5
6
## Not run: 
if (interactive()) {
  # EXAMPLE1
}

## End(Not run)

finnlindgren/multiprobit documentation built on June 20, 2020, 6:12 a.m.