transition_chisq: Perform a Chi-Squared Test for Transition Counts
Description
This function performs a chi-squared test to determine if there are significant differences between observed and expected transition counts in sequences. It calculates the chi-squared statistic and tests the null hypothesis that transitions occur according to the expected frequencies.
Usage
transition_chisq(sequences, alpha = 0.05)
Value
A list with two elements:
significant
A logical value indicating whether the chi-squared test result is significant at the given significance level.
p_value
A numeric value representing the p-value of the chi-squared test.
Arguments
sequences
A vector of sequences, where each sequence is a character string with elements separated by spaces.
alpha
A numeric value representing the significance level for the chi-squared test. Default is 0.05.
Details
The function calculates observed transition counts from the input sequences, computes expected transition counts based on row and column sums, and performs a chi-squared test to compare observed and expected counts. The test determines if the transitions in the sequences differ significantly from what would be expected by chance.