View source: R/GenerateRV.CopApprox.R
GenerateRV.CopApprox | R Documentation |
Method to sample random variates from an object of class
‘CopApprox’.
## S3 method for class 'CopApprox'
GenerateRV(
obj,
n,
MH = FALSE,
trace = FALSE,
PDF = NULL,
burnin = 500,
thinning = 5,
...
)
obj |
object from which to sample. |
n |
number of items to sample. |
MH |
logical, should a Metropolis-Hastings algorithm be used to refine the sample? Default is |
trace |
logical, indicating whether the function should be verbose. |
PDF |
probability density function corresponding to copula used to create |
burnin |
the number of burn-in iterations of the MH sampler, only used if |
thinning |
the thining parameter, only used if |
... |
not used. |
If argument MH
is FALSE
, the default, random variates are directly sampled from the approximation, as described in Tajvidi and Turlach (2017).
If MH
is TRUE
, GenerateRV
uses additionally a Metropolis-Hastings refinement. It first samples from the approximation, but uses those samples then as proposals in a Metropolis-Hastings algorithm. The latter needs the probability density function of the copula. This density function has either to be passed to the argument PDF
, or the copula (stored in argument obj
) belonging to the approximation must have the density function (with name ‘pdfCopula
’) stored in its environment. In the latter case, the argument PDF
can be NULL
(its default).
A matrix of dimension n
times dim
, where dim
is the dimension for which the copula approximation was determined.
If MH
was TRUE
the return value has an attribute called ‘AcceptanceRate
’, indicating the fraction of samples that were accepted in the Metropolis-Hastings step. This fraction is based on all burnin + (n-1)*thinning + 1
samples that are initially generated from the approximation.
Tajvidi, N. and Turlach, B.A. (2017). A general approach to generate random variates for multivariate copulae, Australian & New Zealand Journal of Statistics 60(1): 140–155. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/anzs.12209")}.
GetApprox
cop <- NewBEVAsyMixedModelCopula(theta=1, phi=-0.25)
approx1 <- GetApprox(cop)
approx2 <- GetApprox(cop, type = 1)
sample1 <- GenerateRV(approx1, 100)
plot(sample1)
sample2 <- GenerateRV(approx2, 100)
plot(sample2)
sample1 <- GenerateRV(approx1, 50, MH = TRUE, trace = TRUE)
plot(sample1)
sample2 <- GenerateRV(approx2, 50, MH = TRUE)
plot(sample2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.