transition_test {AnimalSequences} | R Documentation |
Perform a Statistical Test for Transition Probabilities
Description
This function performs a permutation test to evaluate the significance of observed transition probabilities in sequences. It compares the observed transition probabilities to those obtained from permuted sequences to determine if the observed probabilities are significantly different from what would be expected by chance.
Usage
transition_test(sequences, observed_probs, n_permutations = 1000)
Arguments
sequences |
A character vector of sequences where each sequence is represented as a string of elements separated by spaces. |
observed_probs |
A data frame containing observed transition probabilities with columns |
n_permutations |
An integer specifying the number of permutations to perform. Default is 1000. |
Details
- **Observed Transition Probabilities**: Calculated from the input sequences.
- **Permutations**: The sequences are permuted n_permutations
times, and transition probabilities are computed for each permutation.
- **P-Values**: Calculated as the proportion of permuted transition probabilities that are greater than or equal to the observed transition probabilities.
Value
A data frame with the observed transition probabilities, expected probabilities from permutations, and p-values for each transition. The data frame contains the following columns:
previous_element |
The element preceding the transition. |
element |
The element following the transition. |
probability |
The observed probability of the transition. |
expected_probability |
The mean probability of the transition obtained from permuted sequences. |
p_value |
The p-value indicating the significance of the observed probability compared to the permuted probabilities. |
Examples
# Example sequences
sequences <- c('e1 e2 e3', 'e2 e3 e4', 'e3 e4 e1')
# Calculate observed transition probabilities
observed_probs <- calculate_transition_probs(sequences)
# Perform the transition test
test_results <- transition_test(sequences, observed_probs, n_permutations = 50)
# View results
head(test_results)