Skip to content

Commit 9422300

Browse files
committed
remove depencence on Kendall package
1 parent 266ee47 commit 9422300

File tree

8 files changed

+37
-7
lines changed

8 files changed

+37
-7
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: funtimes
22
Type: Package
33
Title: Functions for Time Series Analysis
4-
Version: 9.2
5-
Date: 2023-04-28
4+
Version: 10.0
5+
Date: 2025-12-05
66
Authors@R: c(person("Vyacheslav", "Lyubchich",
77
role = c("aut", "cre"),
88
comment = c(ORCID = "0000-0001-7936-4285"),
@@ -19,7 +19,7 @@ Authors@R: c(person("Vyacheslav", "Lyubchich",
1919
person("Xingyu", "Wang", role = "ctb"))
2020
Depends: R (>= 3.5.0)
2121
License: GPL (>= 2)
22-
Imports: dbscan, Kendall, lmtest, mlVAR, parallel, Rdpack, sandwich, vars
22+
Imports: dbscan, lmtest, mlVAR, parallel, Rdpack, sandwich, vars
2323
Suggests: covid19us, Ecdat, ggplot2, gridExtra, knitr, patchwork, randomcoloR, readxl, reshape2, rmarkdown
2424
Description: Nonparametric estimators and tests for time series analysis. The functions use bootstrap techniques and robust nonparametric difference-based estimators to test for the presence of possibly non-monotonic trends and for synchronicity of trends in multiple time series.
2525
RdMacros: Rdpack

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export(sync_test)
2626
export(tails_i)
2727
export(tails_q)
2828
export(wavk_test)
29-
importFrom(Kendall,MannKendall)
3029
importFrom(Rdpack,reprompt)
3130
importFrom(dbscan,dbscan)
3231
importFrom(grDevices,adjustcolor)

R/fun_cusum.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# - Mfun(): Computes M(k1,...,km) statistic from p. 553
99
# - M1fun(): Optimized version for at most one changepoint
1010
# - MTfun(): Computes MT statistic from p. 554 or first equation on p. 568
11+
# - mann_kendall_tau(): Computes Kendall's tau for trend detection
1112
#
1213
# @keywords internal
1314
# @noRd

R/fun_trend.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Internal Helper Functions for Trend Testing and Estimation
2+
#
3+
# This file contains internal (non-exported) helper functions for trend testing
4+
# and estimation methods. These functions are used by notrend_test(), wavk_test(),
5+
# sync_test(), and related trend analysis methods.
6+
#
7+
# Functions:
8+
# - mann_kendall_tau(): Computes Kendall's tau for Mann-Kendall trend test
9+
#
10+
# @keywords internal
11+
# @noRd
12+
13+
14+
##### Mann-Kendall Trend Test Statistic #####
15+
# Internal implementation to replace Kendall::MannKendall() dependency
16+
# Computes Kendall's tau correlation between time series and time index
17+
#
18+
# @param x numeric vector (time series)
19+
# @return numeric scalar, Kendall's tau (from -1 to 1)
20+
mann_kendall_tau <- function(x) {
21+
if (length(x) < 2) stop("The time series must have at least 2 observations")
22+
23+
# Use base R's C-optimized cor() function
24+
# Comparing 'x' against 'seq_along(x)' (time) is equivalent to Mann-Kendall
25+
stats::cor(x, seq_along(x), method = "kendall")
26+
}

R/funtimes.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#' \insertAllCited{}
3333
#'
3434
#' @importFrom dbscan dbscan
35-
#' @importFrom Kendall MannKendall
3635
#' @importFrom Rdpack reprompt
3736
#' @importFrom stats acf ar arima arima0 arima.sim as.formula cov dist embed filter IQR lm loess median na.omit pnorm qnorm quantile rnorm sd var
3837
#' @importFrom utils combn

R/notrend_test.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ notrend_test <- function(x, B = 1000, test = c("t", "MK", "WAVK"),
182182
if (test == "MK") {
183183
METHOD <- "Sieve-bootstrap Mann--Kendall's trend test"
184184
ALTERNATIVE <- "monotonic trend."
185-
STATISTIC <- MannKendall(x)$tau
185+
STATISTIC <- mann_kendall_tau(x)
186186
names(STATISTIC) <- "Mann--Kendall's tau"
187-
boot.stat <- sapply(1:dim(Y)[2], function(i) MannKendall(Y[,i])$tau)
187+
boot.stat <- sapply(1:dim(Y)[2], function(i) mann_kendall_tau(Y[,i]))
188188
}
189189
#If WAVK test is used
190190
if (test == "WAVK") {

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ library(funtimes)
2222

2323
## Current GitHub version
2424

25+
## CRAN version 10.0
26+
2527
- Added new function `r_crit()` to compute critical values of correlations.
2628
- In the function `causality_pred()`, added option to turn off automatic lag selection.
29+
- Removed defunct functions.
30+
- Removed dependence on the package `Kendall` by adding an internal helper function.
2731

2832
## CRAN version 9.1
2933

funtimes.Rproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ BuildType: Package
1818
PackageUseDevtools: Yes
1919
PackageInstallArgs: --no-multiarch --with-keep.source
2020
PackageBuildBinaryArgs: --html
21+
PackageCheckArgs: --as-cran
2122
PackageRoxygenize: rd,collate,namespace,vignette

0 commit comments

Comments
 (0)