LSBP_VB: Variational Bayes algorithm for the LSBP model

View source: R/LSBP.R

LSBP_VBR Documentation

Variational Bayes algorithm for the LSBP model

Description

This function is an implementation of the variational Bayes Algorithm 3 in Rigon, T. and Durante, D. (2020).

Usage

LSBP_VB(Formula, data, H, prior, control = control_VB(), verbose = TRUE)

Arguments

Formula

An object of class Formula: a symbolic description of the model to be estimated. The details of model specification are given under "Details".

data

A data frame containing the variables described in Formula. The data frame must be provided.

H

An integer indicating the number of mixture components.

prior

A list of prior hyperparameters as returned by prior_LSBP. If missing, default prior values are used, although this is NOT recommended.

control

A list as returned by control_VB.

verbose

A logical value indicating whether additional information should be displayed while the algorithm is running.

Details

The Formula specification contains the response y, separated from the covariates with the symbol '~', and two sets of covariates. The latters are separated by the symbol '|', indicating the kernel covariates and the mixing covariates, respectively. For example, one could specify y ~ x1 + x2 | x3 + x4. NOTE: if the second set of covariates is omitted, then it is implicitely assumed that the two sets are the same.

If offsets or weights are provided in Formula, they will be IGNORED in the current version. A predict method is available and described at predict.LSBP_VB.

Value

The output is an object of class "LSBP_VB" containing the following quantities:

  • param. A list containing the parameters for the variational approximation of each distribution: mu_mixing, Sigma_mixing, mu_kernel, Sigma_kernel, a_tilde, b_tilde.

  • cluster. A n dimensional vector containing, for each observation, the mixture component having with the highest probability.

  • z. A n x H matrix containing the probabilities of belonging to each of the mixture components, where n denotes the number of observations.

  • lowerbound. The lowerbound is the evidence lower bound (ELBO) of the model at convergence. NOTE: the lowerbound is reported up to an additive constant.

  • call. The input Formula.

  • data. The input data frame.

  • control. The control list provided as input.

  • H. The input number of mixture components.

  • prior. The input prior hyperparameters.

References

Rigon, T. and Durante, D., (2020), Tractable Bayesian density regression via logit stick-breaking priors. Journal of Statistical Planning and Inference.

Examples

data(cars)

# A model with constant kernels
fit_vb <- LSBP_VB(dist ~ 1 | speed, data = cars, H = 4)
plot(cars)
lines(cars$speed, colMeans(predict(fit_vb)))

# A model with linear kernels
fit_vb <- LSBP_VB(dist ~ speed | speed, data = cars, H = 2)
plot(cars)
lines(cars$speed, colMeans(predict(fit_vb)))


tommasorigon/LSBP documentation built on Feb. 25, 2023, 2:47 a.m.