sample_HierarchicalModel {systemicrisk} | R Documentation |
Sample from Hierarchical Model with given Row and Column Sums
Description
Sample from Hierarchical Model with given Row and Column Sums
Usage
sample_HierarchicalModel(
l,
a,
L_fixed = NA,
model,
nsamples = 10000,
thin = choosethin(l = l, a = a, L_fixed = L_fixed, model = model, matrpertheta =
matrpertheta, silent = silent),
burnin = NA,
matrpertheta = length(l)^2,
silent = FALSE,
tol = .Machine$double.eps^0.25
)
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. |
nsamples |
number of samples to return. |
thin |
how many updates of theta to perform before outputting a sample. |
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). |
tol |
tolerance used in checks for equality. Defaults to |
Value
The resulting samples. A list with the first element, L, giving the samples of matrices, and the second element, theta, giving the samples of the hyperparameter (if hyperparameters are present).
Examples
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)
res <- sample_HierarchicalModel(l,a,model=m)
# fixing one values
L_fixed <- matrix(NA,ncol=n,nrow=n)
L_fixed[1,2:5] <- x$L[1,2:5]
res <- sample_HierarchicalModel(l,a,model=m,L_fixed=L_fixed,
nsamples=1e2)
sapply(res$L,function(x)x[1,2:5])