Load library

library(tidyverse)
library(ggpubr)
library(funtimes)

Make a random number generated time series dataset

n <- 100
Time <- c(1:n)
X0 <- arima.sim(list(order = c(1, 0, 0), ar = 0.5), n = n, n.start = 100, sd = 0.5)
X1 <- 2*Time/n + X0
X2 <- 2*(Time/n)^0.5 + X0
X3 <- 0.5*(Time - n/2)/n - 6*((Time - n/2)/n)^2 + X0
data <- as.data.frame(cbind(Time, X0, X1, X2, X3))

Check time series plots for all variables

A<-ggplot(data, aes(x=Time, y=X0))+
  geom_line()

B<-ggplot(data, aes(x=Time, y=X1))+
  geom_line()

C<-ggplot(data, aes(x=Time, y=X2))+
  geom_line()

D<-ggplot(data, aes(x=Time, y=X3))+
  geom_line()

ggarrange(A,B,C,D, ncol=2, nrow=2,  labels=c("A", "B", "C", "D"))

Test for trend

Consider the following pair of hypotheses H0: no trend H1: linear trend that can be tested specifically using t-test.

Assuming the time series may be autocorrelated (which is the usual case with observational data), we apply sieve-bootstrap version of the t-test, by adapting the approach of Noguchi, Gel, and Duguay (2011):

notrend_test(X1) # example for X1
## 
##  Sieve-bootstrap Student's t-test for a linear trend
## 
## data:  X1
## Student's t value = 15.863, p-value < 2.2e-16
## alternative hypothesis: linear trend.
## sample estimates:
## $AR_order
## [1] 5
## 
## $AR_coefficients
##        phi_1        phi_2        phi_3        phi_4        phi_5 
##  0.427182789 -0.025532953  0.003522437  0.032889595  0.158651135