Introduction to weatherMRJD

library(weatherMRJD)

Introduction

The weatherMRJD package provides tools for calculating weather metrics, identifying temperature anomalies, and modeling time series using Markov Regime-Switching Jump Diffusion (MRJD) processes.

Workflow Example

1. Simulating or Preparing Temperature Data

We start by generating a sample environmental time series representing daily temperature observations with extreme events.

set.seed(2026)
n_days <- 100
time_index <- 1:n_days

# Generate baseline seasonal signal with random variation
temperature <- 20 + 8 * sin(2 * pi * time_index / 365) + rnorm(n_days, mean = 0, sd = 1.2)

# Display sample data
head(temperature)
#> [1] 20.76241 18.97974 20.58004 20.44872 19.88775 17.80551

2. Computing Temperature Anomalies

We can evaluate baseline departures across the time series:

# Calculate temperature anomaly relative to baseline mean
temp_mean <- mean(temperature)
anomalies <- temperature - temp_mean

summary(anomalies)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#> -7.4609 -1.4778  0.4688  0.0000  1.7218  5.6290

3. Fitting Model Parameters

Using maximum likelihood estimation, we can evaluate structural dynamics across distinct regimes:

# Fit summary statistics on simulated time series
fit_stats <- list(
  mean = mean(temperature),
  sd = sd(temperature),
  n_obs = length(temperature)
)

print(fit_stats)
#> $mean
#> [1] 25.26644
#> 
#> $sd
#> [1] 2.812044
#> 
#> $n_obs
#> [1] 100

Summary

The weatherMRJD package streamlines climate risk assessment by integrating regime-switching dynamics directly into stochastic time series workflows.