choosethin {systemicrisk} | R Documentation |
Calibrate Thinning
Description
Attempts to automatically choose a thinning paramter to achieve an overall relative effective sample size (defined as the effective sample size divided by the number of samples) for all parameters in the model (that do not seem to be constant). This function provides no guarantees that the desired relative effective sample size (rESS) will actually be achieved - it is best treated as a rough guide for this.
Usage
choosethin(
l,
a,
L_fixed = NA,
model,
relESStarget = 0.3,
burnin = 100,
matrpertheta = length(l)^2,
silent = TRUE,
maxthin = 10000
)
Arguments
l |
observed row sum |
a |
observerd column sum |
L_fixed |
Matrix containing known values of L, where NA
signifies that an element is not known. If |
model |
Underlying model for p and lambda. |
relESStarget |
Target for the relative effective sample size, must be in (0,1). Default 0.3. |
burnin |
number of iterations for the burnin. Defaults to 5 of the steps in the sampling part. |
matrpertheta |
number of matrix updates per update of theta. |
silent |
(default FALSE) suppress all output (including progress bars). |
maxthin |
Upper bound on thinning to consider. Default 10000. |
Details
The approach used involves a pilot run of the sampler, followed by a computation of the acf (autocorrelation function) for each component. The acf is used only up to (and excluding) the point used where it becomes negative for the first time. This part of the acf is then used to approximate the rESS and to determine the amount of thinning needed. The reported result is the thinning needed to achieve the rESS for all components (the matrix as well as the parameter theta). The initial pilot run may not be sufficient and further pilot runs may have to be started.
Value
An integer describing the amount of thinning required.
Examples
set.seed(12689)
n <- 10
m <- Model.Indep.p.lambda(Model.p.BetaPrior(n),
Model.lambda.GammaPrior(n,scale=1e-1))
x <- genL(m)
l <- rowSums(x$L)
a <- colSums(x$L)
choosethin(l,a,model=m)
choosethin(l,a,model=m,relESStarget=0.7)