Precipitation Trends in Czechia

Author

Muhammad Merei

Introduction

This report simulates and analyzes monthly precipitation data for Czechia over a 10-year period (2010–2019). The analysis uses statistical methods and visualization tools covered in the Statistical Methods course. The aim is to demonstrate how such techniques can be applied to understand trends relevant to water governance and climate adaptation.

Load Required Packages

library(data.table)
Warning: package 'data.table' was built under R version 4.4.3
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.4.3
library(lubridate)
Warning: package 'lubridate' was built under R version 4.4.3

Attaching package: 'lubridate'
The following objects are masked from 'package:data.table':

    hour, isoweek, mday, minute, month, quarter, second, wday, week,
    yday, year
The following objects are masked from 'package:base':

    date, intersect, setdiff, union

Simulate Monthly Precipitation Data

We generate fake monthly precipitation values using a normal distribution.

set.seed(42)

# Create monthly dates for 10 years
dates <- seq(as.Date("2010-01-01"), as.Date("2019-12-01"), by = "month")

# Generate precipitation data
precip <- rnorm(length(dates), mean = 50, sd = 20)

# Construct data.table
precip_data <- data.table(
  date = dates,
  precip = pmax(round(precip, 1), 0)  # avoid negative values
)

# Add year and month columns
precip_data[, year := year(date)]
precip_data[, month := month(date)]

# Display first few rows
head(precip_data)
         date precip  year month
       <Date>  <num> <num> <num>
1: 2010-01-01   77.4  2010     1
2: 2010-02-01   38.7  2010     2
3: 2010-03-01   57.3  2010     3
4: 2010-04-01   62.7  2010     4
5: 2010-05-01   58.1  2010     5
6: 2010-06-01   47.9  2010     6

Monthly Average Precipitation

We calculate average precipitation for each calendar month across all years.

monthly_avg <- precip_data[, .(mean_precip = mean(precip)), by = month]
monthly_avg
    month mean_precip
    <num>       <num>
 1:     1       47.57
 2:     2       44.06
 3:     3       45.51
 4:     4       52.63
 5:     5       58.11
 6:     6       50.34
 7:     7       47.10
 8:     8       54.83
 9:     9       57.93
10:    10       56.49
11:    11       38.97
12:    12       54.92

Line Plot of Monthly Averages

ggplot(monthly_avg, aes(x = month, y = mean_precip)) +
  geom_line(color = "blue") +
  geom_point(color = "red") +
  geom_smooth(method = "loess", se = FALSE, color = "darkgreen") +
  labs(
    title = "Average Monthly Precipitation (2010–2019)",
    x = "Month",
    y = "Mean Precipitation (mm)"
  ) +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

Regression Trend Over Years

lm_model <- lm(mean_precip ~ year, data = annual_mean)
summary(lm_model)

Call:
lm(formula = mean_precip ~ year, data = annual_mean)

Residuals:
     Min       1Q   Median       3Q      Max 
-11.7299  -2.2940   0.5146   2.3161  13.3320 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)
(Intercept)  530.3188  1659.5396   0.320    0.757
year          -0.2381     0.8238  -0.289    0.780

Residual standard error: 7.483 on 8 degrees of freedom
Multiple R-squared:  0.01033,   Adjusted R-squared:  -0.1134 
F-statistic: 0.08352 on 1 and 8 DF,  p-value: 0.7799

Plot Annual Mean with Trend Line

ggplot(annual_mean, aes(x = year, y = mean_precip)) +
  geom_point(color = "darkblue", size = 3) +
  geom_smooth(method = "lm", se = TRUE, color = "orange") +
  labs(
    title = "Annual Mean Precipitation and Linear Trend",
    x = "Year",
    y = "Mean Precipitation (mm)"
  ) +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

Precipitation Distribution

Histogram of Monthly Precipitation

ggplot(precip_data, aes(x = precip)) +
  geom_histogram(binwidth = 5, fill = "skyblue", color = "black") +
  labs(
    title = "Distribution of Monthly Precipitation",
    x = "Precipitation (mm)",
    y = "Frequency"
  ) +
  theme_minimal()

Boxplot by Year

ggplot(precip_data, aes(x = factor(year), y = precip)) +
  geom_boxplot(fill = "lightgreen") +
  labs(
    title = "Monthly Precipitation Distribution by Year",
    x = "Year",
    y = "Precipitation (mm)"
  ) +
  theme_minimal()

Seasonal Analysis

We categorize the months into seasons and analyze average seasonal precipitation.

precip_data[, season := fifelse(
  month %in% c(12, 1, 2), "Winter",
  fifelse(month %in% c(3, 4, 5), "Spring",
          fifelse(month %in% c(6, 7, 8), "Summer", "Autumn"))
)]

seasonal_avg <- precip_data[, .(mean_precip = mean(precip)), by = season]
seasonal_avg
   season mean_precip
   <char>       <num>
1: Winter    48.85000
2: Spring    52.08333
3: Summer    50.75667
4: Autumn    51.13000

Bar Plot by Season

ggplot(seasonal_avg, aes(x = season, y = mean_precip, fill = season)) +
  geom_col() +
  labs(
    title = "Average Precipitation by Season",
    x = "Season",
    y = "Mean Precipitation (mm)"
  ) +
  theme_minimal()

Save the Simulated Dataset

fwrite(precip_data, "simulated_precip_data.csv")

Conclusion

This analysis demonstrates how simulated data and basic statistical tools can be used to assess precipitation patterns relevant to water governance. The visualizations and trend analysis are a valuable step toward understanding seasonal water availability, which is key for planning under changing climate conditions in Czechia.