logo

Synopsis

This is a brief analysis and some models of the times the Sun has risen everyday in London (Mile End) from 1 January 2021 to 31 December 2025, where the time is in minutes from 00:00.

Modelling the dataset

⚠️ Important: You must have the Prophet package downloaded.

Load Prophet. This piece of code uses Prophet as a means to model the data, after importing it.

library(prophet)
## Warning: package 'prophet' was built under R version 4.3.3
## Loading required package: Rcpp
## Warning: package 'Rcpp' was built under R version 4.3.3
## Loading required package: rlang
## Warning: package 'rlang' was built under R version 4.3.3
sunrise_times <- read.csv("Mile_End_UK_Sunrise_2021_to_2025.csv")

sunrise_model <- prophet(sunrise_times)
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.

Predicting the sunrise times

Here, the next year’s sunrise times are predicted, according to the data. A dataframe is created. The tail() function shows the last 6 days (and their sunrise times) of the predicted data.

future_sunrises <- make_future_dataframe(sunrise_model, periods = 365)
tail(future_sunrises)
##              ds
## 2186 2026-12-26
## 2187 2026-12-27
## 2188 2026-12-28
## 2189 2026-12-29
## 2190 2026-12-30
## 2191 2026-12-31

Modelling the historical and future sunrise times

Here, the data and predicted data is plotted.

Note: yhat represents the average time (in minutes from 00:00) of sunrise, and the upper and lower yhats act as thresholds and the prediction lies between this range.

forecast <- predict(sunrise_model, future_sunrises)
tail(forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')])
##              ds     yhat yhat_lower yhat_upper
## 2186 2026-12-26 480.9484   472.6816   488.7451
## 2187 2026-12-27 481.3201   472.9169   489.7159
## 2188 2026-12-28 481.6875   473.3433   490.3721
## 2189 2026-12-29 481.9608   473.3741   489.1636
## 2190 2026-12-30 482.2378   474.2101   489.5631
## 2191 2026-12-31 482.4474   474.0174   490.2263
plot(sunrise_model, forecast, xlabel = "Time (days)",
     ylabel = "Time of day (minutes)")

The time series is split into its components here.

prophet_plot_components(sunrise_model, forecast, weekly_start = 0)
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## ℹ The deprecated feature was likely used in the prophet package.
##   Please report the issue at <https://github.com/facebook/prophet/issues>.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Interactive Plot

This is an interactive version of the time series.

dyplot.prophet(sunrise_model, forecast)
## Warning: `select_()` was deprecated in dplyr 0.7.0.
## ℹ Please use `select()` instead.
## ℹ The deprecated feature was likely used in the prophet package.
##   Please report the issue at <https://github.com/facebook/prophet/issues>.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Plots

Time(days) vs Time of Sunset (minutes)

The breaks represent when the time changes by an hour. The time goes forward by an hour at 01:00 on the last Sunday of March in UK. The time goes backward by an hour at 02:00 on the last Sunday of October.

The maximum and minimum peaks are when the Sun rises the latest (Winters) and earliest (Summers). These probably contribute to the solstices.

I think Prophet forces the lines to connect (overfitting perhaps). The predicted data is the same as the repeated pattern (a cycle).

Plot broken down into components

The first two plots might be overfitted since the day of the week is most likely not correlated with the times the Sun has risen, in the second plot.

The first plot does not seem accurate either as the pattern seems to repeat and here it shows that the Sun rises later throughout the years. It could be true, but the data does not reflect that.