# luck-package: Generalized iLUCK Models for Bayesian Inference with Sets of... In luck: Generalized iLUCK models

## Description

Generalized iLUCK-models are a way to define sets of priors based on conjugate priors that allow for easy inference and a reasonable behaviour in case of prior-data conflict.

## Details

Generalized iLUCK-models belong to the domain of imprecise (or interval) probability models. Instead of a single prior distribution, a set of priors is used to model prior information. This set is updated element by element by Bayes' rule to form the set of posterior distributions, on which all inferences can be based. The package offers a general framework to handle sets of conjugate priors and methods for inferences based on them.

For sample distributions belonging to the regular, canonical exponential family (Bernardo and Smith 2000, pp. 202 and 272f), there is a general construction method to obtain a conjugate prior. The resulting prior for any distibution of this family can be expressed via the canonical parameters y^(0) and n^(0), forming a general superstructure for conjugate priors. The canonical parameters y^(0) and n^(0) are usually transformations of the commonly used parameters of the prior. In most cases, y^(0) can be seen as parameter of location and is called "main prior parameter" here. n^(0) determines the spread of the prior and can be seen as an inverse variance parameter.

In the canonical parametrization with y^(0) and n^(0), a prior is updated to the posterior by the updating the prior parameters y^(0) and n^(0) to their posterior counterparts by

n^(n) = n^(0) + n,

y^(n) = (n^(0)*y^(0) + tau(x))/(n^(0) + n),

where τ(x) is a sufficient statistic of the data vector x derived during the construction of the prior, and n is the sample size. Due to the role of n^(0) in the update step, it is also called "prior strength parameter".

In the generalized Bayesian approach as described in Walter and Augustin (2009), sets of priors are created by considering sets of these parameters: a prior with ...

• both y^(0) and n^(0) as single numbers is a LUCK-model

• y^(0) interval-valued and n^(0) as single number is an iLUCK-model

• both y^(0) and n^(0) interval-valued is a generalized iLUCK-model.

The package thus implements the general structure of priors in the canonical form where none, one or both y^(0) and n^(0) can be interval-valued. Implemented in the `S4` class system of R, the `LuckModel` class contains next to slots for n^(0) and y^(0) also an optional data slot, supplying the data in the form needed (τ(x)) for the update step. The data is supplied by the `LuckModelData` class in the needed form.

For a concrete data distribution, special cases of this general structure are needed. One must thus define a class extending the `LuckModel` class, and also a class extending `LuckModelData`, such that raw data can be easily converted to the needed form. Currently, this has been done for data from a scaled normal distribution, i.e. x \sim N(μ, 1), with the classes `ScaledNormalLuckModel` and `ScaledNormalData`, and for data from an exponential distribution, i.e. x \sim Exp(λ), with the classes `ExponentialLuckModel` and `ExponentialData`.

A vignette giving step-by-step instructions to programming classes for a new sample distribution will be included in future versions of the package.

As the posterior parameter sets resulting from updating all the priors in a prior set are not two-dimensional intervals anymore, posterior sets are not explicitely represented as `LuckModel` objects. Whenever posterior quantities are of interest (specified in methods by the option `"posterior = TRUE"`), the range of these quantities are calculated by minimizing and maximizing over the updated parameters, which in turn can be done by a box-constrained optimization over the set of prior parameters. This is why the data object is directly included in the `LuckModel` object. For the box-constrained optimization, a helper function called `wrapOptim` is used to be able to treat all cases (none, one or both canonical parameters are interval-valued) in the same way.

For illustrations of and workings with LuckModel objects, some methods have been written. First, there are methods to display and print plain `LuckModel` objects (existing only on the superstructure level):

• The `show` method prints the contents of a `LuckModel` object in more readable form. If the object contains a `LuckModelData` object, this is printed along as well, resorting on a `show` method for `LuckModelData` objects. (`show` methods are the `S4` equivalent to `print` methods for `S3` objects.)

• the `plot` method represents the prior or posterior parameter sets graphically.

Second, for concrete data distributions, there are methods for working with and displaying the resulting sets of prior/posterior distributions:

• The `show` methods for `LuckModel` and `LuckModelData` are specialized in order to explain the meaning of the canonical parameters n and y.

• `unionHdi` calculates the union of highest density intervals for a specialized LuckModel object. This method relies on a function `singleHdi` that gives a highest density interval for a single parameter combination (n, y) for the respective conjugate prior or posterior distribution. Therefore, for each specialized `LuckModel` class, `singleHdi` must be provided.

• `cdfplot` plots the set of cumulative density functions for a specialized `LuckModel`. Again, this method relies on a function `singleCdf` that gives values of the cdf for a single parameter combination (n, y) for the respective conjugate prior distribution.

## Author(s)

Gero Walter, Norbert Krautenbacher

Maintainer: Gero Walter <[email protected]>

## References

Gero Walter and Thomas Augustin (2009), Imprecision and Prior-data Conflict in Generalized Bayesian Inference, Journal of Statistical Theory and Practice 3:255-271.

Norbert Krautenbacher (2011), Ein Beitrag zur generalisierten Bayes-Inferenz: Erweiterung und Anwendung der Implementierung der generalized iLUCK-models (A Contribution to Generalized Bayesian Inference: Extension and Application of the Implementation of Generalized iLUCK models, in German), Bachelor's thesis, LMU Munich.

See `LuckModel` and `LuckModelData` for the abstract framework, and `ScaledNormalLuckModel` and `ScaledNormalData`, or `ExponentialLuckModel` and `ExponentialData`, for the use of the framework in case of data from a scaled normal, or exponential distribution, respectively.
See `cdfplot` or `unionHdi` for examples of inferences based on sets of distributions.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24``` ```# generate an abstract generalized iLUCK model ex1 <- LuckModel(n0=c(1,10), y0=c(0,5)) ex1 # with abstract data object data1 <- LuckModelData(tau=11, n=2) data1 ex1d <- ex1 data(ex1d) <- data1 ex1d # generate a generalized iLUCK model for scaled normal data ex2 <- ScaledNormalLuckModel(ex1, data=rnorm(mean=4, sd=1, n=10)) ex2 # plot the posterior set of canonical parameters plot(ex2, control = controlList(posterior = TRUE)) # plot the prior and posterior set of cdf functions par(mfrow = c(1,2)) cdfplot(ex2) cdfplot(ex2, control = controlList(posterior = TRUE)) par(mfrow = c(1,1)) # calculate the union of hpd intervals unionHdi(ex2, posterior=TRUE)\$borders ```