library(prophet)
## Caricamento del pacchetto richiesto: Rcpp
## Caricamento del pacchetto richiesto: rlang
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ purrr::%@%() masks rlang::%@%()
## ✖ dplyr::filter() masks stats::filter()
## ✖ purrr::flatten() masks rlang::flatten()
## ✖ purrr::flatten_chr() masks rlang::flatten_chr()
## ✖ purrr::flatten_dbl() masks rlang::flatten_dbl()
## ✖ purrr::flatten_int() masks rlang::flatten_int()
## ✖ purrr::flatten_lgl() masks rlang::flatten_lgl()
## ✖ purrr::flatten_raw() masks rlang::flatten_raw()
## ✖ purrr::invoke() masks rlang::invoke()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::splice() masks rlang::splice()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
data<-read_excel("C:/Users/Emanuele/Downloads/EsameMQASS.xlsx",sheet=1)
data$ds<-as.Date(data$ds)
data$y<-as.numeric(data$y)
tail(data)
## # A tibble: 6 × 2
## ds y
## <date> <dbl>
## 1 2020-01-06 7758
## 2 2020-01-05 7359.
## 3 2020-01-04 7354.
## 4 2020-01-03 7345.
## 5 2020-01-02 6966.
## 6 2020-01-01 7201.
Model <- prophet(
yearly.seasonality = TRUE,
weekly.seasonality = TRUE,
daily.seasonality = FALSE,
changepoint.prior.scale = 0.5
)
Model<-add_country_holidays(Model,country_name='US')
Model<-fit.prophet(Model,data)
Future<-make_future_dataframe(Model,periods=365,freq="day")
view(Future)
Forecast<-predict(Model,Future)
tail(Forecast[c('ds','yhat','yhat_lower','yhat_upper')])
## ds yhat yhat_lower yhat_upper
## 2553 2026-12-27 120176.0 -88659.28 305174.9
## 2554 2026-12-28 120384.5 -89511.71 304345.5
## 2555 2026-12-29 120550.5 -94190.04 303079.4
## 2556 2026-12-30 120957.0 -89868.42 307346.4
## 2557 2026-12-31 120998.5 -91265.67 310331.1
## 2558 2027-01-01 119542.1 -98291.87 309479.3
dyplot.prophet(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 every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
prophet_plot_components(Model,Forecast)
