plot_cohen {ctsfeatures} | R Documentation |
Constructs a serial dependence plot based on Cohen's kappa
Description
plot_cohen
constructs a serial dependence plot of a categorical
time series based on Cohen's kappa
Usage
plot_cohen(
series,
max_lag = 10,
alpha = 0.05,
plot = TRUE,
title = "Serial dependence plot",
bar_width = 0.12,
...
)
Arguments
series |
An object of type |
max_lag |
The maximum lag represented in the plot (default is 10). |
alpha |
The significance level for the corresponding hypothesis test (default is 0.05). |
plot |
Logical. If |
title |
The title of the graph. |
bar_width |
The width of the corresponding bars. |
... |
Additional parameters for the function. |
Details
Constructs a serial dependence plot based on Cohens's kappa, \widehat{\kappa}(l)
,
for several lags. A dashed lined is incorporated indicating the critical value
of the test based on the following asymptotic approximation (under the i.i.d. assumption):
\sqrt{\frac{T}{V(\widehat{\boldsymbol p})}}\bigg(\widehat{\kappa}(l)+\frac{1}{T}\bigg)\sim N\big(0, 1\big),
where T
is the series length,
\widehat{\boldsymbol p}=(\widehat{p}_1, \ldots, \widehat{p}_r)
is the vector of estimated marginal probabilities for the r
categories of
the series and V(\boldsymbol {\widehat{p}})=1-\frac{1+2\sum_{i=1}^{r}\widehat{p}_i^3-3\sum_{i=1}^{r}\widehat{p}_i^2}{(1-\sum_{i=1}^{r}\widehat{p}_i^2)^2}
.
Value
If plot = TRUE
(default), returns the serial dependence plot based on Cohens's kappa. Otherwise, the function
returns a list with the values of Cohens's kappa, the critical
value and the corresponding p-values.
Author(s)
Ángel López-Oriona, José A. Vilar
References
Weiß CH (2011). “Empirical measures of signed serial dependence in categorical time series.” Journal of Statistical Computation and Simulation, 81(4), 411–429.
Examples
sequence_1 <- GeneticSequences[which(GeneticSequences$Series==1),]
plot_ck <- plot_cohen(series = sequence_1, max_lag = 3) # Representing
# the serial dependence plot
list_ck <- plot_cohen(series = sequence_1, max_lag = 3, plot = FALSE) # Obtaining
# the values of Cohens's kappa, the critical value and the p-values