Pronosticando casos de coronavirus usando Prophet.
#Call the Packages
library(prophet)
## Loading required package: Rcpp
## Loading required package: rlang
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.3 v purrr 0.3.4
## v tibble 3.1.1 v dplyr 1.0.6
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x purrr::%@%() masks rlang::%@%()
## x purrr::as_function() masks rlang::as_function()
## x dplyr::filter() masks stats::filter()
## x purrr::flatten() masks rlang::flatten()
## x purrr::flatten_chr() masks rlang::flatten_chr()
## x purrr::flatten_dbl() masks rlang::flatten_dbl()
## x purrr::flatten_int() masks rlang::flatten_int()
## x purrr::flatten_lgl() masks rlang::flatten_lgl()
## x purrr::flatten_raw() masks rlang::flatten_raw()
## x purrr::invoke() masks rlang::invoke()
## x dplyr::lag() masks stats::lag()
## x purrr::list_along() masks rlang::list_along()
## x purrr::modify() masks rlang::modify()
## x purrr::prepend() masks rlang::prepend()
## x purrr::splice() masks rlang::splice()
df1<- read.csv("E:/DailyCOVID.csv")
View(df1)
colnames(df1)=c("ds","y")
head(df1)
head(df1)
#Call the Prophet Function and Fit the Model
Model1 <- prophet(df1)
## Disabling yearly seasonality. Run prophet with yearly.seasonality=TRUE to override this.
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
#Model1
future1 <- make_future_dataframe(Model1, periods = 30)
tail(future1)
#Forecast
forecast1 <- predict(Model1, future1)
head(forecast1)
tail(forecast1[c('ds','yhat','yhat_lower','yhat_upper')])
#Plot the Estimates
dyplot.prophet(Model1, forecast1)
## Warning: `select_()` was deprecated in dplyr 0.7.0.
## Please use `select()` instead.
prophet_plot_components(Model1,forecast1)

#Cumulative Coronavirus Cases
df2 <- read.csv("E:/TotalCOVID.csv")
View(df2)
#df2 <- read.csv(file.choose())
head(df2)
colnames(df2)=c("ds","y")
head(df2)
#Call the Prophet Function and Fit the Model
Model2 <- prophet(df2)
## Disabling yearly seasonality. Run prophet with yearly.seasonality=TRUE to override this.
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
future2 <- make_future_dataframe(Model2, periods = 30)
tail(future2)
#Forecast
forecast2 <- predict(Model2, future2)
tail(forecast2[c('ds','yhat','yhat_lower','yhat_upper')])
#Plot the Estimates
dyplot.prophet(Model2, forecast2)
prophet_plot_components(Model2,forecast2)
