The overview of topics that we're going to get into today are going to include the importance of times
hearings in a business context.
We'll get him to submit to come to composition basics such as Time series components additive versus
multiplicative mounds.
Then we'll jump into some time series forecasting techniques and we'll get into some in general modern
modelling considerations some of modelling algorithms themselves and then an output interpretation and
diagnostics afterwards we'll get into a practical application example and then what.
As part of practical application example we'll talk about generalized least squares with maximum likelihood
method
the importance of times here these predictions cannot be understated.
From a business context the ability to observe the development of an area of interest over time and
make predictions based upon historic observations creates a competitive advantage within an analyst's
base 21st century global business environment.
For example if the organization has a capability to better forecast the sales quantities of the product
it will be in a much more favorable position to structure procurement optimize inventory levels.
This can result in an increase in liquidity of an organization's cash reserves decrease up working capital
and improve customer satisfaction through increased order fulfillment and decreased back orders.
Additionally the senior management can formulate the entire capacity planning fiscal sales budget of
the organization through better prediction of revenue cutting costs and profit margin headcount cap
ex and earned expenditures marketing budgets all rely heavily upon having a proper sales but at times
his predictions are the backbone of a successful organization.
I'm not going to get into too much of the business aspects here moving forward.
We're really going to talk about the actual techniques of Time series predictions and how to use them
correctly.
If you want to understand more of a business example and how to use this feel free to go to the first
presentation and the practical example that we went through which we'll talk in detail about how we
can leverage time series and financial planning purposes but with that said let's actually talk and
get into time series and how to use them correctly.
The first topic we're going to look into is decomposition basics.
And this is a fundamental concept in working with time series data.
So we have to have an innate understanding of how this works in order to really use time series methods
correctly
before we begin I want to get into briefly into the concept of looking at graphs critically and evaluating
what we see in the pattern.
Humans naturally see patterns in the data.
We're a visual creature to begin with but when we're talking in the context of being a data scientist
or an analytical professional we have to interpret these grants differently and we need to think about
time series in a different context in order to really master these techniques.
So whatever you're looking at these graphs just think of it from a more analytical perspective.
When we as a time series chart and then we start to look at this chart on the right hand side if we
need to begin to think about decomposing the chart into its basic building blocks and then determine
what type is high time series model where we're trying to model in this case this process needs to be
reformed with every time series predictive task to ensure that we pair up the appropriate analytical
model that best suits the data.
It's not like we can say okay I'm working on time series therefore I'm going to pull out this particular
model and it's going to be a one size fits all.
I'm just gonna run it through my time series algorithm and boom I'm going to have my predictions.
We have to really understand how to pair the right model with the right time serious data.
I want to talk a little bit about the basics of the composition in the previous example.
We can take that graph.
We can break it into these fundamental components.
So at the top we actually see what the graph looks like.
But if you begin to peer through the noise and start to look at the components that are with it I see
that there's a trend component a seasonality component and then there's attributes beyond that general
trend and seasonality that we call random fluctuations
one of the most important concepts when working with time series and decomposition is the concept of
seasonality seasonality or seasonal effects.
It's a systematic and calendar related effect.
Some examples include the sharp escalation in most retail series which occurs around December in response
to the Christmas period or an increase in water consumption in summer due to warmer weather.
So these are processes that have a natural spike or decrease due to a regular interval throughout the
time of the year.
Other seasonal effects include training day efforts the number of working or trading days in a given
month differs from year to year which will impact upon the level of activity in that month and moving
holidays.
The timing of holidays such as Easter varies so the effects of the holiday will be experienced in different
periods each year.
Seasonal adjustment on the other hand is the process of estimating and then removing from a time series
influences that are systematic in calendar related observed data needs to be seasonally adjusted as
seasonal effects can conceal both the true underlying movement in the series as well as certain non
seasonal characteristics which may be of interest to analysts seasonality in a time series can be identified
by regularly spaced peaks and troughs which have a consistent correction in approximately the same magnitude
every year relative to the trend.
This is an important idea that when we're looking at the seasonal component
seasonality arises from systematic calendar related to influences such as natural conditions weather
fluctuations that are representative of the season.
So snow removal could be one example of financial condition or hurricane season.
Business and administrative procedures for example the start and end of a school term social and cultural
behavior such as a on a holiday for religious purposes as Christmases and calendar related effects.
And as we talked about the trading day effects which are the number of occurrences of each day of the
week in a given month will differ from year to year.
For example if there are four weekends and merge and two thousand but five weekends of March of 2002
and also this would include the moving holiday effects which would be like Easter which occurs on a
different day depending on the year
another aspect with decomposition is the trend and regular components a trend can be defined as a long
term movement in a time series without calendar related and random irregular effects.
And it's a reflection of the underlying level the irregular component sometimes known as the residual
is what remains after the seasonal and trend components of Time series have been estimated and removed.
It results from the short term fluctuations in the series which are another systemic or systematic nor
predictable in a highly irregular series these random fluctuations can dominate for months which will
mask the trend seasonality
the seasonal trend and random components can be combined traditionally in two major matters to match
the total observed data can be combined attitude which is an implicit assumption is that the three components
are combined in an additive fashion to match the data so I take my data take my seasonal component plus
my trend component plus my random fluctuation and that matches the data.
Alternatively we can look at it in a multiplicative sense which is the implicit assumption that the
three components are combined in a multiplicative fashion which is I take the data and it's is seasonal
times the trend times there in component
the underlying question that we have here now is do I take a multiplicative or captive approach to the
data for the time 30 seconds we will discuss our approach from an additive standpoint
fortunately multiplicative models are equally easy to fit to a data as of models.
The trick to fit in a multiplicative model is to take a logarithms of both sides of
some I take the log of data equals like the seasonal constraint post fandom after taking the logarithms
either natural logarithms or the base held logarithms.
The three components of a time series again at additive free.
It is important to recognize when multiplicative models are appropriate.
However thinking commands is no harder than fitting additive nouns.
This is important because when we're looking at constructing the approach we want to approach it from
a narrative perspective.
So before we dive into the topic of additive metals I want to give a very simple multiplicative example
so we can understand when to use this type of model versus an additive approach.
In many times series involving quantities of such a stock price movement of money wheat production the
absolute differences in the values are of less interest in importance than the percentage changes.
And then when this happens this is the scenario where a multiplicative approach will be used.
So if I want to understand percentage change of movement multiplicative approaches are more appropriate
than the additive in many times here is the amplitude of both the seasonal and irregular variations
increase as the level of trend rises
as the underlying level of the series changes the magnitude of seasonal fluctuations variance as well.
This shows characteristics of a multiplicative ultra modern approach so as trends are building we see
the peaks and troughs shifting with the trend components and these are characteristics indicative of
multiplicative for time series models.
Note that we've addressed the concept of an additive approach to time series.
Let's look at some forecasting techniques
before we begin on this let's talk about a general approach for analysis.
First as we identify through a visual inspection whether the data has seasonality or trends.
This is important when we identify whether the composition technique required is additive or multiplicative
if it is a multiplicative nature to a large transformation then we're going to test an appropriate additive
algorithm for our time scales.
And there are many different techniques that we're looking at and we'll get into these topics in a moment.
But look at the seasonal look at the trend and look at the random fluctuations.
If there is no seasonal component but there is a trend in Poland and there are no correlations in the
Kingdom more than a simple moving average smoothing method is appropriate.
If we see that there's a seasonal component and there is a trend component that there are no correlations
in the data within the seasonal adjustment.
Likewise with a simple exponential smoothing method.
If there's no seasonal component that there is a trend component no correlations well then this is a
method that will reduce.
We can continue to go on with false exponential smoothing.
So there is no seasonal but there is a trend that no correlations.
This is a technique that is applicable to that type of temps cold winter is exponential smoothing works
when we have seasonal and a trend but no correlations.
Finally another topic is an arena model which can be used whether we have a seasonal trend and the correlations
in the data.
So by looking at the data center and then performing some certain tests that gives us a clue of what
the appropriate time series model is to use.
And we have to do that before we can properly apply the technique to our data.
Afterwards we put we're going to perform some statistical tests to verify that the correct model has
been selected and we'll use the was on Baxter's test.
We'll forecast the errors and making sure that our distributions are normal given the mean 0 tons of
variables which we had talked about in previous lectures then we'll get into the idea of an auto correlation
function or personal auto correlation function which are called the ECF and PNC respectively after we've
done this then who can repeat steps 3 and 4 if necessary.
So if we use a model it turns out that it doesn't have the rights to of that there were no back or try
a different method until we found that the right combination that works for us
the first method that we're going to talk about is going to be the simple moving average smoothly
so what is a simple moving average smoothing out the time series.
It's used to estimate the trend component of a non seasonal type of series which consists of a trend
component and an irregular component and it can be described using the active model.
It's common to use a swimming method such as calculating the simple moving average of a time series
then what we're going to do is we're going to look at a time series of coffee age of Kyrgyzstan and
these are the four successive kings in England starting with William the counter on the y axis looking
to see aging years and the x axis we're gonna see the number of kings.
So as each King is living we're going to find that the age in which that they had died
this dataset when we look at it it doesn't seem to show any seasonality or trending.
However the random fluctuation of the data are roughly constant in size over time.
So just by looking at this data we still discernible pattern or trending in the budget but we do see
the random fluctuation is somewhat consistent.
This essentially suggests to us that an additive model could be used to describe the date set so by
visually looking at this that the line graph in this case we can make some reasonable assumptions that
an adequate model will work is it's going to start to smooth out these components until we just see
just the area of interest but this process takes a little bit of trial and error to find the right amount
of smoothing.
For example we can try using the simple moving average of the order a
the data without simple moving average for her eight gives us a clearer picture of the trend component.
So now we can actually see that in the shape of the trend over time a little more clearly we can see
that the age of death in the scheme of things seems to have increased for about 55 years old to about
38 year old during the reign of the first 20 kings and then it increases after that to about 73 years
old by the end of the reign of the fortieth kingdom in the time series.
In this is clearly seen in the data
that we're going to dive into the topic of a seasonality adjustment to the way to decompose seasonal
data and seasonally adjusted.
In our example here we're going to look at the number of births per month in New York City.
The Y access is going to be the actual number of births in the x axis.
We're going to have at the time in months the dataset shows a seasonal variation with a number of births.
There seems to be a peak in every summer and a trough in every winter the seasonal fluctuation are roughly
consistent in size over time and random fluctuations are often in pencil size and this intensity that
an additive modelling method could be used to describe the dataset before we begin on this.
Let's really take a look at this dataset we can see that there is a general upward trend over time.
So at first we see a large gap but then systematically builds up over time.
So that's what I would expect to see the trend component.
The seasonality which is kind of the heartbeat shape in this case we can see high peaks and low tracks.
It's readily disappointment.
But if you look at some of the peaks in some of the tracks we see a lot more like little squiggles in
the line those squiggles are the irregular components.
So looking at this dataset to try to visually imagine what those three components are whenever you're
working time series
in the plot above it shows the original time series the estimated trend which is second second from
the time the estimated seasonal component which is third from the time and the estimated irregular component
which is at the bottom of this place.
So if decomposed repetitive homes hearings into these sleep measures and we see that the estimated trend
component shows a small decrease for about 24 in 1947 to about 20 to 1948 followed by a steady increase
from then on to about 27 in nineteen fifty then
if you have a seasonal time series that can be described using an additive model you can seasonally
adjusted Home series by estimating the seasonal components and subtracting the estimated seasonal component
from the Arizona slope series so we take our seasonally adjusted curve which is our original minus our
seasonal component and we can see that seasonal variation has been removed from the seasonally adjusted
time service the seasonally adjusted types there is no adjusted his the trend component and then the
rate for component.
So by looking at this graph we have now removed that seems more common pattern from the data
we will now shift gears and talk about a simple exponential smoothing method.
Now let's dive into a simple exponential smoothing example.
Here's a data set which contains the total annual rainfall in inches for London from 1813 to 1912.
The y axis we have our rainfall on the x axis.
We have our month's we can see from the plot that there is roughly constant level.
That means these counts and at about 25 inches.
And if we look at this graph we can imagine putting in a line for 25 inches across the horizontal.
In this case you would see that all the peaks and troughs were kind of cut through this line in the
middle.
The random fluctuations in the time series seem to be roughly constant in size over time.
So it is probably appropriate to describe the data using a narrative model.
If we have a time series that can be described using an additive model with constant double and no seasonality
you can use a simple exponential smoothing to make short term for forecast
the simple exponential smoothing method provides a way of estimating the level at the current time point
smoothing is controlled by the parameter alpha for the estimate of the level at the current time point
the value of alpha lies between 0 and 1 values of Alpha that are close to zero mean that little weight
is placed on the most recent observations when making forecasts of future values.
So in our if I run the whole winter's simple exponential smoothing I see what my smoothing parameter
in this case I see what my alpha level is to what the output Nara is telling us is that the estimated
value of the Alpha parameter is about zero point zero to four.
This is very close to zero which tells us that the forecasts are based on both the recent and the less
recent observations although somewhat more weight is placed on recent observations.
The plot shows the original time series in blue and the forecasts as a red line.
The time series of forecasts is much smoother for the time series of events on data.
Here has a measure of the accuracy of the forecast.
We can calculate the sum of squared errors for the in sample forecasters which is the forecast errors
for the time period covered by our original time series.
It is common in simple exponential smoothing to use the first value in a time series as the initial
account for the level.
For example in the time series for rainfall in London the first value is twenty three point five six
for rainfall in 1830.
So when we run our whole winter's technique we see that the El that start called parameter in the year
in the our model will defining twenty three point five six.
But when we look at this chart we see that the line is almost a straight line that cuts through in the
middle.
So between our actual observe and what we were predicting in this case there's a very large variation
using this technique
here.
The forecast for 1930s 1920 are plotted as the red line.
The 80 percent prediction interval as the area between the marooned out of lines.
The forecast errors are calculated as the observed value minus the predicted values for each time point.
Of course we can only calculate the forecast area errors for the time period covered by our original
time series which is from 1830 to 1912.
So the rainfall data so we can't calculate errors when we're forecasting the future because we haven't
observed anything in the standard that doesn't show at the end of 2012 1912
what were some of the statistical tests that we can use to improve upon this model.
If the predictive model cannot be improved upon.
There should be no correlations between forecasters for successive predictions.
In other words if there are correlations between forecast errors for successive corrections it is likely
that the simple exponential smoothing forecast could be improved upon by another forecasting technique.
To figure out whether this is case we can obtain a call a hologram or an ECF of the insane for forecasters
for lands 1 to 20 we can see from the sample the caller hologram that the auto correlation like 3 is
just touching the significant bounds.
So these significant phones these dotted lines we're looking for breaches that are crossing that threshold
mistake.
And in this example we see event greetings who are it's very close right and I had three
now we're going to conduct the watch on the box test and the test statistic is seventeen point four
and the p value is zero point six for this model when we run this.
This gets this little evidence of non zero auto quotations and the in sample focus areas at last one.
So by actually typing this into Arkansas and specifying that playing a 20 and running this was on the
box hence we can find out that there is little evidence of nonzero auto correlations in the simple forecast
so to be sure that the predictive model cannot be improved upon.
And is also a good idea to check that the forecast errors are normally distributed with a mean zero
and constant variance to check whether the forecasters have constant variance.
We can make a timeline for the any sample forecast errors
the planet shows that the example forecasters seem to have roughly constant variance over time although
the size of fluctuations in the start of the time series may be slightly less than at later date.
So we're looking at this.
We're just looking to see like a much bigger residual part of your question with the peaks and troughs
are kind of randomly dispersed across before get serious counting.
Variance can be detected by looking at the peaks and troughs to see if they're moving even the above
and below this zero horizon.
To check on whether weather forecasters are normally distributed with a mean of zero we can plot histogram
are the forecasters with an overly normal curve but has a mean zero.
In the same standard deviation that's a distribution of the forecasters the plot shows that the distribution
of forecasters is roughly centered on zero and is more or less normally distributed although it seems
to be slightly skewed to the right compared to normal.
However the right skew is rather small.
And so it is possible that the forecasters are normally distributed with a mean zero.
In this case.
So overlaying the normal distribution against the histogram gives us an idea of whether or not this
violation has been or this assumption has been violated.
So our conclusion is that the collision box tests showed that there is little evidence of non-zero correlations
in the sample forecasters and that the distribution of forecasters seem to be normally distributed with
a minimum zero.
This suggests that the simple exponential smoothing method provides an adequate predictive model for
monitoring for which probably cannot be improved upon.
So we've looked at the data.
We decided what a tool to use.
Then from this tool we ran a series of tests in this case and decided that this particular model was
most appropriate to fit the data.
Now let's shift gears and we'll talk about the hits exponential smoothing.
First let's take a look at a dataset for example the time series that can properly be described using
an additive model with a trend and no seasonality is a time series of the annual diameter of women's
skirts at the helm from 1866 to 19 another.
So when we look at this this graph on the y axis we have the diameter of skirts on the x axis.
We have time months we can see from the plant that there was an increase in head diameter for about
600 in 1866 to about 10 50 in 1880 and then after words become diameter decreased to about 520 in 1911
so as we're looking at skirts and the fashion in the time we see this general trend increase where we
have these wider homes and then over time we find that they kind of fall out of fashion and then the
if we have a time serious that can be described using an additive model with increasing or decreasing
trend and no seasonality we can use Holt's exponential smoothing to make short term for forecasts halts
exponential smoothing estimate to the level and slope at the current time point smoothing is controlled
by two parameters alpha for the estimate of the level at the current highpoint and beta for the estimate
of the slope B of the trend component at the current time.
As with simple exponential smoothing the parameters alpha and beta have values between 0 and 1 and values
that are close to zero mean that little weight is placed on the most recent observations when making
forecasts of future values
to make forecasts we can fit a predictive model using the hold winter's function in our to use Holt
winters for Holt exponential smoothing.
We need to set the primer gamma equals false the gamma parameter is used for Holt Winters exponential
smoothing as described below.
For example to use holds exponential smoothing to fit predictive model for the skirt hem diameter.
We take in our cold winter skirt series and then outright specifying camera equals false the estimated
value of alpha.
In this example is zero point eight four and beta is 1.
These are both high.
And that tells us that both the estimate of the current value of the level end of the slope be of the
trend component are based mostly upon very recent observations in the time series.
This makes good intuitive sense since the level and the slope of the time series both change quite a
lot over time.
The value of the sum of squared errors for the example forecast errors is sixteen thousand nine hundred
fifty four.
So when we look at the shape of this graph and we see that it looks like a roller coaster it's constantly
evolving.
What we're finding is that the alpha and beta going being close to 1 in this example are looking at
closer observations more recent observations when it's making its projection moving forward.
And this makes sense when we look at the data
we can plot the original time series as bromine with a forecasted values as a red line on top of it.
We can see from the picture that the NCAA will focus agreed pretty well with the observed values.
Well that they tend to lag behind the observed values just a little bit.
So we've been looking at our growth in this example.
We find that this exponential smoothing method works rather well.
The forecasts are shown as a yellow line with the 80 percent prediction models.
So if I'm looking at this data it also family me it looks a little more compact because of the size
of the prediction intervals in this this example.
But this is the same data that we have.
We can see the development of our red line and the possible errors in there or our confidence at the
80 percent level.
And as for simple exponential smoothing we can make forecasts for future trends not covered by the original
time series.
By using the forecast out of Winter's function in the forecast our package so for example our time series
data for skirt homes was from 1866 to nineteen Clinton and we can make predictions.
It's from the 1912 to 1930 which are nineteen more data points nineteen I specified nineteen data points
in example and we can forecast however for how we were to go in this case.
But we're not necessarily limited however it will work in the time series and just predictive analytics
in general the further out we go for our prediction the less likely our predictions will be correct.
That's why we see the polluting effect of our 80 percent prediction in this case because it just becomes
more uncertain we just don't
let's talk about some statistical tests that we can use to continue to improve upon this model S for
simple exponential smoothing.
We can check whether the predicted model could be improved on by checking whether the sample forecasters
show non-zero auto correlations at lengths one to 20.
Here is the coral hologram which shows that the sample or the correlation for the example forecasts
errors at like five exceeds the significance bounds however we would expect one in 20 goggle correlations
for the first one waves to exceed the 95 percent significance both a chance alone.
So when we run our AC function and we have our balance are dotted audience in this case we're looking
for breaches in 20 waves we would expect one of them to reach surely by chance alone.
But since they all fall within that that range for the most part we can say about that to the auto.
Correlation is not an issue here.
As for simple exponential smoothing we can check whether the predictive model could be a proof that
by checking whether or not the sample forecast errors showed a non-zero order since at last 120 for
example for the skirt hem data we're looking at we can make a call around and then carry out those on
the stats by taking phone
despite having the lag equal in five exceed the significant values we would carry out the laws on the
box hence the p value is point 4 7 indicating that there is little evidence of non-zero auto correlations
in the example focus areas.
Atlanta 1 to 20
s for simple exponential smoothing.
We can also check that the forecasters have constant variance over time and are normally distributed
with a mean of zero.
The forecast errors appear to exhibit cause and variance over time.
We can see the peaks and troughs kind of dancing around this middle of the residual
the time clock forecasters shows that the forecasters have roughly constant variance over time the histogram
of forecasters show that it is possible that the forecasters are normally distributed with meaning zero
and constant variance therefore our conclusion is that the bullish on access shows that there is little
evidence of Croatians and the forecasters.
While the time of history and the forecasters showed that it is plausible that the forecasters are normally
distributed with a mutual and constant variance.
Therefore we can conclude that holds exponential smoothing provides an adequate predictive model for
screwed him diameters which probably cannot be improved upon.
So as before when one needs statistical tests just to make sure that the model that proclaimed in fact
works correctly because it passed these statistical tests.
We can draw some conclusions on that
now we're going to move into the topic of health which is exponential some the
lets you can look at the following sales in this example.
These are monthly sales for a souvenir shop at a beach resort town in Queensland Australia.
So the y axis is the number of souvenirs that have been on the x axis is the time in months in this
case it appears that the habit of call is not appropriate for describing a time series because the size
of the seasonal fluctuations and random fluctuations seem to increase with a level of the time series.
And that's important so when we're looking at the time series we have to make some assessments in terms
of the general shape and trend in this case and because it increases almost exponentially.
In this case on that additive models don't seem to make a whole lot of sense in this case as a result
we may need to adjust this multiplicative time series in order to get a transform time series.
That can be described using a negative model.
For example we can transform the time series by calculating the natural log of the original data
when we transform the time series by up a virtual log of the original data.
We get the graph on the right hand side and by looking at this graph we see that it's no longer has
this giant exponential growth pattern that it's actually a little more consistent with the other datasets
that we've been looking at.
We can see that the size of the seasonal fluctuations and random fluctuations in the long transform
textures seem to be rough and constant over time and they don't depend on the level of the time series.
So this launch transform tasters can probably be described using an additive model this chart can be
described as having a increasing or decreasing trend season in what
if we have a time series that can be described using an additive model with increasing or decreasing
trend and seasonality.
We can use the whole winter's exponential smoothing to make short term forecasts hold Winters exponential
smoothing estimates the model slope and seasonal component.
At the current time point smoothing is controlled by three parameters alpha beta and gamma for the estimates
of the level slope be of the trend component in the seasonal component respectively.
At the current time point the parameters alpha beta and gamma all have values between 0 and 1 and the
values that are close to term mean that relatively little weight is placed on the most recent observations
when making forecasts of future values
to make forecasts we can fit a predictive model using the hot Winters function were
the estimated values of Alpha Beta and Gamma are zero going for one zero point zero and zero point ninety
six respectively.
The value of the alpha zero point for one is relatively low indicating that the estimate of the level
at the current high point is based upon both recent observations and some observations in the more distant
past.
The value of beta is zero indicating that the element of the slope of the trend component is not updated
over the time series and instead it is set equal to its initial value.
This makes good intuitive sense as the level changes quite a bit over time series but the slope of the
trend component remains roughly the same.
In contrast the value of Gamma zero point six is very high indicating that the estimate of the seasonal
component at the current time point is just based upon a very recent observations.
As for a simple exponential smoothing and halts exponential smoothing we can plot the original time
series as a brown line with the forecasted values as a blue line on top of that we see from the plot
that holds metrosexual expert central method is a very successful method in predicting the seasonal
peaks which occur roughly in November every year.
So just the shape of the line seems to mimic what we see in the data set very well in this case
the forecasts are shown as a blue line and the red dotted lines showing the 80 percent prediction or
false.
I know it's not the easiest to see in this particular example but we can see the trending in the seasonality
component being picked up by this model.
So as we as we are looking at the data series and that's the trend is moving up we see that the model
has actually capture that data rather well
so we can continue to evaluate this approach by performing our statistical tests.
In this case the core with Graham shows that that the auto correlations for the end sample Forecasters
do not exceed the significance bounds for lands one to 20.
So they all fall within these these bones
we can investigate whether the predictive model can be improved upon by checking whether the in sample
forecast here is shown non-zero auto correlations at plans 1 to 20 by making a call hologram and carrying
out foolish on the box test when we run that was on box test in this case the p value is zero point
six million indicating that there is little evidence of nonzero auto correlations it lags one to 20
we can also check whether the forecast errors have counts and variance over time so we're going to plot
our residuals and we're going to look at the spread of residuals across the zero the forecasters appear
to exhibit constant variance over time
from the history of the forecasters it seems plausible that the forecasters are normally distributed
with the mean of zero our conclusion is that there is little evidence of auto correlation at lags of
one to 20 twenty for the forecasters and the forecasters appear to be normally distributed with a mean
of zero and a constant variance over time.
This suggests that hold matters exponential smoothing provides an adequate predictive model with the
log of sales at the souvenir shop which probably cannot be further improved upon.
Furthermore the assumptions upon which the prediction intervals were based are probably valid.
So we've found a good model that fits the state of very well.
Now we're going to switch gears and we're going to talk about Arima models or auto regressive integrated
moving average models
exponential smoothing methods which are the methods that we've discussed earlier are useful for making
forecasts.
And make no assumptions about correlations between successive values of the time series.
However if we want to make prediction intervals for forecast made using an exponential smoothing methods
the prediction intervals require that the forecasters are uncorrelated and are normally distributed
with a mean zero and constant variance while exponential smoothing methods do not make any assumptions
about the correlations between successive values all of the time series.
In some cases we can make a better predictive model by taking correlations in the data into account.
This is what new remodel procedure does or auto aggressive integrated moving average includes an explicit
statistical model for the irregular component of the time series.
It allows for non-zero auto correlations in the irregular component
arena models are defined for stationary time series.
Therefore if you start off with a non stationary time series you will first need to difference the time
series until you obtain a stationary timetables.
If you have the difference the time series de times to obtain a stationary series then you have a PD
Q at all.
D is the order of difference in utilized for example the time series the annual diameter of women's
skirts at the home from 1866 to 1911 is not stationary and meet as the level changes a lot over time.
So if we're looking at this data it kind of looks like a roller coaster.
It's constantly evolving.
This is what the original data set shows over.
If I take a different scene of one the resulting time series of the first sequences does not appear
to be stationary in the mean.
It's still kind of looks like its overall shape but we see that there's a very high peak that starts
on the top and then when we go down car proper to further observations we see it begins to pants around
the knees.
But really most of them are below.
So the difficulty no one point does not appear to be stationary.
In this case
the Times there is other second differences.
Dots appear to be stationary and mean and variance as the level of the series stays roughly constant
over time.
And the variance with the series appears roughly constant over time.
So by shifting from a difference of 1 to 2 when we do a difference of 2 in this case we see this pattern
on the data in this pattern.
Now all seems to be a little more of what we would expect of a residual plot.
If we need to difference our original time serious data details in order to retain stationary time series.
This means that you can use the remote P Q the hole for your time series or two years of the order of
difference of used for example for the time series of the diameter of women's skirts.
We have different detectors twice and so that the order of difference in D is 2.
That means that we can use an arena p 2 to model first series the next step.
Essentially it is for us to figure out the values of p and to further carry the model.
Wanted just to take a look at the different scene again where we're looking at our original dataset
though when we see a different scene of one being applied a difference of 2 being applied.
So we see that the data is transforming and it's melting.
Look across this line.
And so by looking at the actual height difference in the functions we can see how how the patterns are
emerging and how we can use us for Defining what variables to include in the arena model.
Another difference to the time series of first differences appears to be stationary and mean and variance.
And so probably in a remote P one Q model is probably appropriate for the time series but taking the
time series are the first differences we have removed the trend component of the time series of ages
at death of the kings and we're left with the irregular component we can now examine whether there are
correlations between successive terms of this irregular component.
If so this could help us to make a predictive battle for the ages at depths of the King's.
How do we go about selecting a candidate remember if our type series is stationary or if we've transformed
it to a stationary time series by different team D times the next step is to select the appropriate
amount which means finding the values most appropriate values of p q.
Further we look p q Mo to do this we need to examine the core telegram and the personal choral telegram
of the station three time series
here's an example of the ages at death of the kings of England we've produced our choral telegram in
this case for banks of one to twenty on the once different time series we can see from this choral telegram
that the auto correlation at lap 1 exceeds the significant bounds but the other auto correlations between
the 120 don't exceed the significant spellings remember we're looking for the bars of the histogram
to remain within this particular function.
And since we had one of the 20 breach that caused that barrier we can say that can happen from church
hands alone.
OK.
So I don't think that to that we're having an issue in terms of the difference in equal one in this
case
if our example of the ages at death of the kings of England looking at our personal auto correlation
function we plant the partial called Telegram for lives of one the twenty for the one's different time
series of the age ages had the death of English kings and we get the values of the personal auto correlations
the personal choral telegram shows that the personal auto correlations at LAX one two and three exceed
the significance bounds are negative and are slowly decreasing in magnitude with increasing lag so lag
one is minus zero point three six like two is minus point three three five length three is minus point
three to one the partial auto correlations tail off to zero after lag three
no can we spent some time evaluating the core lower gram and the personal core MG We need to select
a candidate a remote for armament
a remote a PD our armor is similar except for it's just a p q mobile so what can sensitively gain from
looking at the Carlyle Group and personal call okay.
Well since the ECF zero after lap 1 and the pace he f tails off to 0 from a 3.
This means that the following Arma models are possible for the time series first differences so we can
have more than one candidate model.
In this example in order to find that we have three we can use in our mind 3 0 now which is an auto
aggressive model of order p equals 3.
Since the personal auto calling and 0 after length 3 and the auto call over in tails off to 0 although
perhaps too abruptly for this model to be appropriate.
You can use an Amo and saw a model that is a moving average model of order q equals 1.
Since the auto Coraline Abram is 0 after Maclin in the personal auto core MG tells off to 0.
And finally we can use an army peak level that is a mixed model with P and Q greater than 0.
Since the auto core level then impersonal call gram tail off to zero although the core telegram probably
tails off to 0 to a roughly for this model to be appropriate.
To decide which model to use we're going to invoke the principle of parsimony we have three models.
We have an army of 3 our model.
We have an arm 0 0 1 now.
We have an arm a P Q and what we're looking for here is the model with the least amount of complexity
to it.
Since the Arma 3 0 metal has three parameters it's fairly complex.
The arm of each member has at least two parameters.
It's also somewhat complex but the AMO zero one only has one president and therefore we're going to
use the Arma 0 1 model is taken as the best mountain
since in ArmA 0 1 model with a P equals zero cuticles one is taken to be the best candidate model for
the time series of first differences of the agents at depth.
I think most Kings from the original time series of the ages of death can be amount of using and are
remote.
0 1 1 model with P coin 0 d equaling 1 for a difference in 2 equals 1 where D is the order of differences
required required a moving average model is usually used to model 10 series that shows short term dependencies
between successive observations.
Intuitively it makes good sense that a moving average model could be used to describe the irregular
component in the time series of ages.
At other those schemes as we might expect the age of a particular in the scheme to have some effect
on the ages of the death of the next king or two but not much effect on the ages at death of kings that
reign much longer than that.
So there is going to be an impact close in between the lives of certain kings but when we start looking
at the King that lived 300 years ago compared to a king that declared in twenty years ago that the gap
is going to be more significant from the 1 300 years ago and the relationship of the trending party
should should be less significant as we span across that amount of time.
So let's get into another arena.
Example the volcanic dust veil index for the Northern Hemisphere from fifteen hundred to 1969.
This is a measure of the impact of volcanic eruptions.
The release of dust and aerosols into the environment from the time period it appears that the random
fluctuations in the time series are roughly constant in size over time so an inactive model of what
is probably appropriate for describing this time series
furthermore the time series appears to be stationary mean and variance as its levels and variants appear
to be roughly constant over time.
Therefore we do not need to different the series in order to fit normal model but can't fit Arima model
to the original series.
The order a different to acquire D 0 here.
In this case we can now plot a coral hologram and partial coral more than four miles one to twenty to
investigate.
What are we model teams.
We see from the coral holograms that the Argo correlations four legs 1 2 and 3 you exceed the significant
sounds and that the auto correlations tail off to zero after leg 3.
The auto correlations from lands 1 2 and 3 are positive and decrease in magnitude with an increasing
lag.
So make one the Zero Point success like two is zero point 3 7 4 lag 3 is zero point 1 6 2 the auto correlation
4 makes 19 and 20 exceed the significant bounds 2 but it is unlikely that this is due just a chance
since they exceed the significant bounds especially for leveling team the auto correlations for lengths
for defeating do not exceed the significance bounds we would expect one in 20 bags to exceed the 95
percent significance bounds by chance alone.
From the personal auto core MG We see that the personal auto core MG at 5 1 is positive and exceeds
the significant amount zero point six of six.
While the personal auto correlation they have linked to is negative and also exceeds the significant
bounds but minus zero point one 2 6 personal auto correlations tail off to zero after 9 to
so we're talking about selecting which candidate our model like before.
Since the calling win tails off to zero after leg 3 and the partial call hologram is zero effort like
to the following calmer models are possible for this time zero.
We have an arm a tumor
we have an item on the 0 3 map and we have our Herman p q mixed model
evoking our principle of parsimony.
We look at it from a teaser now having two parameters Arma 0 3 having 3 parameters and Palmer P Q Having
at least two parameters.
Therefore we can say that you're either using an ARMA 2 0 model or an armor P to model are equally good
candidate models
if an hour or 2 0 with p equals two and two equals zero is used to model the time series of volcanic
dust Vale index.
That would mean that the AMO 2 0 0 model can be used with p equals too deep equals zero and Q equals
zero.
Working is the order of differences required.
Similarly if in armor p q mixed models used were p. m. Q are both greater than zero then an R remote
p zero Q model can be used as well.
An auto aggressive model is usually used to model time series which shows a longer term discrepancies
between successive summations intuitively it makes sense that in car model could be used to describe
the time series of volcanic dust failing does as we would expect volcanic dust and aerosol models in
one year to effect those in much later years since the dust and aerosols are unlikely to disappear quickly.
Now we're going to get into some examples of forecasting using arena models.
So let's go back in taken if we take a look at our example of the ages at death of the kings of England.
Once we've selected the best candidate a Rima pedi to model for your time series then you can estimate
the parameters of the Rima model and then use that as the basis for our predictive model to create our
forecast.
For example we discussed that in our Rima 0 1 1 model seems a plausible model for ages at us of the
kings of England
we can plant the observed ages of death for the first 42 Kings as well as the ages.
That would be predicted for these forty two kings and for the next five kings using our prima 0 1 1
model.
Now we're not limited to just five kings and this is just when I had specified in the model as in the
case of exponential smoothing methods.
It is a good idea to investigate whether the forecast errors of an arena model are normally distributed
with mean zero and constant variance in weather that had these correlations are between the success
of forecasters.
For example we can make a call hologram of the forecasters using our remains or open one model for the
ages at death of kings and perform the illusion box test for LAX one at 20 by typing the following.
The p value for the on the box test is zero point eighty five 1 indicating that there is little evidence
of nonzero order correlations at last one to twenty
the core hologram shows that none of the sample correlations four legs and one to twenty exceed the
significance found also the p value for those on box test is zero point eight in which we can conclude
that there is very little evidence for non-zero order correlations in the forecast terrorist at lengths
one to twenty
we can check whether the forecasters have constant variance over time into enter normally distributed
with mean 0 by making a timeline of the forecasters into his room with overlaid normal curve
the time part of the end simple forecasters shows that the variance of the forecasters seems to be roughly
constant over time though perhaps there is a slightly higher variance for the second half of the time
series.
The histogram with the Times series shows that the forecasters are roughly normally distributed in the
mean seems to be close to zero.
Therefore it is possible that the forecasters are normally distributed with means or in constant variance
our conclusion is that since successive focus has not seem to be correlated and that the focus here
seem to be normally distributed with mean zero and constant variance the Rema 0 1 1 model does seem
to provide an adequate predictive model for the ages at traffic in most cases
nothing.
We've got about this let's go ahead and type into a practical application example going to the forecast
product sales quantity
before we begin let's go ahead and first try to understand a little bit about the dataset we're working
month.
This is a very common example that we're going to see in business applications where I have sales of
a product over a given span of time.
So in this case I'm looking at it just two pieces of information the time represented in months and
the quantity of a particular product.
So what does this time series graph.
Before we begin let's first decompose the time series.
So in order to further isolate which algorithm to use for this analysis let's let's just look at these
components.
We see if the trend component in this case can clearly be shown it's an upward trend that's stabilizing
over time.
There is a regular seasonal component that we see which almost kind of looks like a little heartbeat
pattern to end.
There is a random component of the data in this random component reaches a peak of thirty five hundred
units to a trough of minus forty five hundred units the gap with the spread is wide enough that we probably
should use in a remote p q model in order to capture this noise in our final analysis
so now we're going to go about difference in the time series.
In this example we're going to use a different scene of one and just see how the data looks at the time
series such as the first difference does appear to be stationary and mean and variance.
Since we had the difference the time series once and so the order of different scene of D is equal to
1.
This means that we can use in our remote P one Q model for four times heroes.
The next step is to figure out the values of p q for the original model.
There is a technique in our called Auto Auriemma which we identified the best candidate Karima PD Q
based upon some valuation parameters okay the default in this technique is the cocky information criterion
her AIC
when we process this technique the resulting model is an agreement 0 1 1.
No.
Please note that we can actually go and evaluate the ECF.
The piece off the box along with wrong test etc. using the techniques outlined in the presentation but
we'll skip this evaluation for brevity sake
now that we've done this work.
You can go about charting this line chart onto the graph so we can forecast moving forward into a period
and see the resulting product.
Estimated quantities in our example we extended the forecast now for an additional twelve months.
The final forecast takes into consideration our seasonal variations involving macro micro trends of
this product.
Leverage is the random noise when built in the quantity estimates the final estimate it seems predictions
can be leveraged to terminal procurement requirements.
Sales budgets incomes etc cetera
let's say you talk a little bit out time series and use using a generalized at least square mile.
There are many instances where we are interested in not only predicting the development of a time series
citizen but we also want to understand how individual independent variables acts in this case impact
the dependent variable Y.
Spanning across time for example sales development over time taking GDP unemployment rate and other
variables into account.
So econometric analysis of time series data we would naively initially approach this task using the
standard oil as linear regression model with a form of Y equals intercept plus beta 1 X1 plus beta 2
x2 plus so on so forth.
And finally the error term and we get into a very detailed discussion about all of us in her regression
tutorial earlier on.
So if you need a refresher on those techniques please feel free to check out that presentation.
One important thing to note because a critical assumption when building with oil is regression is that
the errors are homo scholastic and serially correlated.
It is common when working with time series data that the errors are unlikely to be independent and are
serially correlated.
Therefore it's important to understand that as well as regression will not be sufficient.
With modern times series DFA this is an important concept too because when we're working with regression
we're used to using our lives we're going to show that we needed to take a different approach when working
the paint series in order to address the serial correlation issue.
We can employ a generalized with squares model fit by maximum likelihood.
This approach focuses on resolving some of the underlying concerns with the error term there are some
standard models for auto correlated questionnaires with the most common in the first order auto aggressive
process.
They are worked
the t rex since the random shots and are soon to be counseling white noise and it represents the correlation
the what this is doing is it's taking the error term and it's breaking down the error term into two
subcomponents so you can think of this much like columns a proton in the in the act.
Well it's made up of quotes in this Eric term in office regression just represents the difference between
our Observer an actual count but there are even more fundamental components that are important to understand.
And times hearings
if they are to back or on the other end him continues this process.
Breaking the error term down and we now see that particular 5 1 was the error.
T minus one plus five to their term T minus two plus 15
in contrast in the first order moving average passes I mean 1 the current error depends upon the random
shock from the current and previous periods rather than Palin but the previous regression error.
So if I'm looking at the main one model versus in any two model you can see the phone.
Finally a car in a main terms can be combined in a R made P2P processes
therefore in a remote or an hour mode 1 1 model is a hybrid
now we have a basic understanding of HLS approach.
Let's work through an example.
Here's the heart Nakhle dataset from 1931 to 1968 a different macro economic attributes of women in
Canada.
And for those who have followed along the series in our neural network tutorial we touched upon this
dataset there.
But if you haven't seen it and this is the first time you're looking at this dataset on just go in to
a brief description of some of the variables we have a variable that represents the year a variable
that represents the total fertility rate of births per thousand women.
Then we can in some metrics that are related to individual items such as their labor force participation
rate their post-secondary degree rate indictable offence conviction rate and then their theft conviction
rate for control purposes.
We also include some interest related to men so such as their indictable offence conviction rate and
their theft conviction rate.
What we're trying to do is we're trying to estimate the variable R F comfort on TFR Partick degrees
and M. comfort for the rational for including the M convict variable it is to control for omitted variables
that affect the crime rate in general.
So let's sort of go ahead and be a
folk type into the model itself.
Let's just take a look at the shape of our time series plot.
Now the data set does not appear to have any seasonality components.
However we could decompose the time series and seasonally adjusted data set to ensure that we're only
focusing on the trend in random components.
We talked about that seasonally adjusting earlier in the presentation and that is something that we
could do before we go along with the modeling aspects so we can incorporate other of other techniques
into our time series work.
So let's go ahead and first run a multiple linear regression.
Wouldn't we run this to the women's crime rate appears to have climbed with fertility and increase with
labor force participation.
The other two coefficients are statistically insignificant the r squared metric shows zero point 6 9
4 8 which is a fairly strong value and indicates that the model is capable of predicting a large portion
of observations.
And if you want to understand what what these metrics mean please go through the OSA tutorial earlier
on regression analysis
in some previous tutorials and our EDTA tutorial and our regression analysis true.
We got into the concept of a residual plots and how to detect errors within the residual plot but nothing
we've created our whole last model.
I want to show how we can use the residual what residual plot to detect auto correlation.
If we look at this plot we notice that the residuals are not uniform and they're randomly distributed
across the zero line.
This can be observed by the large peak and troughs that we see additionally.
There seems to be a direction the residuals that are moving upward indicating that serial correlation
is a problem and that this all adds regression violates statistical assumptions.
So the general shape of the dots moving in direction is a visual indicator that we can use for detecting
serial conflict with the correlation or auto correlation.
So when you're looking at residual pundits we look for this pattern as well.
Now that we've determined that all our super regression cannot be used in this case what we needed to
call the how determine what model or approach we should use like the examples before we need to create
the ECF and PCR caught our rooms and examine them in detail.
However we need to look carefully at the patterns of each one to determine which model approach a higher
P and a Q or a RNA p q makes most sense for the GLAAD approach the reference chart that we have here
can be used as a general guideline for this evaluation.
So when you're looking at creating this regression analysis over time series and you're not sure exactly
how to evaluate the ATF and PCR if we need to go back and refer to this slide.
Okay.
This is very helpful for me.
When I first started working at time series it was difficult for me to understand exactly what model
I should be using where.
So just remember if I need to understand the specific variables related to time series and decide which
approach to use come back to this slide it will help you out.
So I produce the core of holograms the ECF and P.S. F and I evaluate the spread across the legs.
In this case the ATF diagram shows an exponential decay to link to where it is a sign of sodium or a
pattern in the piece he had to show significantly before dropping to zero at lag to this indicates that
the AARP approach should be used and pay a S.F. showed a drop to zero at Lady 2.
Therefore we will use the R to map for our analysis
we follow up by computing the Durbin Watson statistics for all s or regression.
This function produces bootstrapped p values for the Durbin Watson statistics three of the first five.
Durbin Watson statistics are significant including the first this indicates that auto correlation is
present in the dataset and will be improved upon through nano modelling methods.
So so we suspect that serial correlation or auto correlation exists run the Durbin in test
know that we've produced the model.
Let's go ahead and take a look at the model fit for GSR model some observations is that the fi one is
equal to one point 0 6 8 3 5 5 2 is minus zero point five 5 1 which is what we expect expected that
a 5 1 is to be greater than 0 5 2 to be less than 6 0 the M.S. or the M convict's variable was not statistically
significant and the Alice model but it is significant in the GM asthma.
So this just shows you that using a different regression technique can provide a different insights
in terms of variables and their statistical significance in the eye cocky information criteria AIC is
3 0 5 4 1 and so lower values indicate stronger models.
So if we're using this model over and over with different types of variables we're looking for models
that have a lower AIC
to verify that the R2 model once the preferred model we reran the models for error 0 Carawan in error
3 and then we performed ANOVA and we got into the topic of ANOVA analysis in earlier lectures the same
lecture that has our linear regression analysis so please refer back to that if you want a primer and
in this case the AIC is the lowest for the air to model three or five point four one four followed very
closely by error 3 2 3 0 7 point 4 0.
So if we follow the principle of parsimony the air to model is less complex and therefore should be
used as our final model.
So let's take a look at our final jealous model.
So here is an extract of the model fit in some statistics that we have here some additional changes
are that we remove the intercept and the degree variables and the a cocky information criteria AIC is
three or four point five nine compared to three or five point four one
now that we have this.
Let's take a look at how our model fits.
We can see the actual observed values with the blue line and now we can use our Geo Quiz prediction
using our orange dotted line.
Furthermore we actually have a regression equation that we can draw from.
So if we want to talk about how specific variables impact on this we now have our conviction rate equaling
minus zero point zero to four times the fertility value plus zero point 3 0 4 times the labor value
plus zero point one zero times the male convict plus the error term in this case the error term is one
point one 5 four times there T minus one minus zero point five three times the error term T minus two
plus if you 15.