0% found this document useful (0 votes)
16 views28 pages

Intro To Time Series

Uploaded by

zhuzhaodong23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views28 pages

Intro To Time Series

Uploaded by

zhuzhaodong23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Introduction to Time Series Analysis

ST534

Donald E.K. Martin


North Carolina St. U.

August 21, 2022

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 1 / 28
Outline

1 Definitions

2 Examples of time series

3 Goals of time series analysis

4 Approaches to analyzing time series


Time domain analysis
Frequency domain analysis

5 Introduction to SAS software

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 2 / 28
Definitions

A stochastic process is a collection of random variables


{Z (t), t ∈ T }, where T is the index set over which the process
is defined.

A time series is a stochastic process for which the index set T


represents time. Thus a time series is a collection of random
variables observed sequentially in time.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 3 / 28
Continuous and discrete time series

A time series is continuous when observations are made


continuously in time.

A time series is discrete when observations are taken only at


specific time points, usually equally spaced, e.g.
t = 0, ±1, ±2, . . . .

We will be concerned with discrete time series, measured at


equally spaced time intervals.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 4 / 28
How discrete time series arise

Discrete time series can arise in various ways:

Sampling a continuous series at equal intervals of time

Aggregating values over an interval of time, such as monthly


exports data or the amount of rainfall at a particular location
during successive days

Some series are inherently discrete, such as the amount of


interest on a bank account in successive months.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 5 / 28
Ordering of observations

In time series, the data values are ordered through time,


beginning with the earliest time period and proceeding to the
latest.

The time ordering is important, for the observations are typically


correlated, and not independent.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 6 / 28
Dependence

Dependence in time series data is called autocorrelation


(dependent relationships between successive observations on the
same variable), or crosscorrelation, where the dependencies are
for different variables.

Time series analysis is basically concerned with techniques for


the analysis of dependence between observations. One seeks to
understand or model the underlying data generation mechanisms.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 7 / 28
Examples of time series in business and economics
Corporate planning data related to:
i Capital expenditures
ii Company sales
iii Earnings
iv Economic indicators

Financial planning data on:


i Budgets
ii Cash flows
iii Expenses
iv Inventory levels
v Interest rates
vi Prices
vii Sales revenue

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 8 / 28
More examples of time series in business and
economics
Marketing data on:
i Consumer trends
ii Market shares
iii Prices
iv Product sales
v Sales revenue

Production data related to:


i Inventory levels
ii Labor costs and requirements
iii Material costs and requirements
iv Plant utilization
v Product demand
vi Shipments
Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 9 / 28
Other time series

Continuous monitor readings of a person’s heart rate

Physical time series: average monthly temperatures, ozone


levels, daily rainfall data

Sports statistics over days, months, seasons

Demographic data related to population, births, deaths, etc.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 10 / 28
Goals of time series analysis

Description of the series

Explanation of variation in the series

Forecasting

Intervention and outlier analysis

Statistical process control

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 11 / 28
Description of the series

Various methods are used to note the series’ main features.


Plotting is a basic method that allows one to see features such
as seasonal effects, trends, outliers, etc.

The time series may be decomposed into various components,


including a seasonal, trend, and irregular (noise) components.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 12 / 28
Explanation of the series

When observations are taken on two or more variables, it may be


possible to explain variation in one series using variation in
another series.

For example, one may want to see how sales are affected by
price and economic conditions.

A transfer function model (a dynamic input-output model that


can show the effect on the output of the system of any given set
of inputs) is set up for this purpose.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 13 / 28
Intervention analysis and outlier detection

In intervention analysis, we try to determine the effect of an


external event, such as the eruption of a war, a hot or cold wave,
a strike, sales promotion, policy change, etc., on the time series.

It could be that the timing and cause of an interruptive event is


unknown. In that case, a method to determine the presence of
disruptions to the time series, which could cause outliers
(unusual observations), is useful.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 14 / 28
Forecasting

Forecasting involves:

Prediction of future values

An assessment of uncertainty associated with the prediction

A description of the method and assumptions used in deriving


the forecast

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 15 / 28
Statistical quality control

Here the process is monitored to determine when it is out of


control in the sense that it deviates too far from its target value.

In that case, the process is adjusted to remove identifiable


sources of variation.

Statistical process control is the topic of ST435.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 16 / 28
Approaches to analyzing time series
Plotting the data to examine the series visually

Decomposing the data into various components

Time domain methods

Frequently domain methods

Time series analysis typically requires statistical software.

At times, combinations of methods are used. As examples, data is


typically plotted before models are fit. Also, one may determine
trend, seasonal and irregular components through filtering, and then
fit a model to the irregular component.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 17 / 28
Time domain analysis
In this method, filtering techniques (for example differencing the
series) are used to obtain a stationary time series.

A probability model is fit to the stationary time series.

Diagnostic tools such as the autocorrelation and partial


autocorrelation functions are used in setting up the probability
models, which are called ARMA models.

The main method that we will examine was developed by Box


and Jenkins.

The derived model is then used to carry out tasks, for example
forecasting future values.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 18 / 28
Frequency domain analysis

In the frequency domain approach, fluctuation in the time series


is represented as a function of sine and cosine waves at various
frequencies.

Similar to the time domain approach, diagnostics may be used


to determine an appropriate model for the data.

The main diagnostic used is the Fourier transform of the


autocorrelation function, and thus the time and frequency
domain approaches are related and carry similar information.
The two approaches, however, look at the data from two
different perspectives.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 19 / 28
Data plots
Plotting the data is typically a first step in analyzing a time
series.

We look for basic features such as stationarity, and deviations


from stationarity through seasonal fluctuations, a trend, outliers,
etc.

Before plotting data, decisions need to be made on the scale for


the axes and the way the points are plotted (as a continuous line
or separate dots).

Some software packages take care of these decisions


automatically.

We will be using SAS, but one can use other software packages.
Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 20 / 28
SAS program steps

SAS programs are made up of ”steps.” A program can contain


one step; it could contain 100 steps.

There are two kinds of steps: DATA steps and procedure (or
PROC) steps.

Programs can also contain global statements that affect things


like system options, titles, etc.

Steps in a program are executed sequentially.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 21 / 28
SAS program statements
Your SAS program is made up of one or more SAS statements. The
following are rules for writing these statements:

Statements begin with a keyword and end with a semicolon.

Statements may be broken over two or more lines, or two or


more statements may be written on the same line.

Uppercase and lowercase letters may be used in any combination.

Any number of blank lines may appear between statements.

Statements may be indented to start at any position on a line.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 22 / 28
Data step

Data is entered during a SAS data step.

You can think of a SAS data set as a two-dimensional table or a


matrix, with rows representing observations and columns
representing variables.

Most formats can be converted into SAS data sets, including


spreadsheets and text files.

SAS data sets are formed in one of two ways: either instream or
by reading it in from an external file. We illustrate both methods
next.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 23 / 28
Instream data entry
DATA SALES;
Length Name $ 20; /* (allows length 20) */
Input Name $ Custnum $ Amount; /* (Name and Custnum are
character variables) */
cards;
Thomas 40350 3670.45
Thomas 40990 958.89
Thomas 40350 1258.06
Thomas 35118 335.93
Wu 87764 9761.00
Wu 71410 756.45
Walters 71833 5723.12
Christopherson 45280 6374.21
Christopherson 45280 289.17
Christopherson 45280 3074.31
;
Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 24 / 28
Instream data entry (continued)

RUN; /* (ends data step) */

TITLE ’SALES LIST’;

PROC PRINT DATA=SALES;


SUM AMOUNT; /* computes the sum */
RUN;

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 25 / 28
External data file

FILENAME PATDATA ’c:\clinic\visits.dat’; /* gives the (nickname


PATDATA) */

LIBNAME MYLIB ’c:\sasdata’; /* (gives the nickname MYLIB for


’c:\sasdata’) */
DATA MYLIB.PATIENTS; /* (SAS dataset created in MYLIB) */
FORMAT VISITDAY DATE7.; /* (how displayed; 7 columns for
VISITDAY e.g. April 20, 1993 is shown as 20APR93) */
INFILE PATDATA; /*(names external file for input) */

INPUT VISITDAY PATIENTS CATEGORY;

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 26 / 28
External data file (continued)

RUN; * (ends and executes data step);


TITLE ’Patient count’;

PROC PRINT DATA=MYLIB.PATIENTS;


sum PATIENTS;
RUN;

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 27 / 28
PROC step

A PROC is a program written for you by SAS Institute.

Each PROC performs a different data processing function.

There are procedures to sort data, plot data, perform regression


analysis, count occurrences, etc. In a single SAS program you
can use any number of PROC and data steps.

Donald E.K. Martin (North Carolina St. U.) Introduction to Time Series Analysis August 21, 2022 28 / 28

You might also like