diff --git a/R/smoothness.R b/R/smoothness.R index b45202b5f..28c2f4a0e 100644 --- a/R/smoothness.R +++ b/R/smoothness.R @@ -1,4 +1,10 @@ -#' Quantify the smoothness of a vector +#' Series smoothness +#' +#' Functions to quantify the smoothness of a vector, which can be used in some cases +#' as an index of "linearity". A smooth series is one that does not have abrupt changes in +#' its values. The smoothness of a series can be measured in different ways, such +#' as the standard deviation of the standardized differences or the lag-one +#' autocorrelation. #' #' @param x Numeric vector (similar to a time series). #' @param method Can be `"diff"` (the standard deviation of the standardized @@ -12,6 +18,13 @@ #' plot(x) #' smoothness(x, method = "cor") #' smoothness(x, method = "diff") +#' +#' # A boootstrapped value can also be computed +#' smoothness(x, iterations = 100) +#' +#' # When perfectly linear, the "smoothness" is 1 +#' smoothness(1:10) +#' #' @return Value of smoothness. #' @references https://stats.stackexchange.com/questions/24607/how-to-measure-smoothness-of-a-time-series-in-r #' diff --git a/man/smoothness.Rd b/man/smoothness.Rd index f2e1d2662..5b93db2b5 100644 --- a/man/smoothness.Rd +++ b/man/smoothness.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/smoothness.R \name{smoothness} \alias{smoothness} -\title{Quantify the smoothness of a vector} +\title{Series smoothness} \usage{ smoothness(x, method = "cor", lag = 1, iterations = NULL, ...) } @@ -24,13 +24,24 @@ errors. If \code{NULL} (default), parametric standard errors are computed.} Value of smoothness. } \description{ -Quantify the smoothness of a vector +Functions to quantify the smoothness of a vector, which can be used in some cases +as an index of "linearity". A smooth series is one that does not have abrupt changes in +its values. The smoothness of a series can be measured in different ways, such +as the standard deviation of the standardized differences or the lag-one +autocorrelation. } \examples{ x <- (-10:10)^3 + rnorm(21, 0, 100) plot(x) smoothness(x, method = "cor") smoothness(x, method = "diff") + +# A boootstrapped value can also be computed +smoothness(x, iterations = 100) + +# When perfectly linear, the "smoothness" is 1 +smoothness(1:10) + } \references{ https://stats.stackexchange.com/questions/24607/how-to-measure-smoothness-of-a-time-series-in-r