Title: | Ordinal Time Series Analysis |
---|---|
Description: | An implementation of several functions for feature extraction in ordinal time series datasets. Specifically, some of the features proposed by Weiss (2019) <doi:10.1080/01621459.2019.1604370> can be computed. These features can be used to perform inferential tasks or to feed machine learning algorithms for ordinal time series, among others. The package also includes some interesting datasets containing financial time series. Practitioners from a broad variety of fields could benefit from the general framework provided by 'otsfeatures'. |
Authors: | Angel Lopez-Oriona [aut, cre], Jose A. Vilar [aut] |
Maintainer: | Angel Lopez-Oriona <[email protected]> |
License: | GPL-2 |
Version: | 1.0.0 |
Built: | 2025-01-21 03:39:53 UTC |
Source: | https://github.com/cran/otsfeatures |
Ordinal time series (OTS) of yearly categories of salaries for different Austrian employees
data(AustrianWages)
data(AustrianWages)
A list
with one element, which is:
data
A list with 9402 MTS.
Each element in data
is an ordinal time series
containing 6 states (yearly categorized wages). 9402 Austrian workers
considered. The series exhibit individual lengths ranging from 2 to 32 years with the median length being equal to 22.
For more information, see López-Oriona et al. (2023).
López-Oriona Á, Weiß C, Vilar JA (2023). “Fuzzy clustering of ordinal time series based on two novel distances with financial applications.” Manuscript submitted for publication, 000-000.
binarization
constructs the binarized time series associated with a given
ordinal time series.
binarization(series, states)
binarization(series, states)
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function
constructs the binarized time series, which is defined as
,
with
such that
if
(
). The binarized series is constructed in the form of a matrix
whose rows represent time observations and whose columns represent the
states in the original series.
The binarized time series.
Ángel López-Oriona, José A. Vilar
Weiß CH (2018). An introduction to discrete-valued time series. John Wiley and Sons. López-Oriona Á, Vilar JA, D’Urso P (2023). “Hard and soft clustering of categorical time series based on two novel distances with an application to biological sequences.” Information Sciences, 624, 467–492.
binarized_series <- binarization(AustrianWages$data[[100]], states = 0 : 5) # Constructing the binarized # time series for one OTS in dataset AustrianWages
binarized_series <- binarization(AustrianWages$data[[100]], states = 0 : 5) # Constructing the binarized # time series for one OTS in dataset AustrianWages
c_binarization
constructs the cumulative binarized time series associated with a given
ordinal time series.
c_binarization(series, states)
c_binarization(series, states)
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function
constructs the cumulative binarized time series, which is defined as
,
with
such that
if
(
). The cumulative binarized series is constructed in the form of a matrix
whose rows represent time observations and whose columns represent the
states in the original series.
The binarized time series.
Ángel López-Oriona, José A. Vilar
Weiß CH (2018). An introduction to discrete-valued time series. John Wiley and Sons.
López-Oriona Á, Vilar JA, D’Urso P (2023). “Hard and soft clustering of categorical time series based on two novel distances with an application to biological sequences.” Information Sciences, 624, 467–492.
c_binarized_series <- c_binarization(AustrianWages$data[[100]], states = 0 : 5) # Constructing the cumulative binarized # time series for one OTS in dataset AustrianWages
c_binarized_series <- c_binarization(AustrianWages$data[[100]], states = 0 : 5) # Constructing the cumulative binarized # time series for one OTS in dataset AustrianWages
c_conditional_probabilities
returns a matrix with the cumulative conditional
probabilities of an ordinal time series
c_conditional_probabilities(series, lag = 1, states)
c_conditional_probabilities(series, lag = 1, states)
series |
An OTS. |
lag |
The considered lag (default is 1). |
states |
A numerical vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function computes the
matrix
,
with
, where
is the number of elements less one or equal to
in the realization
and
is the number
of pairs
in the realization
such that
and
.
A matrix with the conditional probabilities.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
matrix_ccp <- c_conditional_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # cumulative conditional probabilities for one series in dataset AustrianWages
matrix_ccp <- c_conditional_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # cumulative conditional probabilities for one series in dataset AustrianWages
c_joint_probabilities
returns a matrix with the cumulative joint
probabilities of an ordinal time series
c_joint_probabilities(series, lag = 1, states)
c_joint_probabilities(series, lag = 1, states)
series |
An OTS. |
lag |
The considered lag (default is 1). |
states |
A numerical vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function computes the
matrix
,
with
, where
is the number
of pairs
in the realization
such that
and
.
A matrix with the jcumulative oint probabilities.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
matrix_cjp <- c_joint_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # cumulative joint probabilities for one series in dataset AustrianWages
matrix_cjp <- c_joint_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # cumulative joint probabilities for one series in dataset AustrianWages
c_marginal_probabilities
returns a vector with the cumulative marginal
probabilities of an ordinal time series
c_marginal_probabilities(series, states)
c_marginal_probabilities(series, states)
series |
An OTS (numerical vector with integers). |
states |
A numerical vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function computes the
vector
,
with
, where
is the number
of elements less than or equal to
in the realization
.
A vector with the cumulative marginal probabilities.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
vector_cmp <- c_marginal_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the vector of # cumulative marginal probabilities for one series in dataset AustrianWages
vector_cmp <- c_marginal_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the vector of # cumulative marginal probabilities for one series in dataset AustrianWages
ci_ordinal_asymmetry
constructs a confidence interval for the
ordinal asymmetry (block distance)
ci_ordinal_asymmetry( series, states, level = 0.95, temporal = TRUE, max_lag = 1 )
ci_ordinal_asymmetry( series, states, level = 0.95, temporal = TRUE, max_lag = 1 )
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
level |
The confidence level (default is 0.95). |
temporal |
Logical. If |
max_lag |
If |
If temporal = TRUE
(default), the function constructs the confidence interval for the
ordinal asymmetry relying on Theorem 7.1.1 in Weiß (2019). Otherwise,
the interval is constructed according to Theorem 4.1 in Weiß (2019).
The confidence interval.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
ci_asymmetry <- ci_ordinal_asymmetry(AustrianWages$data[[100]], states = 0 : 5) # Constructing a confidence interval for the # ordinal asymmetry for one OTS in dataset AustrianWages
ci_asymmetry <- ci_ordinal_asymmetry(AustrianWages$data[[100]], states = 0 : 5) # Constructing a confidence interval for the # ordinal asymmetry for one OTS in dataset AustrianWages
ci_ordinal_dispersion
constructs a confidence interval for the
ordinal dispersion (block distance)
ci_ordinal_dispersion( series, states, level = 0.95, temporal = TRUE, max_lag = 1 )
ci_ordinal_dispersion( series, states, level = 0.95, temporal = TRUE, max_lag = 1 )
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
level |
The confidence level (default is 0.95). |
temporal |
Logical. If |
max_lag |
If |
If temporal = TRUE
(default), the function constructs the confidence interval for the
ordinal dispersion relying on Theorem 7.1.1 in Weiß (2019). Otherwise,
the interval is constructed according to Theorem 4.1 in Weiß (2019).
The confidence interval.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
ci_dispersion <- ci_ordinal_dispersion(AustrianWages$data[[100]], states = 0 : 5) # Constructing a confidence interval for the # ordinal dispersion for one OTS in dataset AustrianWages
ci_dispersion <- ci_ordinal_dispersion(AustrianWages$data[[100]], states = 0 : 5) # Constructing a confidence interval for the # ordinal dispersion for one OTS in dataset AustrianWages
ci_ordinal_skewness
constructs a confidence interval for the
ordinal skewness (block distance)
ci_ordinal_skewness(series, states, level = 0.95, temporal = TRUE, max_lag = 1)
ci_ordinal_skewness(series, states, level = 0.95, temporal = TRUE, max_lag = 1)
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
level |
The confidence level (default is 0.95). |
temporal |
Logical. If |
max_lag |
If |
If temporal = TRUE
(default), the function constructs the confidence interval for the
ordinal skewness relying on Theorem 7.1.1 in Weiß (2019). Otherwise,
the interval is constructed according to Theorem 4.1 in Weiß (2019).
The confidence interval.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
ci_skewness <- ci_ordinal_skewness(AustrianWages$data[[100]], states = 0 : 5) # Constructing a confidence interval for the # ordinal skewness for one OTS in dataset AustrianWages
ci_skewness <- ci_ordinal_skewness(AustrianWages$data[[100]], states = 0 : 5) # Constructing a confidence interval for the # ordinal skewness for one OTS in dataset AustrianWages
conditional_probabilities
returns a matrix with the conditional
probabilities of an ordinal time series
conditional_probabilities(series, lag = 1, states)
conditional_probabilities(series, lag = 1, states)
series |
An OTS. |
lag |
The considered lag (default is 1). |
states |
A numerical vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function computes the
matrix
,
with
, where
is the number of elements equal to
in the realization
and
is the number
of pairs
in the realization
.
A matrix with the conditional probabilities.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
matrix_cp <- conditional_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # conditional probabilities for one series in dataset AustrianWages
matrix_cp <- conditional_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # conditional probabilities for one series in dataset AustrianWages
Ordinal time series (OTS) of monthly credit ratings of different European countries
data(CreditRatings)
data(CreditRatings)
A list
with one element, which is:
data
A list with 28 MTS.
Each element in data
is an ordinal time series
containing 23 states (monthly credit ratings). The 28 countries of the European Union plus
the United Kingdom are considered. The sample period spans from January 2000 to December 2017, thus resulting serial realizations of length .
For more information, see Weiß (2019).
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
index_ordinal_variation
computes the estimated index of ordinal variation
of an ordinal time series
index_ordinal_variation(series, states)
index_ordinal_variation(series, states)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function computes the
estimated IOV given by
,
where
is the standard estimate of the cumulative marginal probability
for state
computed from the series
.
The estimated IOV.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_iov <- index_ordinal_variation(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the estimate of the IOV # for one series in dataset AustrianWages
estimated_iov <- index_ordinal_variation(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the estimate of the IOV # for one series in dataset AustrianWages
joint_probabilities
returns a matrix with the joint
probabilities of an ordinal time series
joint_probabilities(series, lag = 1, states)
joint_probabilities(series, lag = 1, states)
series |
An OTS. |
lag |
The considered lag (default is 1). |
states |
A numerical vector containing the corresponding states. |
Given an OTS of length with range
(
),
, the function computes the
matrix
,
with
, where
is the number
of pairs
in the realization
.
A matrix with the joint probabilities.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
matrix_jp <- joint_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # joint probabilities for one series in dataset AustrianWages
matrix_jp <- joint_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the matrix of # joint probabilities for one series in dataset AustrianWages
marginal_probabilities
returns a vector with the marginal
probabilities of an ordinal time series
marginal_probabilities(series, states)
marginal_probabilities(series, states)
series |
An OTS (numerical vector with integers). |
states |
A numerical vector containing the corresponding states |
Given an OTS of length with range
(
),
, the function computes the
vector
,
with
, where
is the number
of elements equal to
in the realization
.
A vector with the marginal probabilities.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
vector_mp <- marginal_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the vector of # marginal probabilities for one series in dataset AustrianWages
vector_mp <- marginal_probabilities(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the vector of # marginal probabilities for one series in dataset AustrianWages
ordinal_asymmetry
computes the estimated asymmetry
of an ordinal time series
ordinal_asymmetry(series, states, distance = "Block", normalize = FALSE)
ordinal_asymmetry(series, states, distance = "Block", normalize = FALSE)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
distance |
A function defining the underlying distance between states. The Hamming, block and Euclidean distances are already implemented by means of the arguments "Hamming", "Block" (default) and "Euclidean". Otherwise, a function taking as input two states must be provided. |
normalize |
Logical. If |
Given an OTS of length with range
(
),
, the function computes the
estimated asymmetry given by
,
where
,
with
being the standard estimate of the marginal probability for state
,
and
are the identity and counteridentity
matrices of order
, respectively, and
is a pairwise distance
matrix for the elements in the set
considering a specific distance
between ordinal states,
. If
normalize = TRUE
, then the normalized estimate is computed, namely
.
The estimated asymmetry.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_asymmetry <- ordinal_asymmetry(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the asymmetry estimate # for one series in dataset AustrianWages using the block distance
estimated_asymmetry <- ordinal_asymmetry(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the asymmetry estimate # for one series in dataset AustrianWages using the block distance
ordinal_cohens_kappa
computes the estimated ordinal Cohen's kappa
of an ordinal time series
ordinal_cohens_kappa(series, states, distance = "Block", lag = 1)
ordinal_cohens_kappa(series, states, distance = "Block", lag = 1)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
distance |
A function defining the underlying distance between states. The Hamming, block and Euclidean distances are already implemented by means of the arguments "Hamming", "Block" (default) and "Euclidean". Otherwise, a function taking as input two states must be provided. |
lag |
The considered lag. |
Given an OTS of length with range
(
),
, the function computes the
estimated ordinal Cohen's kappa given by
,
where
is the DIVC estimate of the dispersion, with
being a distance between ordinal states and
being the
standard estimate of the marginal probability for state
,
and
.
The estimated ordinal Cohen's kappa.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_ock <- ordinal_cohens_kappa(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the estimated ordinal Cohen's kappa # for one series in dataset AustrianWages using the block distance
estimated_ock <- ordinal_cohens_kappa(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the estimated ordinal Cohen's kappa # for one series in dataset AustrianWages using the block distance
ordinal_dispersion_1
computes the standard estimated dispersion
of an ordinal time series
ordinal_dispersion_1(series, states, distance = "Block", normalize = FALSE)
ordinal_dispersion_1(series, states, distance = "Block", normalize = FALSE)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
distance |
A function defining the underlying distance between states. The Hamming, block and Euclidean distances are already implemented by means of the arguments "Hamming", "Block" (default) and "Euclidean". Otherwise, a function taking as input two states must be provided. |
normalize |
Logical. If |
Given an OTS of length with range
(
),
, the function computes the standard
estimated dispersion given by
,
where
is the standard estimate of the location and
is a distance between ordinal states.
If
normalize = TRUE
, then the normalized dispersion is computed, namely
max
.
The standard estimated dispersion.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_dispersion <- ordinal_dispersion_1(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the standard dispersion estimate # for one series in dataset AustrianWages using the block distance
estimated_dispersion <- ordinal_dispersion_1(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the standard dispersion estimate # for one series in dataset AustrianWages using the block distance
ordinal_dispersion_2
computes the estimated dispersion
of an ordinal time series according to the approach based on the
diversity coefficient
ordinal_dispersion_2(series, states, distance = "Block", normalize = FALSE)
ordinal_dispersion_2(series, states, distance = "Block", normalize = FALSE)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
distance |
A function defining the underlying distance between states. The Hamming, block and Euclidean distances are already implemented by means of the arguments "Hamming", "Block" (default) and "Euclidean". Otherwise, a function taking as input two states must be provided. |
normalize |
Logical. If |
Given an OTS of length with range
(
),
, the function computes the DIVC
estimated dispersion given by
,
where
is a distance between ordinal states and
is the
standard estimate of the marginal probability for state
.
If
normalize = TRUE
, and distance = "Block"
or distance = "Euclidean"
, then the normalized versions are computed, that is,
the corresponding estimates are divided by the factors or
, respectively.
The estimated dispersion according to the approach based on the diversity coefficient.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_dispersion <- ordinal_dispersion_2(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the DIVC dispersion estimate # for one series in dataset AustrianWages using the block distance
estimated_dispersion <- ordinal_dispersion_2(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the DIVC dispersion estimate # for one series in dataset AustrianWages using the block distance
ordinal_location_1
computes the standard estimated location
of an ordinal time series
ordinal_location_1(series, states, distance = "Block", normalize = FALSE)
ordinal_location_1(series, states, distance = "Block", normalize = FALSE)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
distance |
A function defining the underlying distance between states. The Hamming, block and Euclidean distances are already implemented by means of the arguments "Hamming", "Block" (default) and "Euclidean". Otherwise, a function taking as input two states must be provided. |
normalize |
Logical. If |
Given an OTS of length with range
(
),
, the function computes the standard
estimated location given by
argmin
,
where
is a distance between ordinal states.
The standard estimated location.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_location <- ordinal_location_1(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the standard location estimate # for one series in dataset AustrianWages using the block distance
estimated_location <- ordinal_location_1(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the standard location estimate # for one series in dataset AustrianWages using the block distance
ordinal_location_2
computes the estimated location
of an ordinal time series with respect to the lowest category
ordinal_location_2(series, states, distance = "Block", normalize = FALSE)
ordinal_location_2(series, states, distance = "Block", normalize = FALSE)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
distance |
A function defining the underlying distance between states. The Hamming, block and Euclidean distances are already implemented by means of the arguments "Hamming", "Block" (default) and "Euclidean". Otherwise, a function taking as input two states must be provided. |
normalize |
Logical. If |
Given an OTS of length with range
(
),
, the function computes the
estimated location with respect to the lowest state, that is, the state
such that
is the closest to
is determined,
where
is a distance between ordinal states.
The estimated location with respect to the lowest category.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_location <- ordinal_location_2(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the location estimate # with respect to the lowest state for one series in dataset AustrianWages
estimated_location <- ordinal_location_2(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the location estimate # with respect to the lowest state for one series in dataset AustrianWages
ordinal_skewness
computes the estimated skewness
of an ordinal time series
ordinal_skewness(series, states, distance = "Block", normalize = FALSE)
ordinal_skewness(series, states, distance = "Block", normalize = FALSE)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
distance |
A function defining the underlying distance between states. The Hamming, block and Euclidean distances are already implemented by means of the arguments "Hamming", "Block" (default) and "Euclidean". Otherwise, a function taking as input two states must be provided. |
normalize |
Logical. If |
Given an OTS of length with range
(
),
, the function computes the
estimated skewness given by
,
where
is a distance between ordinal states and
is the standard estimate
of the marginal probability for state
computed from the realization
.
The estimated skewness.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
estimated_skewness <- ordinal_skewness(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the skewness estimate # for one series in dataset AustrianWages using the block distance
estimated_skewness <- ordinal_skewness(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the skewness estimate # for one series in dataset AustrianWages using the block distance
ots_plot
constructs an ordinal time series plot
ots_plot(series, states, title = "Time series plot", labels = NULL)
ots_plot(series, states, title = "Time series plot", labels = NULL)
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
title |
The title of the graph. |
labels |
The labels of the graph. |
Constructs an ordinal time series plot for a given OTS.
The ordinal time series plot.
Ángel López-Oriona, José A. Vilar
Weiß CH (2018). An introduction to discrete-valued time series. John Wiley and Sons.
ordinal_time_series_plot <- ots_plot(series = AustrianWages$data[[100]],, states = 0 : 5) # Constructs an ordinal # time series plot for one series in # dataset AustrianWages
ordinal_time_series_plot <- ots_plot(series = AustrianWages$data[[100]],, states = 0 : 5) # Constructs an ordinal # time series plot for one series in # dataset AustrianWages
plot_ordinal_cohens_kappa
constructs a serial dependence plot of an ordinal
time series based on the ordinal Cohen's kappa considering the block distance
plot_ordinal_cohens_kappa( series, states, max_lag = 10, alpha = 0.05, plot = TRUE, title = "Serial dependence plot", bar_width = 0.12, ... )
plot_ordinal_cohens_kappa( series, states, max_lag = 10, alpha = 0.05, plot = TRUE, title = "Serial dependence plot", bar_width = 0.12, ... )
series |
An OTS. |
states |
A numerical vector containing the corresponding states. |
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. |
Constructs a serial dependence plot based on the ordinal Cohens's kappa, ,
for several lags, where
is the block distance between ordinal states, that is,
for two states
and
.
A dashed lined is incorporated indicating the critical value
of the test based on the following asymptotic approximation (under the i.i.d. assumption):
where is the series length,
is the estimated cumulative probability for state
and
is the DIVC estimate of the dispersion.
If plot = TRUE
(default), returns the serial dependence plot based on the ordinal Cohens's kappa. Otherwise, the function
returns a list with the values of the ordinal Cohens's kappa, the critical
value and the corresponding p-values.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
plot_ock <- plot_ordinal_cohens_kappa(series = AustrianWages$data[[100]], states = 0 : 5, max_lag = 3) # Representing # the serial dependence plot list_ck <- plot_ordinal_cohens_kappa(series = AustrianWages$data[[100]], states = 0 : 5, max_lag = 3, plot = FALSE) # Obtaining # the values of the ordinal Cohens's kappa, the critical value and the p-values
plot_ock <- plot_ordinal_cohens_kappa(series = AustrianWages$data[[100]], states = 0 : 5, max_lag = 3) # Representing # the serial dependence plot list_ck <- plot_ordinal_cohens_kappa(series = AustrianWages$data[[100]], states = 0 : 5, max_lag = 3, plot = FALSE) # Obtaining # the values of the ordinal Cohens's kappa, the critical value and the p-values
Synthetic dataset containing 80 OTS generated from four different generating processes.
data(SyntheticData1)
data(SyntheticData1)
A list
with two elements, which are:
data
A list with 80 OTS.
classes
A numeric vector indicating the corresponding classes associated with the elements in data
.
Each element in data
is a 6-state OTS of length 600.
Series 1-20, 21-40, 41-60 and 61-80 were generated from
binomial AR(p) processes with different coefficients (see Scenario 1 in López-Oriona et al. (2023)).
Therefore, there are 4 different classes in the dataset.
López-Oriona Á, Weiß C, Vilar JA (2023). “Fuzzy clustering of ordinal time series based on two novel distances with financial applications.” Manuscript submitted for publication, 000-000.
Synthetic dataset containing 80 OTS generated from four different generating processes.
data(SyntheticData2)
data(SyntheticData2)
A list
with two elements, which are:
data
A list with 80 OTS.
classes
A numeric vector indicating the corresponding classes associated with the elements in data
.
Each element in data
is a 6-state OTS of length 600.
Series 1-20, 21-40, 41-60 and 61-80 were generated from
binomial INARCH(p) processes with different coefficients (see Scenario 2 in López-Oriona et al. (2023)).
Therefore, there are 4 different classes in the dataset.
López-Oriona Á, Weiß C, Vilar JA (2023). “Fuzzy clustering of ordinal time series based on two novel distances with financial applications.” Manuscript submitted for publication, 000-000.
Synthetic dataset containing 80 OTS generated from four different generating processes.
data(SyntheticData3)
data(SyntheticData3)
A list
with two elements, which are:
data
A list with 80 OTS.
classes
A numeric vector indicating the corresponding classes associated with the elements in data
.
Each element in data
is a 6-state OTS of length 600.
Series 1-20, 21-40, 41-60 and 61-80 were generated from
ordinal logit AR(1) processes with different coefficients (see Scenario 3 in López-Oriona et al. (2023)).
Therefore, there are 4 different classes in the dataset.
López-Oriona Á, Weiß C, Vilar JA (2023). “Fuzzy clustering of ordinal time series based on two novel distances with financial applications.” Manuscript submitted for publication, 000-000.
test_ordinal_asymmetry
performs the hypothesis test associated with the
ordinal asymmetry for the block distance
test_ordinal_asymmetry( series, states, true_asymmetry, alpha = 0.05, temporal = TRUE, max_lag = 1 )
test_ordinal_asymmetry( series, states, true_asymmetry, alpha = 0.05, temporal = TRUE, max_lag = 1 )
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
true_asymmetry |
The value for the true asymmetry. |
alpha |
The significance level (default is 0.05). |
temporal |
Logical. If |
max_lag |
If |
If temporal = TRUE
(default), the function performs the hypothesis test based on the
ordinal asymmetry relying on Theorem 7.1.1 in Weiß (2019). Otherwise,
the test based on Theorem 4.1 in Weiß (2019) is carried out.
The results of the hypothesis test.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
results_test <- test_ordinal_asymmetry(AustrianWages$data[[100]], states = 0 : 5, true_asymmetry = 2) # Performing the hypothesis test associated with the # ordinal asymmetry for one OTS in dataset AustrianWages
results_test <- test_ordinal_asymmetry(AustrianWages$data[[100]], states = 0 : 5, true_asymmetry = 2) # Performing the hypothesis test associated with the # ordinal asymmetry for one OTS in dataset AustrianWages
test_ordinal_dispersion
performs the hypothesis test associated with the
ordinal dispersion for the block distance
test_ordinal_dispersion( series, states, true_dispersion, alpha = 0.05, temporal = TRUE, max_lag = 1 )
test_ordinal_dispersion( series, states, true_dispersion, alpha = 0.05, temporal = TRUE, max_lag = 1 )
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
true_dispersion |
The value for the true dispersion. |
alpha |
The significance level (default is 0.05). |
temporal |
Logical. If |
max_lag |
If |
If temporal = TRUE
(default), the function performs the hypothesis test based on the
ordinal dispersion relying on Theorem 7.1.1 in Weiß (2019). Otherwise,
the test based on Theorem 4.1 in Weiß (2019) is carried out.
The results of the hypothesis test.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
results_test <- test_ordinal_dispersion(AustrianWages$data[[100]], states = 0 : 5, true_dispersion = 2) # Performing the hypothesis test associated with the # ordinal dispersion for one OTS in dataset AustrianWages
results_test <- test_ordinal_dispersion(AustrianWages$data[[100]], states = 0 : 5, true_dispersion = 2) # Performing the hypothesis test associated with the # ordinal dispersion for one OTS in dataset AustrianWages
test_ordinal_skewness
performs the hypothesis test associated with the
ordinal skewness for the block distance
test_ordinal_skewness( series, states, true_skewness, alpha = 0.05, temporal = TRUE, max_lag = 1 )
test_ordinal_skewness( series, states, true_skewness, alpha = 0.05, temporal = TRUE, max_lag = 1 )
series |
An OTS (numerical vector with integers). |
states |
A numeric vector containing the corresponding states. |
true_skewness |
The value for the true skewness. |
alpha |
The significance level (default is 0.05). |
temporal |
Logical. If |
max_lag |
If |
If temporal = TRUE
(default), the function performs the hypothesis test based on the
ordinal skewness relying on Theorem 7.1.1 in Weiß (2019). Otherwise,
the test based on Theorem 4.1 in Weiß (2019) is carried out.
The results of the hypothesis test.
Ángel López-Oriona, José A. Vilar
Weiß CH (2019). “Distance-based analysis of ordinal data and ordinal time series.” Journal of the American Statistical Association.
results_test <- test_ordinal_skewness(AustrianWages$data[[100]], states = 0 : 5, true_skewness = 2) # Performing the hypothesis test associated with the # ordinal skewness for one OTS in dataset AustrianWages
results_test <- test_ordinal_skewness(AustrianWages$data[[100]], states = 0 : 5, true_skewness = 2) # Performing the hypothesis test associated with the # ordinal skewness for one OTS in dataset AustrianWages
total_c_correlation
returns the value of the total cumulative correlation for
an ordinal time series
total_c_correlation(series, lag = 1, states, features = FALSE)
total_c_correlation(series, lag = 1, states, features = FALSE)
series |
An OTS. |
lag |
The considered lag (default is 1). |
states |
A numerical vector containing the corresponding states. |
features |
Logical. If |
Given an OTS of length with range
,
, and
the cumulative binarized time series, which is defined as
,
with
such that
if
(
), the function computes the estimated average
,
where
is the estimated correlation
,
. If
features = TRUE
, the function
returns a matrix whose components are the quantities ,
.
If features = FALSE
(default), returns the value of the total cumulative correlation. Otherwise, the function
returns a matrix of features, i.e., the matrix contains the features employed to compute the
total cumulative correlation.
Ángel López-Oriona, José A. Vilar
tcc <- total_c_correlation(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the total cumulative correlation # for one of the series in dataset AustrianWages feature_matrix <- total_c_correlation(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the corresponding matrix of features
tcc <- total_c_correlation(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the total cumulative correlation # for one of the series in dataset AustrianWages feature_matrix <- total_c_correlation(series = AustrianWages$data[[100]], states = 0 : 5) # Computing the corresponding matrix of features
total_mixed_c_correlation_1
returns the TMCLC between an ordinal and a
real-valued time series
total_mixed_c_correlation_1( o_series, n_series, lag = 1, states, features = FALSE )
total_mixed_c_correlation_1( o_series, n_series, lag = 1, states, features = FALSE )
o_series |
An OTS. |
n_series |
A real-valued time series. |
lag |
The considered lag (default is 1). |
states |
A numerical vector containing the corresponding states. |
features |
Logical. If |
Given a OTS of length with range
,
, and
the cumulative binarized time series, which is defined as
,
with
such that
if
(
), the function computes the estimated TMCLC given by
where
, with
being a
-length real-valued time series. If
features = TRUE
, the function
returns a vector whose components are the quantities ,
.
If features = FALSE
(default), returns the value of the TMCLC. Otherwise, the function
returns a vector of features, i.e., the vector contains the features employed to compute the
TMCLC.
Ángel López-Oriona, José A. Vilar
tmclc <- total_mixed_c_correlation_1(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5) # Computing the TMCLC # between the first series in dataset SyntheticData1 and white noise feature_vector <- total_mixed_c_correlation_1(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5, features = TRUE) # Computing the corresponding # vector of features
tmclc <- total_mixed_c_correlation_1(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5) # Computing the TMCLC # between the first series in dataset SyntheticData1 and white noise feature_vector <- total_mixed_c_correlation_1(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5, features = TRUE) # Computing the corresponding # vector of features
total_mixed_c_correlation_2
returns the TMCQC
between an ordinal and a real-valued time series
total_mixed_c_correlation_2( o_series, n_series, lag = 1, states, features = FALSE )
total_mixed_c_correlation_2( o_series, n_series, lag = 1, states, features = FALSE )
o_series |
An OTS. |
n_series |
A real-valued time series. |
lag |
The considered lag (default is 1). |
states |
A numerical vector containing the corresponding states. |
features |
Logical. If |
Given a OTS of length with range
,
, and
the cumulative binarized time series, which is defined as
,
with
such that
if
(
), the function computes the estimated TMCQC given by
where
, with
being a
-length real-valued time series,
a probability
level,
the indicator function and
the quantile
function of the corresponding real-valued process. If
features = TRUE
, the function
returns a vector whose components are the quantities ,
.
If features = FALSE
(default), returns the value of the TMCQC. Otherwise, the function
returns a vector of features, i.e., the vector contains the features employed to compute the
TMCLC.
Ángel López-Oriona, José A. Vilar
tmclc <- total_mixed_c_correlation_2(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5) # Computing the TMCQC # between the first series in dataset SyntheticData1 and white noise feature_vector <- total_mixed_c_correlation_2(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5, features = TRUE) # Computing the corresponding # vector of features
tmclc <- total_mixed_c_correlation_2(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5) # Computing the TMCQC # between the first series in dataset SyntheticData1 and white noise feature_vector <- total_mixed_c_correlation_2(o_series = SyntheticData1$data[[1]], n_series = rnorm(600), states = 0 : 5, features = TRUE) # Computing the corresponding # vector of features