Description Usage Format Details Value Methods Examples
Class to describe both univariate and multivariate ladders.
1 |
R6Class
object.
A multivariate ladder is a categorical distribution where the probability of each outcome is of the form
π_i(p) = R_i\frac{∏_{j=1}^m p_j^{n_{i,j}}}{C(p)}
where C(p) is a polynomial with real coefficients not divisible by any p_j, R_i is a strictly positive constant, n_{i,j} are possibly null positive integers and |n_i| = d. A ladder is fine if there are no redundant n_{i,j} and it is connected if for any π_i there exists a π_k where only one of the n_{i,j} is increased by one and another one is decreased by one.
Object of R6Class
with methods to construct connected and fine ladders as well as sampling from them.
new(M,R)
Construct an object of the class Ladder
.
M is a m \times k matrix describing the powers of p_1,p_2,...,p_k and
R is a k-long vector of coefficients.
print
Print information about the ladder, such as if it is a valid/connected/fine ladder.
get.connected
Return TRUE
if the ladder is connected.
update.fun(i,B,U)
Update function for the Markov chain. i
is the current state,
B
is a vector of rolls of the original die, U
is a vector of uniform random variables.
update.fun.R(i,B,U)
Same as update.fun
, but implemented in R rather than in C++. Generally slower.
update.fun.global(i,B,U)
Update function for the Markov chain. This update function is defined using
global properties of the chain. Albeit being valid, it leads to a slow CFTP implementation and it is thus deprecated.
Use update.fun
instead.
update.fun.slow(i,B,U)
Update function for the Markov chain. Albeit being valid, it's a slower
implementation than update.fun.R
and update.fun
and it is thus deprecated. Use update.fun
instead.
sample(n,roll.fun,true_p=NULL,num_cores=1,verbose=FALSE,global=FALSE,double_time=FALSE,...)
Get a sample from a
fine and connected ladder via Coupling From The Past (see CFTP
).
n
is required size of the sample, roll.fun
is a user defined R function that rolls the original die (optional parameters
can be passed). Instead of roll.fun
, the user can defined a fixed value of probabilites of the original die via true_p
for
debug purposes. num_cores
sets the numbers of cores used (supported only on Linux and Mac OS). If verbose = TRUE
a list is
returned where the first element is the sample and the second element are the rolls required to get such sample. When
global = TRUE
, update.fun.global
is used instead of update.fun
, leading to a valid but slower implementation and should not
be used. When double_time = TRUE
at each iteration of the CFTP algorithm, time is doubled instead of increased by 1 leading
to a slower implementation if rolling the die is costly.
evalute(p)
Evaluate the ladder when the true probability of the original die is given. Useful for debug purposes.
impose.fineness
Returns a list where the first object is a new fine ladder and the second object is
a vector that can be used to transform a sample from the new ladder in a sample from the original one. If the original ladder is
connected, so it is the new one. See disaggregation.sample
.
impose.connected
Returns a list where the first object is a new connected ladder and the second object is
a vector that can be used to transform a sample from the new ladder in a sample from the original one. See disaggregation.sample
.
get.a
Returns the global constant a used to define update.fun.global
. Useful for debug purposes.
get.P
Returns the transition matrix of the chain. Contains only the coefficients and not the values of the p_is.
get.P.moves
Returna a k \timex k matrix, where k is the number of states, describing which roll is necessary for the chain to move from state i to j.
get.P.cumsum
For internal use. Returns a a doubled indexed list. The first index is the current state, the second is the current roll. Returns the cumulative sum of the coefficients.
get.P.moves.list
For internal use. Returns a a doubled indexed list. The first index is the current state, the second is the current roll. Returns the index of the possible moves.
1 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.