Computational Provenance & Reproducibility Record

RAISINS - R and AI Solutions for INferential Statistics · Online Statistical Analysis Platform for Agricultural Research

Computational Provenance & Reproducibility Record Growth Rate Estimation and Trend Analysis · 1.0.0 · DOI 10.5281/zenodo.24035722

Computational Provenance & Reproducibility Record

RAISINS · Growth Rate Estimation and Trend Analysis Module

This Computational Provenance Record documents the statistical computing environment, software dependencies, computational provenance, and bibliographic references associated with the RAISINS Growth Rate Estimation and Trend Analysis module. It is intended to support computational reproducibility and software transparency. Detailed statistical methodology, mathematical derivations, and user guidance are provided separately in the official module documentation.

Any issues or updates required please comment here

Go to the App from here

1 Module Metadata

Parameter Specification
Module Growth Rate Estimation and Trend Analysis
Module Version 1.0.0
DOI 10.5281/zenodo.24035722
Document Type Computational workflow
Statistical Engine R
R Version 4.5.2
Reproducibility Execution Environment: Posit Connect · GCR · renv-locked

2 Statistical Dependency Manifest

Package Version Repository Core Statistical Functions
stats 4.5.2 Base R lm(), confint(), logLik(), residuals(), fitted(), cor(), cor.test(), pnorm(), qnorm(), median(), aggregate()

All growth, trend, instability and decomposition results are computed with base R. No additional statistical package is used.

3 Statistical Function Registry

Analytical Role Primary Function(s)
Compound growth rate (CGR), confidence interval and p-value stats::lm(log(y) ~ t), stats::confint(), summary()
Compound annual growth rate (CAGR) Closed-form formula on the first and last observed values
Average annual growth rate (AAGR) Closed-form formula on adjacent-year changes
Trend models stats::lm(y ~ t), stats::lm(y ~ t + I(t^2)), stats::lm(y ~ t + I(t^2) + I(t^3)), stats::lm(log(y) ~ t)
Trend model selection AICc from stats::logLik(); R-squared on the original scale
Mann-Kendall trend test Closed-form S, tie-corrected variance and Z; stats::pnorm(); stats::cor.test(method = "kendall", exact = TRUE) for small samples without ties
Sen’s slope and confidence interval stats::median() of pairwise slopes; rank limits from stats::qnorm()
Coefficient of variation and Cuddy-Della Valle Index stats::sd(), summary(stats::lm(y ~ t))$adj.r.squared
Area-yield decomposition Closed-form formula on the first and last years
Change point Pettitt statistic and approximate p-value (closed form)

4 Default Methods & Parameters

Analysis Default Method / Value
Compound growth rate Log-linear trend on year; CGR = 100 (exp(b) − 1) % per year, with t-test and confidence interval. Level of significance α = 0.05 (selectable: 0.01, 0.10)
CAGR 100 ((ylast / yfirst)1/t − 1), with t = last year − first year
AAGR Mean of the percentage changes between consecutive years
Trend fitting Linear, quadratic, cubic and exponential models; lowest AICc selected; AICc and R-squared compared on the original scale
Mann-Kendall test Tie-corrected variance and continuity-corrected Z; exact p-value with fewer than 10 years and no ties, otherwise two-sided normal approximation
Sen's slope Median of all pairwise slopes, with a rank-based confidence interval
Instability Coefficient of variation and Cuddy-Della Valle Index, CDVI = CV √(1 − adjusted R2), from a linear trend
Area-yield decomposition Area, yield and interaction effects between the first and last years
Change point Pettitt test with its approximate p-value
Innovative trend analysis Sorted first half of the years against the sorted last half

5 R Code for Key Analytical Steps

The code below shows the principal calculations so that reviewers can verify reported results. Set year and y to one series in time order, with consecutive years and no missing values.

5.1 Growth Rates

alpha <- 0.05
n <- length(y)
t <- year - min(year)
fit <- lm(log(y) ~ t)

cgr    <- 100 * expm1(coef(fit)[["t"]])
cgr_ci <- 100 * expm1(confint(fit, "t", level = 1 - alpha))
cgr_p  <- summary(fit)$coefficients["t", "Pr(>|t|)"]

cagr <- 100 * ((y[n] / y[1])^(1 / (year[n] - year[1])) - 1)
aagr <- 100 * mean(diff(y) / head(y, -1))

5.2 Trend Fitting

models <- list(Linear      = lm(y ~ t),
               Quadratic   = lm(y ~ t + I(t^2)),
               Cubic       = lm(y ~ t + I(t^2) + I(t^3)),
               Exponential = lm(log(y) ~ t))

trend <- do.call(rbind, lapply(names(models), function(name) {
  m  <- models[[name]]
  ll <- logLik(m); k <- attr(ll, "df")
  aic <- -2 * as.numeric(ll) + 2 * k
  mean_fit <- fitted(m)
  if (name == "Exponential") {
    aic <- aic + 2 * sum(log(y))
    mean_fit <- exp(mean_fit + mean(residuals(m)^2) / 2)
  }
  data.frame(Model = name,
             AICc  = aic + 2 * k * (k + 1) / (n - k - 1),
             R2    = 1 - sum((y - mean_fit)^2) / sum((y - mean(y))^2))
}))

5.3 Mann-Kendall Test and Sen’s Slope

S <- sum(sapply(1:(n - 1), function(i) sum(sign(y[(i + 1):n] - y[i]))))
ties <- as.numeric(table(y))
varS <- (n * (n - 1) * (2 * n + 5) - sum(ties * (ties - 1) * (2 * ties + 5))) / 18
Z <- (S - sign(S)) / sqrt(varS)
p <- 2 * pnorm(-abs(Z))

pairs  <- combn(n, 2)
slopes <- sort((y[pairs[2, ]] - y[pairs[1, ]]) / (year[pairs[2, ]] - year[pairs[1, ]]))
sen <- median(slopes)
C <- qnorm(1 - alpha / 2) * sqrt(varS)
sen_ci <- slopes[c(ceiling((length(slopes) - C) / 2), floor((length(slopes) + C) / 2) + 1)]

5.4 Instability

cv    <- 100 * sd(y) / mean(y)
r2adj <- summary(lm(y ~ t))$adj.r.squared
cdvi  <- cv * sqrt(1 - max(min(r2adj, 1), 0))

5.5 Area-Yield Decomposition

# area and production: first and last years
yield <- production / area
effects <- c(Area        = yield[1] * diff(area),
             Yield       = area[1] * diff(yield),
             Interaction = diff(area) * diff(yield),
             Total       = diff(production))

5.6 Change Point

U <- sapply(1:(n - 1), function(k) sum(sign(outer(y[1:k], y[(k + 1):n], function(a, b) b - a))))
K <- max(abs(U))
change_after <- year[which.max(abs(U))]
pettitt_p <- min(1, 2 * exp(-6 * K^2 / (n^3 + n^2)))

Explore the entire Growth Rate Estimation and Trend Analysis module in preview mode using our demo datasets. To submit suggestions or report a workflow issue, please use the discussion section below, or visit the official RAISINS website.

6 RAISINS Native Statistical Framework

RAISINS uses R for all its statistical computations. Principal statistical functions are listed with illustrative examples. Exact reproduction also requires the release source, input data, analysis settings and runtime environment. These results are then organized and formatted on the RAISINS website along with visualisation to make them easier to use and interpret. RAISINS also has its own custom-built statistical tools for managing workflows, validating results, and generating reports. Details of these are not fully covered here, they’re shared with outside researchers only on request, and are subject to licensing terms.

7 Package References

R Core Team. (2025). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/

Cuddy, J. D. A., & Della Valle, P. A. (1978). Measuring the instability of time series data. Oxford Bulletin of Economics and Statistics, 40(1), 79–85. https://doi.org/10.1111/j.1468-0084.1978.mp40001006.x

Gilbert, R. O. (1987). Statistical Methods for Environmental Pollution Monitoring. Van Nostrand Reinhold.

Hurvich, C. M., & Tsai, C.-L. (1989). Regression and time series model selection in small samples. Biometrika, 76(2), 297–307. https://doi.org/10.1093/biomet/76.2.297

Kendall, M. G. (1975). Rank Correlation Methods (4th ed.). Charles Griffin.

Mann, H. B. (1945). Nonparametric tests against trend. Econometrica, 13(3), 245–259. https://doi.org/10.2307/1907187

Pettitt, A. N. (1979). A non-parametric approach to the change-point problem. Journal of the Royal Statistical Society: Series C (Applied Statistics), 28(2), 126–135. https://doi.org/10.2307/2346729

Sen, P. K. (1968). Estimates of the regression coefficient based on Kendall’s tau. Journal of the American Statistical Association, 63(324), 1379–1389. https://doi.org/10.1080/01621459.1968.10480934

Şen, Z. (2012). Innovative trend analysis methodology. Journal of Hydrologic Engineering, 17(9), 1042–1046. https://doi.org/10.1061/(ASCE)HE.1943-5584.0000556

Feedback & Discussion