Time Series Talk : Autoregressive Model

ritvikmath · Beginner ·📊 Data Analytics & Business Intelligence ·7y ago

Key Takeaways

The video covers the basics of the Autoregressive (AR) model in Time Series Forecasting, including its application in predicting the quantity of milk demanded based on past values, using tools such as the Partial Autocorrelation Function (PA CF) chart and the Autocorrelation Function (ACF) plot.

Full Transcript

in this video we're going to be continuing our exploration into timeseriesforecasting and we'll be talking about one of my all-time favorite models the AR model or the auto regressive model let's just talk about the name for a second before we get into this really easy example auto regressive so that means that it's a regression that you're probably familiar with right you're trying to predict something based on other things but this is a specific type of regression it's an auto regression which means you're trying to predict something based on past values of that same thing and that's a really powerful point that I think doesn't get emphasized enough in timeseriesforecasting videos or courses is that it's very natural to want to predict something maybe it's the price of some kind of item or it's the quantity of something you need or it's the number of houses sold per month whatever it is of course there's a lot of factors going into each thing such as the weather or the stock market or many other different things but what's more natural than saying I want to predict the value of that thing today based on what the value of that thing was yesterday based on what the value of that thing was last week last month last year going back right because that thing's gonna change in maybe some particular way maybe it's not been predictable at all but chances are that there could be some pattern that emerges and if we can capture that pattern we can get a much stronger prediction especially if we incorporate all those more common things that people think of when you do a regression all these other factors okay so I wanted to just give you guys a really really gentle introduction into why auto regression is a very powerful concept now let's get into the example and how you would figure out what is the best auto regressive model for your situation so in this setup you are a milk salesman more particularly you are a distributor of milk you ship milk all over the country and one really big problem for you is month by month you want to know how much milk should I produce so that I can have the exact amount for pretty much the right amount to ship to everyone who needs it I don't want to have too much right because I don't have milk which is going to spoil I don't want to have too little because then I can't fulfill all my orders so you want to know exactly how much milk should I load onto the truck this month so let's say you go ahead and see if you can use timeseriesforecasting or an auto regressive model maybe for this kind of situation so the first thing you do is you go ahead and drop a plot where the y-axis is the quantity of milk that is shipped and the x-axis is time so here we're saying each of these blocks separated by the purple dotted lines are years so here's 2016 2017 and 2018 and you make a chart of how much milk was demanded in each of those months so each of these black dots here's a month maybe let's say and you draw it out you can already see a pretty clear pattern here right as you go into the month into the year the quantity of milk demanded goes up up up and a little bit more halfway past a given year then it dips right and then maybe a plateaus and then at the beginning of the next year it starts all over again up and then down up and then down so this is a very predictable pattern that you can take advantage of to predict exactly how much milk you might need for any given month in the future in 2019 and young now how would we figure that out how would we figure out let me introduce some notation here so we can write a model in just a second let's say M sub T is the quantity of milk that is demanded this month let's say M sub t minus 1 is the quantity of milk that was demanded last month so minus 1 and and T's minus 12 for example is the quantity of milk that was demanded 12 months ago or this time last year okay so this is our notation for quantity of milk demanded of course the thing I'm trying to predict is M sub T because I'm in my current time period and the thing I have available to predict with or all these and so T minus 1 minus 2 minus 12 however much I want however much data I actually have right so one naive approach you could say hey why don't I just throw every single lag from 1 through 12 maybe into the model then I'll have a great prediction model right because I'm incorporating all the data that I have well you might get a seemingly strong model but it's gonna be prone to a lot of statistical issues like overfitting which just means that it's too too tuned to your certain data and besides in statistics in regression modeling if a simpler model can do the job or pretty much same job as a very complicated model we're going to prefer that simple model because it's going to hold up better over time so for that reason we want to figure out only which lags only which of these T - what are important for our situation we're going to be using our good friend the PA CF chart or partial autocorrelation function so if you haven't seen my video on autocorrelation and partial autocorrelation go ahead and watch that if you really don't want to watch it then the basics of PA CF are that the PA CF at a given lab so for example PA CF of lag 1 is going to be the direct correlation actually maybe better to say the P AC F of 3 it's going to be the direct correlation of the quantity of note demanded three months ago on the quantity of note today without considering so removing the effects of the intermediary temporaries which are so we're trying to do MT - three direct effect on M sub T that means it removes the effect of M sub T - - price of the quarter Damon up two months ago and M sub t minus one quantity of milk just last night it's the direct effect so it's pretty natural here we only want to keep the lags whose direct effects are high in magnitude either positive or negative if those direct effects are zero or statistically very close to zero we don't want to include those lives because if some certain lab has no direct correlation with our quantity of milk donated today why would we include it it's not important it's just going to make our model noisy and cluttered right so we only want to include the lands whose PA CF are above these red bands and these red bands basically you can think of them as anything within the red bands we don't we think is statistically close to zero anything outside the red bands are statistically different than zero so we have evidence to say that anything else other advanced is actually different from zero so let's just go through our target and see lag one definitely is statistically different than zero in a positive direction lag - statistically different from zero in the negative direction like three does not cut it because it's below the top air band lag for does cut it statistically different from zero in the negative direction and let's say all these lags in between do not cut it but the lag at twelve or one year ago well months ago does cut it and it's very strong okay and let's just say that all the lags after twelve are statistically below zero they don't cut it so we're only concerned with these four that do cut it okay so what might a good model look like a good model might look like of course we first start out with the thing we're trying to predict which is M sub T we have a coefficient here they debate or not the intercept and then we have beta one and of course the first flag is M sub t minus 1 plus beta 2 and sub t minus 2 then 3 didn't cut it so we have 4 plus beta for M sub t minus 4 and then we had one more theta 12 and sub t minus Bob and we need to include that error term so me box this model in a different color purple here so this based on our evidence could be a good model to help us predict the quantity of milk demanded today based on the quantity of milk demanded a month ago two months ago four months ago and 12 months ago okay and we deduced that based on the PA CF plot which again is just measuring the direct correlation the price of milk some number of lives ago along the price I'm sorry quantity of milk some months ago on the quantity of milk today that is the basics of an AR model and the reason I liked it so much is just its simplicity its simplicity starting from the concept of it predicting something based on past values of that thing to figuring out a model based on this p ACF which is very intuitive to think about going from there to actually creating your model and testing okay this was a very gentle introduction to a our models of course there's many other factors going into this but we will save those for in a future video okay so until next time

Original Description

Gentle intro to the AR model in Time Series Forecasting My Patreon : https://www.patreon.com/user?u=49277905
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from ritvikmath · ritvikmath · 46 of 60

1 Math Team Update
Math Team Update
ritvikmath
2 Single Variable Calculus Volume of a Sphere - Proof 1
Single Variable Calculus Volume of a Sphere - Proof 1
ritvikmath
3 Single Variable Calculus Volume of a Sphere - Proof 2
Single Variable Calculus Volume of a Sphere - Proof 2
ritvikmath
4 Multivariable Calculus Volume of a Sphere Proof - Triple Integrals
Multivariable Calculus Volume of a Sphere Proof - Triple Integrals
ritvikmath
5 Multivariable Calculus Volume of a Sphere Proof - Double Integrals
Multivariable Calculus Volume of a Sphere Proof - Double Integrals
ritvikmath
6 The Euclidian Algorithm
The Euclidian Algorithm
ritvikmath
7 Proving the Chain Rule
Proving the Chain Rule
ritvikmath
8 Proving the Fundamental Theorem of Calculus Part 1
Proving the Fundamental Theorem of Calculus Part 1
ritvikmath
9 Proving the Fundamental Theorem of Calculus Part 2
Proving the Fundamental Theorem of Calculus Part 2
ritvikmath
10 Math Puzzle - Poison Perplexity
Math Puzzle - Poison Perplexity
ritvikmath
11 Math Puzzle - Poison Perplexity - Solution
Math Puzzle - Poison Perplexity - Solution
ritvikmath
12 Expected Value and Variance of Continuous Random Variables (Calculus)
Expected Value and Variance of Continuous Random Variables (Calculus)
ritvikmath
13 Expected Value and Variance of Discrete Random Variables (No Calculus)
Expected Value and Variance of Discrete Random Variables (No Calculus)
ritvikmath
14 Array Method
Array Method
ritvikmath
15 Complex Power Series and their Derivatives
Complex Power Series and their Derivatives
ritvikmath
16 Distributions - Intro
Distributions - Intro
ritvikmath
17 The Poisson Distribution
The Poisson Distribution
ritvikmath
18 The Bernoulli Distribution
The Bernoulli Distribution
ritvikmath
19 The Binomial Distribution
The Binomial Distribution
ritvikmath
20 The Continuous Uniform Distribution
The Continuous Uniform Distribution
ritvikmath
21 The Geometric Distribution
The Geometric Distribution
ritvikmath
22 The Triangular Distribution
The Triangular Distribution
ritvikmath
23 The Exponential Distribution
The Exponential Distribution
ritvikmath
24 The Borel Distribution + Notes on Poisson Distribution
The Borel Distribution + Notes on Poisson Distribution
ritvikmath
25 The Gamma Distribution
The Gamma Distribution
ritvikmath
26 The Normal Distribution
The Normal Distribution
ritvikmath
27 The Laplace Distribution
The Laplace Distribution
ritvikmath
28 The Chi - Squared Distribution
The Chi - Squared Distribution
ritvikmath
29 Overfitting
Overfitting
ritvikmath
30 Vector Norms
Vector Norms
ritvikmath
31 Truths Behind the Titanic : K-Nearest Neighbor
Truths Behind the Titanic : K-Nearest Neighbor
ritvikmath
32 The Mathematics of Breakups
The Mathematics of Breakups
ritvikmath
33 Sillyfish
Sillyfish
ritvikmath
34 Finding Optimal Paths - Dynamic Programming
Finding Optimal Paths - Dynamic Programming
ritvikmath
35 HowToDataScience : Scraping Twitter Data
HowToDataScience : Scraping Twitter Data
ritvikmath
36 Decision Trees
Decision Trees
ritvikmath
37 Perceptron
Perceptron
ritvikmath
38 Naive Bayes
Naive Bayes
ritvikmath
39 K-Nearest Neighbor
K-Nearest Neighbor
ritvikmath
40 Evaluating Machine Learning Models
Evaluating Machine Learning Models
ritvikmath
41 Decision Tree Pruning
Decision Tree Pruning
ritvikmath
42 K-Means Clustering
K-Means Clustering
ritvikmath
43 Gaussian Mixture Model
Gaussian Mixture Model
ritvikmath
44 Data Science - Fuzzy Record Matching
Data Science - Fuzzy Record Matching
ritvikmath
45 Time Series Talk : Autocorrelation and Partial Autocorrelation
Time Series Talk : Autocorrelation and Partial Autocorrelation
ritvikmath
Time Series Talk : Autoregressive Model
Time Series Talk : Autoregressive Model
ritvikmath
47 Time Series Talk : Moving Average Model
Time Series Talk : Moving Average Model
ritvikmath
48 Time Series Talk : ARMA Model
Time Series Talk : ARMA Model
ritvikmath
49 Time Series Talk : ARCH Model
Time Series Talk : ARCH Model
ritvikmath
50 Time Series Talk : White Noise
Time Series Talk : White Noise
ritvikmath
51 Time Series Talk : Stationarity
Time Series Talk : Stationarity
ritvikmath
52 Time Series Talk : ARIMA Model
Time Series Talk : ARIMA Model
ritvikmath
53 Time Series Talk : Lag Operator
Time Series Talk : Lag Operator
ritvikmath
54 Time Series Talk : What is Seasonality ?
Time Series Talk : What is Seasonality ?
ritvikmath
55 Time Series Talk : Seasonal ARIMA Model
Time Series Talk : Seasonal ARIMA Model
ritvikmath
56 So ... What Actually is a Matrix ? : Data Science Basics
So ... What Actually is a Matrix ? : Data Science Basics
ritvikmath
57 Derivative of a Matrix : Data Science Basics
Derivative of a Matrix : Data Science Basics
ritvikmath
58 Basics of PCA (Principal Component Analysis) : Data Science Concepts
Basics of PCA (Principal Component Analysis) : Data Science Concepts
ritvikmath
59 Eigenvalues & Eigenvectors : Data Science Basics
Eigenvalues & Eigenvectors : Data Science Basics
ritvikmath
60 The Covariance Matrix : Data Science Basics
The Covariance Matrix : Data Science Basics
ritvikmath

This video teaches the basics of the Autoregressive (AR) model in Time Series Forecasting, including how to use the Partial Autocorrelation Function (PA CF) chart and the Autocorrelation Function (ACF) plot to determine model parameters and predict future values. The AR model is a type of regression that predicts something based on past values of the same thing, making it useful for forecasting quantities such as milk demand.

Key Takeaways
  1. Drop a plot with the y-axis as the quantity of milk shipped and the x-axis as time
  2. Draw a chart of how much milk was demanded in each month
  3. Identify a predictable pattern in the data
  4. Plot PA CF chart to identify important lags
  5. Determine statistically significant lags by identifying values outside the red bands
  6. Select lags with high magnitude direct effects for inclusion in the model
  7. Create an AR model
  8. Determine model parameters using ACF plot
  9. Test the model
💡 The AR model can be used to predict future values based on past values, and the Partial Autocorrelation Function (PA CF) chart and the Autocorrelation Function (ACF) plot are useful tools for determining model parameters.

Related Reads

📰
The Surveillance State’s Fatal Flaw: Why Total Information Awareness Collapses Under Its Own Weight
The surveillance state's total information awareness is doomed to collapse due to its own complexity, highlighting the importance of privacy as civil disobedience
Medium · Data Science
📰
How to Calculate Return on Investment (ROI) for Operational Tech & AI Investments
Learn to calculate Return on Investment (ROI) for operational tech and AI investments to quantify tangible dollar returns and strategic value
Medium · Data Science
📰
Beyond Firefighting: How to Use Data to Identify Hidden Growth Opportunities
Use data to identify hidden growth opportunities and shift from reactive problem-solving to proactive opportunity mining
Medium · Data Science
📰
There Are Many Ways to Skin a Cat: Querying Data with SQL and Pandas
Learn to query data using SQL and Pandas, and understand the different approaches to data processing
Medium · Python
Up next
Which Ad Placements Make the Most Money? (Using Ezoic Big Data Analytics)
Chris - Niche Safari
Watch →