Computes the conditional probabilities of a categorical time series
Computes the conditional probabilities of a categorical time series
conditional_probabilities returns a matrix with the conditional probabilities of a categorical time series
UTF-8
conditional_probabilities(series, lag =1)
Arguments
series: An object of type tsibble (see R package tsibble), whose column named Value contains the values of the corresponding CTS. This column must be of class factor and its levels must be determined by the range of the CTS.
lag: The considered lag (default is 1).
Returns
A matrix with the conditional probabilities.
Details
Given a CTS of length T with range V={1,2,…,r}, Xt={X1,…,XT}, the function computes the matrix Pc(l)=(pijc(l))1≤i,j≤r, with pijc(l)=(T−l)NiTNij(l), where Ni is the number of elements equal to i in the realization Xt and Nij(l) is the number of pairs (Xt,Xt−l)=(i,j) in the realization Xt.
Examples
sequence_1 <- GeneticSequences[which(GeneticSequences$Series==1),]matrix_cp <- conditional_probabilities(series = sequence_1)# Computing the matrix of# joint probabilities for the first series in dataset GeneticSequences