Package 'dsample'

Title: Discretization-Based Direct Random Sample Generation
Description: Discretization-based random sampling algorithm that is useful for a complex model in high dimension is implemented. The normalizing constant of a target distribution is not needed. Posterior summaries are compared with those by 'OpenBUGS'. The method is described: Wang and Lee (2014) <doi:10.1016/j.csda.2013.06.011> and exercised in Lee (2009) <http://hdl.handle.net/1993/21352>.
Authors: Chel Hee Lee [aut, cre] , Liqun Wang [aut]
Maintainer: Chel Hee Lee <[email protected]>
License: GPL-3
Version: 0.91.3.4
Built: 2024-12-08 06:55:05 UTC
Source: CRAN

Help Index


Generating Random Samples via Wang-Lee algorithm

Description

dsample generates a sample of specified size n from the target density function (up to a normalizing constant) based on the Wang-Lee algorithm.

Usage

dsample(expr, rpmat, n = 1000, nk = 10000, wconst)

Arguments

expr

expression of a target density function

rpmat

matrix containing random points for discretization

n

non-negative integer, the desired sample size.

nk

positive integer, the number of contours. See ‘Details’.

wconst

real number between 0 and 1. See ‘Details’.

Details

X has the number of rows equals to the number of discrete base points. In each row, the first element contains the functional value of the target density and the rest elements are the coordinates at which the density is evaluated. wconst is a constant for adjusting the volume of the last contour.

Value

dsample gives the samples in data.frame with number of rows n and number of columns ncol(rpmat).

References

Wang, L. and Lee, C.H. (2014). Discretization-based direct random sample generation. Computational Statistics and Data Analysis, 71, 1001-1010. Lee, C.H. (2009). Efficient Monte Carlo Random Sample Generation through Discretization, MSc thesis, Department of Satistics, University of Manitoba, Canada

Examples

## Example on page 414 in West (1993)
expr <- expression((x1*(1-x2))^5 * (x2*(1-x1))^3 * (1-x1*(1-x2)-x2*(1-x1))^37)
sets <- list(x1=runif(1e3), x2=runif(1e3))
smp <- dsample(expr=expr, rpmat=sets, nk=1e2, n=1e3)

Visualizing Wang-Lee Samples

Description

The samples generated by the Wang-Lee algorithm are plotted for visual examination. The plot is useful when multiple modes exist.

Usage

## S3 method for class 'dsample'
plot(x, which, ...)

Arguments

x

an object produced by dsample.

which

plot type, 1: CDF, 2: Contours, and 3: Histogram.

...

arguments passing functions inside

Value

plot.dsample has no return value.


Summary Statistics of Marginal Distributions

Description

Producing basic summary statistics (mean, standard deviation and the first five modes) from the sample drawn for all marginal distributions.

Usage

## S3 method for class 'dsample'
summary(object, n = 5, k = 1, ...)

Arguments

object

data.frame containing the samples drawn

n

the first n samples

k

number of clusters

...

arguments passing to the functions used internally

Value

summary.dsample gives a list of summary statistics.

means

Means

stdevs

Standard deviations

modes

Modes

hc

object produced by hclust

grp

cluster members produced by hclust

X

samples generated by dsample

cdf

cumulative distributions