target: Class: target distribution

Description Objects from the Class Important slots Optional slots Methods Author(s) Examples

Description

This class represents target distributions, that is, probability distributions from which we want to sample using MCMC or Wang-Landau.

Objects from the Class

Objects should created by calls of the function target. Examples are provided that should help implementing any continuous probability distributions.

Important slots

dimension:

Object of class "numeric": should be an integer specifying the dimension of the state space on which the target distribution is defined.

logdensity:

Object of class "function" : should be a function taking n points in the state space and parameters, and returning a vector of n real values. See the example below. This function is in most cases the most time-consuming part in a MCMC algorithm, so make sure it runs reasonably fast!

rinit:

Object of class "function" : this function should take an integer as argument, say n. Then the function should return a matrix of dimension n times d (where d is the dimension of the state space), representing n points in the state space. These n points will be used as starting points of a parallel MCMC algorithm.

Optional slots

parameters:

Object of class "list" : you can put anything in that list (and nothing, which is the defaults), the important thing is that calls to logdensity(x, parameters)

return sensible values. For example, for a gaussian target distribution, you can put the mean and the variance in the parameters list (see example below). If need be, you can put a whole data set in there.

type:

Object of class "character" : could be "continuous" or "discrete"; default is "continuous".

name:

Object of class "character" : ... if you want to name your distribution (default is "unspecified").

generate:

Object of class "function" : does not have to be specified, but if it is specified it should be a function to generate from the distribution (like rnorm is to the standard normal distribution).

Methods

show

signature(object = "target"): provides a little summary of a target object when called (or when print is called).

Author(s)

Luke Bornn <bornn@stat.harvard.edu>, Pierre E. Jacob <pierre.jacob.work@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  showClass("target")
  # starting points for MCMC algorithms
  rinit <- function(size) rnorm(size)
  # target log density function: a gaussian distribution N(mean = 2, sd = 3)
  parameters <- list(mean = 2, sd = 3)
  logdensity <- function(x, parameters) dnorm(x, parameters$mean, parameters$sd, log = TRUE)
  # creating the target object
  gaussiantarget <- target(name = "gaussian", dimension = 1,
                    rinit = rinit, logdensity = logdensity,
                    parameters = parameters)
  print(gaussiantarget)

PAWL documentation built on May 2, 2019, 5:58 a.m.