plot_cohen function

Constructs a serial dependence plot based on Cohen's kappa

Constructs a serial dependence plot based on Cohen's kappa

plot_cohen constructs a serial dependence plot of a categorical time series based on Cohen's kappa UTF-8

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 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.
  • 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 plot = TRUE (default), returns the serial dependence plot. Otherwise, returns a list with the values of Cohens's kappa, the critical value and the corresponding p-values.
  • title: The title of the graph.
  • bar_width: The width of the corresponding bars.
  • ...: Additional parameters for the function.

Returns

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.

Details

Constructs a serial dependence plot based on Cohens's kappa, κ^(l)\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):

TV(p^)(κ^(l)+1T)N(0,1), \sqrt{\frac{T}{V(\widehat{\boldsymbol p})}}\bigg(\widehat{\kappa}(l)+\frac{1}{T}\bigg)\sim N\big(0, 1\big),

where TT is the series length, p^=(p^1,,p^r)\widehat{\boldsymbol p}=(\widehat{p}_1, \ldots, \widehat{p}_r) is the vector of estimated marginal probabilities for the rr categories of the series and V(p^)=11+2i=1rp^i33i=1rp^i2(1i=1rp^i2)2V(\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}.

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

References

Rdpack::insert_ref(key="weiss2011empirical",package="ctsfeatures")

Author(s)

Ángel López-Oriona, José A. Vilar

  • Maintainer: Angel Lopez-Oriona
  • License: GPL-2
  • Last published: 2024-01-29

Useful links