Title: | Dirichlet-Based Polya Tree |
Version: | 1.0.1 |
Description: | Contains functions to perform copula estimation by the non-parametric Bayesian method, Dirichlet-based Polya Tree. See Ning (2018) <doi:10.1080/00949655.2017.1421194>. |
Depends: | R (≥ 3.3.1) |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | MCMCpack, stats, plyr, MASS, Rdpack |
RdMacros: | Rdpack |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | no |
Packaged: | 2018-06-19 02:29:13 UTC; ning |
Author: | Shaoyang Ning [aut, cre] |
Maintainer: | Shaoyang Ning <shaoyangning@fas.harvard.edu> |
Repository: | CRAN |
Date/Publication: | 2018-06-19 09:17:55 UTC |
Calculating sub-partition probabiltiy measures for a realized distribution from D-P tree.
Description
DPTreeDensity
returns
the probablity measures in the finest sub-partitions of a realized distribution from D-P tree prior/posterior.
Usage
DPTreeDensity(Z)
Arguments
Z |
An array of dimension of |
Value
A 2^m
by 2^m
matrix. Normalized measures for all 2^m
by 2^m
sub-partititons on copula space
given by the realized distribution from D-P tree.
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
dp.rlz <- RealizeDPTree(DPTreePrior(m=2, z=1))
DPTreeDensity(dp.rlz)
Calculating sub-partition probabiltiy measures for the posterior mean distribution from D-P tree.
Description
DPTreePMeanDensity
returns
the probablity measures in the finest sub-partitions of the posterior mean from D-P tree.
Usage
DPTreePMeanDensity(prior)
Arguments
prior |
A list. D-P tree specification. Should be in same format as returned from |
Value
A 2^m
by 2^m
matrix. Normalized measures for all 2^m
by 2^m
sub-partititons on copula space
given by the posterior mean distribution from D-P tree.
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
DPTreePMeanDensity(DPTreePrior(m=2, z=1))
D-P tree posterior updating from a single copula observation.
Description
DPTreePosterior
returns
the D-P tree posterior given input copula data.
Usage
DPTreePosterior(x, prior, w = 1)
Arguments
x |
An array of length 2. Single copula data observation. Each element should be between 0 and 1. |
prior |
A list. Should be in same format as returned from |
w |
A positive number. Weight of data for posterior updating. Default 1. |
Value
A list.
a |
An array containing the hyperparameters of D-P trees. |
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
nsim = 1
rho = 0.9
data1 <- MASS::mvrnorm(n=nsim, mu=rep(0, 2), Sigma=matrix(c(1, rho, rho, 1), 2, 2))
data2 <- stats::pnorm(data1)
DPTreePosterior(x=data2, prior=DPTreePrior(m=4, z=1))
D-P tree posterior updating from multiple copula observations.
Description
DPTreePosteriorMulti
returns
the D-P tree posterior given input copula data.
Usage
DPTreePosteriorMulti(x, prior, w = 1)
Arguments
x |
An array of dimension n by 2. Multiple copula data observations, with each row being a bivariate copula observation. All elements should be between 0 and 1. |
prior |
A list. Should be in same format as returned from |
w |
A positive number or an array of length n. Weight of data for posterior updating. Default 1. |
Value
A list.
a |
An array containing the hyperparameters of D-P trees. |
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
nsim = 10
rho = 0.9
data1 <- MASS::mvrnorm(n=nsim, mu=rep(0, 2), Sigma=matrix(c(1, rho, rho, 1), 2, 2))
data2 <- stats::pnorm(data1)
DPTreePosteriorMulti(x=data2, prior=DPTreePrior(m=4, z=1))
Generating the standard D-P Tree prior
Description
DPTreePrior
returns
a standard D-P Tree prior based on specified hyperparameters.
Usage
DPTreePrior(m = 4, z = 1)
Arguments
m |
A positive integer. The finite approximation level for D-P tree. Default m=4. |
z |
A positive number. On i-th level, the hyperparameter for D-P tree prior is
|
Value
A list.
a |
An array containing the hyperparameters of D-P trees. |
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
DPTreePrior(m=6, z=1)
Sampling a realized distribution from the D-P Tree.
Description
RealizeDPTree
returns
a realized (copula) distribtuion sampled from the input D-P Tree.
Usage
RealizeDPTree(prior)
Arguments
prior |
A list. Should be in same format as returned from |
Value
An array of dimension 2^m
by 2^m
by m. m is the approximation level.
Realized Z's for all partitions at each level.
Three dimensions reprensent two marginals, and the level respectively.
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
RealizeDPTree(DPTreePrior(m=2, z=1))
Sample a copula observation from a realized distribution from D-P tree.
Description
SampleDPTreeDensity
returns
a copula sample from a realized distribution from D-P tree.
Usage
SampleDPTreeDensity(nsam, d)
Arguments
nsam |
A positive integer. The sample size. |
d |
A |
Value
An array of dimension nsam by 2. The values of PDF of the input D-P tree distribution evaluated at the input points.
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
SampleDPTreeDensity(10, DPTreePMeanDensity(DPTreePrior(m=2, z=1)))
The disitribution function for realized distribution from D-P tree.
Description
dDPTreeRealize
returns
the value of density function of realized distribution from D-P tree at certain given point on copula space.
Usage
dDPTreeRealize(d, x)
Arguments
d |
A |
x |
An array of dimension n by 2. The points on copula space for density function evluation. Should be between 0 and 1. |
Value
An array of length n. The values of PDF of the input D-P tree distribution evaluated at the input points.
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
dDPTreeRealize(DPTreePMeanDensity(DPTreePrior(m=2, z=1)),c(0.5,0.5))
The disitribution function for realized distribution from D-P tree.
Description
pDPTreeRealize
returns
the value of distribution function of realized distribution from D-P tree at certain given point on copula space.
Usage
pDPTreeRealize(d, x)
Arguments
d |
A |
x |
An array of dimension n by 2. The points on copula space for distribution function evluation. Should be between 0 and 1. |
Value
An array of length n. The values of CDF of the input D-P tree distribution evaluated at the input points.
References
Ning S and Shephard N (2018). “A nonparametric Bayesian approach to copula estimation.” Journal of Statistical Computation and Simulation, 88(6), pp. 1081-1105. doi: 10.1080/00949655.2017.1421194.
Examples
pDPTreeRealize(DPTreePMeanDensity(DPTreePrior(m=2, z=1)),c(0.5,0.5))