plot_cramer function

Constructs a serial dependence plot based on Cramer's vi

Constructs a serial dependence plot based on Cramer's vi

plot_cramer constructs a serial dependence plot of a categorical time series based on Cramer's vi UTF-8

plot_cramer( 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 Cramer's vi, 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 Cramer's vi. Otherwise, the function returns a list with the values of Cramer's vi, the critical value and the corresponding p-values.

Details

Constructs a serial dependence plot based on Cramer's vi, v^(l)\widehat{v}(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):

T(r1)v^(l)2χ(r1)22, T(r-1)\widehat{v}(l)^2 \sim\chi^2_{(r-1)^2},

where TT is the series length and rr is the number of categories in the time series.

Examples

sequence_1 <- SyntheticData1[which(SyntheticData1$Series==1),] plot_cv <- plot_cramer(series = sequence_1, max_lag = 3) # Representing # the serial dependence plot list_cv <- plot_cramer(series = sequence_1, max_lag = 3, plot = FALSE) # Obtaining # the values of Cramer's vi, the critical value and the p-values

References

Rdpack::insert_ref(key="weiss2013serial",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