| dTV_sample | R Documentation |
Calculates the total variation distance between distributions conditioned in a given past sequence.
dTV_sample(S, j, A = NULL, base, lenA = NULL, A_pairs = NULL, x_S)
S |
A numeric vector of positive integers (or |
j |
A positive integer representing a lag in the |
A |
A vector of unique positive integers (state space) with at least two elements. |
base |
A data frame with sequences of elements from |
lenA |
An integer |
A_pairs |
A two-column matrix with all unique pairs of elements from |
x_S |
A vector of length |
This function computes the total variation distance between distributions
found in base, which is expected to be the output of the function freqTab().
Therefore, base must follow a specific structure (e.g., column names must
match, and a column named qax_Sj, containing transition distributions, must be
present). For more details on the output structure of freqTab(), refer to its
documentation..
If you provide the state space A, the function calculates:
lenA <- length(A) and A_pairs <- t(utils::combn(A, 2)).
Alternatively, you can input lenA and A_pairs directly and let
A <- NULL, which is useful in loops to improve efficiency.
Returns a vector of total variation distances, where each entry corresponds to the
distance between a pair of distributions conditioned on the same fixed past x_S,
differing only in the symbol indexed by j, which varies across all distinct pairs
of elements in A.The output has length equal to the number of unique pairs
in A_pairs.
#creating base argument through freqTab function.
pbase <- freqTab(S=c(1,4),j=2,A=c(1,2,3),countsTab = countsTab(testChains[,2],d=5))
dTV_sample(S=c(1,2),j=4,A=c(1,2,3),base=pbase,x_S=c(2,3))
pbase <- freqTab(S=NULL,j=1,A=c(1,2,3),countsTab = countsTab(testChains[,2],d=5))
dTV_sample(S=NULL,j=1,A=c(1,2,3),base=pbase)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.