knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

rtrend

R-CMD-check codecov CRAN

Installation

You can install the released version of rtrend from CRAN with:

install.packages("rtrend")

Example

Fast Linear regression

library(rtrend)
set.seed(1)
y = rnorm(100)
# y <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69)
(r <- slope(y))
microbenchmark::microbenchmark(
  summary(lm(y~seq_along(y)))$coefficients[2, c(1, 4)],  # traditional slope and pvalue  
  r_p <- slope_p(y)  # fast linear regression
)

Fast modified MK

set.seed(1)
x <- rnorm(2e2)
microbenchmark::microbenchmark(
    mkTrend_r(x), # traditional in MK fume
    mkTrend(x)    # in Rcpp version
)
x <- c(4.81,4.17,4.41,3.59,5.87,3.83, 6.03,4.89,4.32,10,4.69)
par(mar = c(3, 3, 1, 1), mgp = c(2, 0.6, 0))
r_cpp <- mkTrend(x, IsPlot = TRUE)

Bootstrap slope

(r_boot <- slope_boot(y))

References

Kong, D., Gu, X., Li, J., Ren, G., & Liu, J. (2020). Contributions of Global Warming and Urbanization to the Intensification of Human‐Perceived Heatwaves Over China. Journal of Geophysical Research: Atmospheres, 125(18), 1–16. https://doi.org/10.1029/2019JD032175.



kongdd/rtrend documentation built on Jan. 29, 2024, 11:48 p.m.