Hi. In this video, I'm going to give you a basic introduction to some forecasting techniques, and then primarily focus on linear regression as a forecasting tool. So let's get started. The first method I want to describe is simply to use the average of the past values as a forecast for the future value. So you take all your data points and take the average add them up divide by n. But instead of dividing by code n, I want to be a little more specific, little more rigorous. So here we have this notation. So I want to explain that really quickly. Y hat, that's our forecast value. So if you see a hat, that's our estimate or forecast value. So y hat is our forecast value at time T plus h. So what does that mean? It means we have data say, for period 1, period 2, period 3 up to period T. Sometime periods. So if it's five years of data, T is five, if it's 60 months of data, T is 60, what have you. H is just the number of periods that you want to look ahead. If you want to think of it simply, just have h equals 1. So given the past 60 days, I want to figure out or predict what tomorrow's value of y should be. Then this little vertical bar T that means given all your past values up to T. So y hat is your estimate. It's the estimate of period t plus h. If h is one it's just tomorrow. If h is two it's two days from now or two periods from now, given the past values. This average method uses y-bar which is simply to add them up; y1 plus y2 plus y3 etc up to yT and divide by T. The other subtle point in notation is that one to T is the time periods, whereas if you see an average formula for a list of numbers you'll see x1 through n as the number of elements, but there's no implied time value involved. So that's the average method, and that's your prediction. So let's take a look at the R code. So here I have put up a little program to show these different methods. We're going to need this library FMA that has time series datasets, and now we're just going to use, the first example is to use averages of forecast. Recall that this head command head open paren, in this case beer, will display the first few lines of this dataset beer which can be found in this library FMA. So let's run that line, and here you can see some of the first few values. If you want to see the whole dataset, you can just type the name of the dataset beer, and you can see there it is. We have data from 1991 January, and as you go across, you have the amount of beer produced for each month, and then it goes through 1995, August. This dataset is the beer data, has monthly beer production data in Australia. So that's what this data represents. The next line summary gives us the descriptive statistics of this dataset, and there you have it. You have the minimum value is a 119. The maximum value is 192. The median and the mean are 145.5 and 149.3 respectively, and you have the interquartile ranges. It's always a good idea to plot the data, so let's do that. I plotted the data over here on the right, you can see it. Let me make that screen a little bigger and like all time series data, you have time on the bottom and then the amount of beer produced on the y-axis. Mean F is the mean forecast of beer for one forecast period forward, that's 149.3 which is the same as the mean, and if you do five periods forward the values are the same, noticed. So for September '95, the prediction is given your past values of T is 149.3 and it's the same for each of the next five periods. We don't have any more information. So that's what that means there. So in the R-code I had h equal one, h equal two, h equal three, four and five. That didn't really change the value of our estimate. The value is still y bar or the average of the data points that we had up until that point of time, and that's not a bad method, right. If you're trying to figure out what to wear tomorrow you can look at the average temperatures for the past seven days to decide what the temperature is tomorrow and decide whether or not you're going to bring a heavy jacket or a light sweater or something like that. Granted, the time period is important, so you do want to think about how much time you want to collect. How many periods you want to collect. All right, and that wraps it up for the average method.