---
title: "Basic Time Series Forecasting"
author: "Martin Schedlbauer, PhD"
format: 
  revealjs:
    logo: "https://s3.us-east-2.amazonaws.com/artificium.us/assets/icons/NU+Logo.png"
    footer: "3.303L | Forecasting"
    theme: serif
editor: source
---

## Introduction to Forecasting

  - Builds predictive models based on trends in time series data
  - Essential in fields like finance, economics, and science for predicting future values
  - Relies on historical data to identify patterns and trends to predict future outcomes

------

```{r, echo=FALSE, out.width='70%'}
library(ggplot2)

# Create example time series data with month names
months <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
values <- c(150, 160, 170, 180, 175, 185, 190, 200, 210, 205, 215, 220)

# Create the data frame
time_series_df <- data.frame(
  month = factor(months, levels = months),
  values
)

# Create the line chart
ggplot(time_series_df, aes(x = month, y = values, group = 1)) +
  geom_line(color = "blue") +
  geom_point(color = "red") +
  labs(title = "Average Daily Sales for Past Year",
       x = "",
       y = "") +
  theme_minimal()
```

## Lesson Overview

**Key concepts covered in this lesson:**

  - Fundamental principles of forecasting
  - Various forecasting methods
  - Practical implementations using R

## Forecasting Techniques

- **Simple Methods**
  - Moving Averages
  - Weighted Moving Averages
- **Statistical Methods**
  - ARIMA
  - Exponential Smoothing
  - Linear Regression
- **Advanced Techniques**
  - Prophet
  - LSTM Neural Networks

## Sample Data

Average daily water use (in liters) from CSV file `waterusage.csv`.

```{r displayCSV, eval = T, echo = F}
# load data from CSV
water.usage.ts <- read.csv("../waterusage.csv",
                           stringsAsFactors = F)

# display first few rows
knitr::kable(head(water.usage.ts, 4),
             format = "simple",
             align = "c")
```

## Moving Averages





## Summary and Conclusion

- **Recap of Key Points**
- **Importance of Accurate Forecasting and Predictive Modeling**
- **Final Thoughts**

## Q&A
