
This repository contains R code and documentation for conducting Mann-Kendall trend analysis on seasonal climatic variables in Dar es Salaam, Tanzania. The analysis uses monthly meteorological data from the Tanzania Meteorological Authority covering a 10-year period (2014–2024) to detect and quantify monotonic trends in rainfall, temperature, and relative humidity across different seasons.
The Mann-Kendall test is a non-parametric statistical method widely used in climatology and hydrology for detecting trends in time series data. It does not require assumptions about data distribution, making it particularly suitable for environmental data analysis. This implementation includes Sen's slope estimator to quantify the magnitude and direction of detected trends.
January G. Msemakweli
Graduate Student | ScM in Epidemiology
Bloomberg School of Public Health
Johns Hopkins University
https://orcid.org/0009-0007… https://orcid.org/0009-0007…
The following R packages are required:
readr # Data import dplyr # Data manipulation Kendall # Mann-Kendall test trend # Sen's slope estimator and Pettitt test knitr # Dynamic report generation kableExtra # Enhanced table formatting ggplot2 # Data visualization tidyr # Data tidying broom # Model output tidying (for OLS analysis)
Install all required packages using:
install.packages(c("readr", "dplyr", "Kendall", "trend", "knitr", "kableExtra", "ggplot2", "tidyr", "broom"))
.
├── README.md # This file
├── MK_Test.Rmd # Main Mann-Kendall trend analysis
├── OLS_Sensitivity_Check.Rmd # OLS regression sensitivity analysis
├── CLIMATE DAR DATASET.csv # Input climate data (required)
└── [generated outputs] # PNG plots and HTML reports
The primary analysis document containing:
A sensitivity analysis using Ordinary Least Squares (OLS) regression to validate the non-parametric Mann-Kendall results:
This sensitivity check strengthens confidence in findings when both parametric and non-parametric methods agree.
The analysis requires a CSV file named CLIMATE DAR DATASET.csv with the following columns:
Year: Year of observation (e.g., 2014, 2015, ...)Month: Month abbreviation (e.g., Jan, Feb, Mar, ...)Season: Season classification (e.g., Dry, Wet, etc.)rainfall_mm: Rainfall in millimetersdaytime_temperature_celcius: Daytime temperature in °Cnighttime_temperature_celcius: Nighttime temperature in °Crelative_humidity_%: Relative humidity in percentage.Rmd file in RStudioCLIMATE DAR DATASET.csv is in the working directory# Knit from the console rmarkdown::render("MK_Test.Rmd") # Main analysis rmarkdown::render("OLS_Sensitivity_Check.Rmd") # Sensitivity analysis
Running the analysis will generate:
Mann-Kendall Test: Non-parametric test for monotonic trends
Sen's Slope Estimator: Robust non-parametric slope estimator
A formatted HTML table containing:
While statistical significance indicates that a trend is unlikely due to chance, consider the magnitude (Sen's slope) for practical implications. Small but statistically significant trends may have limited practical importance for long-term climate planning.
https://github.com/january-… Example: Sen's slope magnitudes showing increasing (red) and decreasing (green) trends across seasons.
If you use this code or methodology in your research, please cite:
@software{msemakweli2024mannkendall, author = {Msemakweli, January G.}, title = {{Decadal Trends in Seasonal Climatic Variables in Dar es Salaam, Tanzania: A Non-Parametric Approach Using the Mann-Kendall Test}}, year = {2024}, publisher = {Zenodo}, doi = {10.5281/zenodo.17720494}, url = {doi.org} }
Climate data sourced from: Tanzania Meteorological Authority (TMA)
This project is licensed under the Creative Commons Attributio….
You are free to:
Under the following terms:
Contributions, issues, and feature requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
For questions, suggestions, or collaboration opportunities, please contact:
January G. Msemakweli
Graduate Student | ScM in Epidemiology
Bloomberg School of Public Health
Johns Hopkins University
615 N Wolfe St
ORCID: 0009-0007-6743-8479
Keywords: Mann-Kendall test, Sen's slope, climate trend analysis, time series analysis, Dar es Salaam, Tanzania, rainfall trends, temperature trends, seasonal analysis, non-parametric statistics
Last Updated: January 2026