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 |
dsample
generates a sample of specified size n
from the target density function (up to a normalizing constant) based on the Wang-Lee algorithm.
dsample(expr, rpmat, n = 1000, nk = 10000, wconst)
dsample(expr, rpmat, n = 1000, nk = 10000, wconst)
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’. |
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.
dsample
gives the samples in data.frame
with number of rows n
and number of columns ncol(rpmat)
.
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
## 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)
## 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)
The samples generated by the Wang-Lee algorithm are plotted for visual examination. The plot is useful when multiple modes exist.
## S3 method for class 'dsample' plot(x, which, ...)
## S3 method for class 'dsample' plot(x, which, ...)
x |
an object produced by |
which |
plot type, 1: CDF, 2: Contours, and 3: Histogram. |
... |
arguments passing functions inside |
plot.dsample
has no return value.
Producing basic summary statistics (mean, standard deviation and the first five modes) from the sample drawn for all marginal distributions.
## S3 method for class 'dsample' summary(object, n = 5, k = 1, ...)
## S3 method for class 'dsample' summary(object, n = 5, k = 1, ...)
object |
|
n |
the first n samples |
k |
number of clusters |
... |
arguments passing to the functions used internally |
summary.dsample
gives a list of summary statistics.
means |
Means |
stdevs |
Standard deviations |
modes |
Modes |
hc |
object produced by |
grp |
cluster members produced by |
X |
samples generated by |
cdf |
cumulative distributions |