dTV_sample {hdMTD} | R Documentation |
The total variation distance between distributions
Description
Calculates the total variation distance between distributions conditioned in a given past sequence.
Usage
dTV_sample(S, j, A = NULL, base, lenA = NULL, A_pairs = NULL, x_S)
Arguments
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 |
Details
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.
Value
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
.
Examples
#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)