From 45e400651dca7b3c5d52b88a396e1282b93657c0 Mon Sep 17 00:00:00 2001 From: "J. Derek Tucker" Date: Fri, 17 Nov 2023 21:05:11 -0700 Subject: [PATCH] fixes from R CMD Check --- R/BBridge.R | 4 +- R/LongRunCovMatrix.R | 9 +---- R/elastic_changepoint.R | 84 ++++++++++++++++++++--------------------- man/LongRunCovMatrix.Rd | 6 +-- 4 files changed, 46 insertions(+), 57 deletions(-) diff --git a/R/BBridge.R b/R/BBridge.R index ed6cfc5..ef54ec8 100644 --- a/R/BBridge.R +++ b/R/BBridge.R @@ -2,8 +2,8 @@ BBridge <- function(x=0, y=0, t0=0, T=1, N=100){ if(T<= t0) stop("wrong times") dt <- (T-t0)/N t <- seq(t0, T, length=N+1) - X <- c(0,cumsum( rnorm(N)*sqrt(dt))) + X <- c(0,cumsum(stats::rnorm(N)*sqrt(dt))) BB <- x + X - (t-t0)/(T-t0)*(X[N+1]-y+x) - X <- ts(BB, start=t0,deltat=dt) + X <- stats::ts(BB, start=t0,deltat=dt) return(invisible(X)) } diff --git a/R/LongRunCovMatrix.R b/R/LongRunCovMatrix.R index 8928770..6745bd6 100644 --- a/R/LongRunCovMatrix.R +++ b/R/LongRunCovMatrix.R @@ -8,14 +8,7 @@ #' @param kern_type Kernel function to be used for the estimation of the long run covariance #' matrix. The choices are \code{c("BT", "PR", "SP", "FT")} which are respectively, bartlett, parzen, simple and flat-top kernels. #' By default the function uses a \code{"barlett"} kernel. -#' @param ... Further arguments to pass -#' -#' @return -#'\item{\code{}}{ -#' Estimated long run covariance matrix. -#'} -#' - +#' @return Returns long run covariance matrix # this is for the computation of Long Run Variance of \Theta LongRunCovMatrix <- function(mdobj, h=0, kern_type = "bartlett"){ diff --git a/R/elastic_changepoint.R b/R/elastic_changepoint.R index 85307fc..f1f7fff 100644 --- a/R/elastic_changepoint.R +++ b/R/elastic_changepoint.R @@ -98,29 +98,29 @@ elastic_amp_change_ff <- function(f, time, d = 1000, h = 0, smooth_data=FALSE, s # Plot if (showplot == TRUE) { - par(mfrow = c(1, 3)) - matplot(f, type = "l", col = "grey", main = "Functional Data", ylab = "values") + graphics::par(mfrow = c(1, 3)) + graphics::matplot(f, type = "l", col = "grey", main = "Functional Data", ylab = "values") for (i in 1:ncol(dat.a)) { - lines(dat.a[, i], col = "pink") + graphics::lines(dat.a[, i], col = "pink") } for (i in 1:ncol(dat.b)) { - lines(dat.b[, i], col = "lightblue") + graphics::lines(dat.b[, i], col = "lightblue") } - lines(mean.b, col = "blue") - lines(mean.a, col = "red") - legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) - plot(delta, type = "l", main = "Estimated Change Function", ylab = "values") + graphics::lines(mean.b, col = "blue") + graphics::lines(mean.a, col = "red") + graphics::legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) + graphics::plot(delta, type = "l", main = "Estimated Change Function", ylab = "values") - matplot(out$warping_functions, type = "l", col = "grey", main = "Warping Functions", ylab = "values") + graphics::matplot(out$warping_functions, type = "l", col = "grey", main = "Warping Functions", ylab = "values") for (i in 1:ncol(warp.b)) { - lines(warp.b[, i], col = "pink") + graphics::lines(warp.b[, i], col = "pink") } for (i in 1:ncol(warp.a)) { - lines(warp.a[, i], col = "lightblue") + graphics::lines(warp.a[, i], col = "lightblue") } - lines(warp_mean_a, col = "blue") - lines(warp_mean_b, col = "red") - legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) + graphics::lines(warp_mean_a, col = "blue") + graphics::lines(warp_mean_b, col = "red") + graphics::legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) } out <- list( @@ -239,29 +239,29 @@ elastic_ph_change_ff <- function(f, time, d = 1000, h = 0, smooth_data=FALSE, sp # Plot delta <- mean.a - mean.b if (showplot == TRUE) { - par(mfrow = c(1, 3)) - matplot(f, type = "l", col = "grey", main = "Functional Data", ylab = "values") + graphics::par(mfrow = c(1, 3)) + graphics::matplot(f, type = "l", col = "grey", main = "Functional Data", ylab = "values") for (i in 1:ncol(dat.a)) { - lines(dat.a[, i], col = "pink") + graphics::lines(dat.a[, i], col = "pink") } for (i in 1:ncol(dat.b)) { - lines(dat.b[, i], col = "lightblue") + graphics::lines(dat.b[, i], col = "lightblue") } - lines(mean.b, col = "blue") - lines(mean.a, col = "red") - legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) - plot(delta, type = "l", main = "Estimated Change Function", ylab = "values") + graphics::lines(mean.b, col = "blue") + graphics::lines(mean.a, col = "red") + graphics::legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) + graphics::plot(delta, type = "l", main = "Estimated Change Function", ylab = "values") - matplot(out$warping_functions, type = "l", col = "grey", main = "Warping Functions", ylab = "values") + graphics::matplot(out$warping_functions, type = "l", col = "grey", main = "Warping Functions", ylab = "values") for (i in 1:ncol(warp.b)) { - lines(warp.b[, i], col = "pink") + graphics::lines(warp.b[, i], col = "pink") } for (i in 1:ncol(warp.a)) { - lines(warp.a[, i], col = "lightblue") + graphics::lines(warp.a[, i], col = "lightblue") } - lines(warp_mean_a, col = "blue") - lines(warp_mean_b, col = "red") - legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) + graphics::lines(warp_mean_a, col = "blue") + graphics::lines(warp_mean_b, col = "red") + graphics::legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) } out <- list( @@ -377,30 +377,30 @@ elastic_change_fpca <- function(f, time, pca.method = "combined", pc = 0.95, d = # Plot delta <- mean.a - mean.b if (showplot == TRUE) { - par(mfrow = c(1, 3)) - matplot(f, type = "l", col = "grey", main = "Functional Data", ylab = "values") + graphics::par(mfrow = c(1, 3)) + graphics::matplot(f, type = "l", col = "grey", main = "Functional Data", ylab = "values") for (i in 1:ncol(dat.b)) { - lines(dat.b[, i], col = "pink") + graphics::lines(dat.b[, i], col = "pink") } for (i in 1:ncol(dat.a)) { - lines(dat.a[, i], col = "lightblue") + graphics::lines(dat.a[, i], col = "lightblue") } - lines(mean.a, col = "blue") - lines(mean.b, col = "red") - legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) + graphics::lines(mean.a, col = "blue") + graphics::lines(mean.b, col = "red") + graphics::legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) - plot(delta, type = "l", main = "Estimated Change Function", ylab = "values") + graphics::plot(delta, type = "l", main = "Estimated Change Function", ylab = "values") - matplot(out$warping_functions, type = "l", col = "grey", main = "Warping Functions", ylab = "values") + graphics::matplot(out$warping_functions, type = "l", col = "grey", main = "Warping Functions", ylab = "values") for (i in 1:ncol(warp.b)) { - lines(warp.b[, i], col = "pink") + graphics::lines(warp.b[, i], col = "pink") } for (i in 1:ncol(warp.a)) { - lines(warp.a[, i], col = "lightblue") + graphics::lines(warp.a[, i], col = "lightblue") } - lines(warp_mean_a, col = "blue") - lines(warp_mean_b, col = "red") - legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) + graphics::lines(warp_mean_a, col = "blue") + graphics::lines(warp_mean_b, col = "red") + graphics::legend("topleft", c("before", "after"), col = c("blue", "red"), lty = c(1, 1), cex = 0.5) } out <- list( diff --git a/man/LongRunCovMatrix.Rd b/man/LongRunCovMatrix.Rd index 9403043..acb0322 100644 --- a/man/LongRunCovMatrix.Rd +++ b/man/LongRunCovMatrix.Rd @@ -15,13 +15,9 @@ to estimating covariance matrix assuming iid data.} \item{kern_type}{Kernel function to be used for the estimation of the long run covariance matrix. The choices are \code{c("BT", "PR", "SP", "FT")} which are respectively, bartlett, parzen, simple and flat-top kernels. By default the function uses a \code{"barlett"} kernel.} - -\item{...}{Further arguments to pass} } \value{ -\item{\code{}}{ -Estimated long run covariance matrix. -} +Returns long run covariance matrix } \description{ This function estimates the long run covariance matrix of a given multivariate data sample.