I applied the Mann-Kendall test with autocorrelation enhancement as stated on this website: https://cran.r-project.org/web/packages/funtimes/vignettes/trendtests.html
The given code worked for a simple dataframe with a time series from 2007 to 2022. I tried the same for another dataframe. Even after creating it on my own, I get the error Error in filter(x, PHETAS[[i]], sides = 1) : missing values in 'filter'. And I honestly have no idea how to fix it.
Its from the funtimes library
Refenu_summary_byyearoC <- data.frame(
year = c(2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019),
Total_Enucleation = c(748, 762, 817, 844, 891, 940, 911, 970)
)
apply(Refenu_summary_byyearoC["Total_Enucleation"], 2, function(x) {
notrend_test(x, B = 1000, test = c("MK"),
ar.method = "HVK", ar.order = NULL,
factor.length = c("user.defined", "adaptive.selection"),
Window = NULL, q = 3/4, j = c(8:11))$p.value
})
In my opinion there is a downward trend of my data and I want to display it with a p-value using the mann-kendall test. I could just use the mann-kendall test and be happy with the p-value and tau, but I was advised to consider the bootstrap to avoid false results because of autocorrelation of my time series.