Using R for Time Series Analysis R is a package that can be downloaded for free.

Slides:



Advertisements
Similar presentations
Statistical Time Series Analysis version 2
Advertisements

FINANCIAL TIME-SERIES ECONOMETRICS SUN LIJIAN Feb 23,2001.
SMA 6304 / MIT / MIT Manufacturing Systems Lecture 11: Forecasting Lecturer: Prof. Duane S. Boning Copyright 2003 © Duane S. Boning. 1.
Autocorrelation Functions and ARIMA Modelling
Time Series Analysis Definition of a Time Series process
Autoregressive Integrated Moving Average (ARIMA) models
Stationary Time Series
Time Series Analysis -- An Introduction -- AMS 586 Week 2: 2/4,6/2014.
Chapter 4: Basic Estimation Techniques
Dates for term tests Friday, February 07 Friday, March 07
DSCI 5340: Predictive Modeling and Business Forecasting Spring 2013 – Dr. Nick Evangelopoulos Exam 1 review: Quizzes 1-6.
© Department of Statistics 2012 STATS 330 Lecture 32: Slide 1 Stats 330: Lecture 32.
Part II – TIME SERIES ANALYSIS C4 Autocorrelation Analysis © Angel A. Juan & Carles Serrat - UPC 2007/2008.
Model Building For ARIMA time series
Part II – TIME SERIES ANALYSIS C5 ARIMA (Box-Jenkins) Models
Slide 1 DSCI 5340: Predictive Modeling and Business Forecasting Spring 2013 – Dr. Nick Evangelopoulos Lecture 7: Box-Jenkins Models – Part II (Ch. 9) Material.
Time Series Building 1. Model Identification
R. Werner Solar Terrestrial Influences Institute - BAS Time Series Analysis by means of inference statistical methods.
Economics 310 Lecture 25 Univariate Time-Series Methods of Economic Forecasting Single-equation regression models Simultaneous-equation regression models.
STAT 497 LECTURE NOTES 8 ESTIMATION.
How should these data be modelled?. Identification step: Look at the SAC and SPAC Looks like an AR(1)- process. (Spikes are clearly decreasing in SAC.
Modeling Cycles By ARMA
NY Times 23 Sept time series of the day. Stat Sept 2008 D. R. Brillinger Chapter 4 - Fitting t.s. models in the time domain sample autocovariance.
ARIMA Forecasting Lecture 7 and 8 - March 14-16, 2011
Financial Econometrics
Correlation and spectral analysis Objective: –investigation of correlation structure of time series –identification of major harmonic components in time.
BOX JENKINS METHODOLOGY
AR- MA- och ARMA-.
STAT 497 LECTURE NOTES 2.
#1 EC 485: Time Series Analysis in a Nut Shell. #2 Data Preparation: 1)Plot data and examine for stationarity 2)Examine ACF for stationarity 3)If not.
Intervention models Something’s happened around t = 200.
Slide 1 DSCI 5340: Predictive Modeling and Business Forecasting Spring 2013 – Dr. Nick Evangelopoulos Exam 2 review: Quizzes 7-12* (*) Please note that.
Autoregressive Integrated Moving Average (ARIMA) Popularly known as the Box-Jenkins methodology.
It’s About Time Mark Otto U. S. Fish and Wildlife Service.
John G. Zhang, Ph.D. Harper College
Data analyses 2008 Lecture Last Lecture Basic statistics Testing Linear regression parameters Skill.
FORECASTING. Minimum Mean Square Error Forecasting.
K. Ensor, STAT Spring 2005 Model selection/diagnostics Akaike’s Information Criterion (AIC) –A measure of fit plus a penalty term for the number.
Introducing ITSM 2000 By: Amir Heshmaty Far. S EVERAL FUNCTION IN ITSM to analyze and display the properties of time series data to compute and display.
1 Chapter 3:Box-Jenkins Seasonal Modelling 3.1Stationarity Transformation “Pre-differencing transformation” is often used to stablize the seasonal variation.
Time Series Basics Fin250f: Lecture 8.1 Spring 2010 Reading: Brooks, chapter
LINREG linreg(options) depvar start end residuals # list where: depvar The dependent variable. start endThe range to use in the regression. The default.
STAT 497 LECTURE NOTE 9 DIAGNOSTIC CHECKS 1. After identifying and estimating a time series model, the goodness-of-fit of the model and validity of the.
MULTIVARIATE TIME SERIES & FORECASTING 1. 2 : autocovariance function of the individual time series.
Case 2 Review Brad Barker, Benjamin Milroy, Matt Sonnycalb, Kristofer Still, Chandhrika Venkataraman Time Series - February 2013.
Linear Filters. denote a bivariate time series with zero mean. Let.
1 Chapter 5 : Volatility Models Similar to linear regression analysis, many time series exhibit a non-constant variance (heteroscedasticity). In a regression.
Module 4 Forecasting Multiple Variables from their own Histories EC 827.
Seasonal ARIMA FPP Chapter 8.
ESTIMATION METHODS We know how to calculate confidence intervals for estimates of  and  2 Now, we need procedures to calculate  and  2, themselves.
Ch16: Time Series 24 Nov 2011 BUSI275 Dr. Sean Ho HW8 due tonight Please download: 22-TheFed.xls 22-TheFed.xls.
Univariate Time series - 2 Methods of Economic Investigation Lecture 19.
Analysis of financial data Anders Lundquist Spring 2010.
Review of Unit Root Testing D. A. Dickey North Carolina State University (Previously presented at Purdue Econ Dept.)
Lecture 12 Time Series Model Estimation Materials for lecture 12 Read Chapter 15 pages 30 to 37 Lecture 12 Time Series.XLSX Lecture 12 Vector Autoregression.XLSX.
ESTIMATION METHODS We know how to calculate confidence intervals for estimates of  and 2 Now, we need procedures to calculate  and 2 , themselves.
Chapter 4: Basic Estimation Techniques
Chapter 4 Basic Estimation Techniques
Covariance, stationarity & some useful operators
The General Linear Model
Chapter 6: Autoregressive Integrated Moving Average (ARIMA) Models
Model Building For ARIMA time series
STAT 497 LECTURE NOTE 9 DIAGNOSTIC CHECKS.
The General Linear Model (GLM)
The general linear model and Statistical Parametric Mapping
Linear Filters.
The General Linear Model (GLM)
ESTIMATION METHODS We know how to calculate confidence intervals for estimates of  and 2 Now, we need procedures to calculate  and 2 , themselves.
The General Linear Model
BOX JENKINS (ARIMA) METHODOLOGY
Presentation transcript:

Using R for Time Series Analysis R is a package that can be downloaded for free

When R is opened

To read in data from a file: Type > sunData<-read.table("C:/Users/User/Desktop/Sunspot.txt",header=TRUE) The name of the data or table The file name and file path Read the variable names The following line causes the data to be printed > sunData Year no

To plot a scatter plot of the data type: > plot(sunData[,2]) or > plot(sunData[,”no”])

To plot a line graph of the data type: plot(sunData[,”no”],type = "l")

To plot a line graph of the data with “Year” along the horizontal axis type: plot(sunData[,”Year”],sunData[,”no”],type = "l")

To plot the autococorrelaton function of “no” type: > acf(sunData[,”no”])

To plot the autococorrelaton function of “no”, up to lag 60 type: > acf(sunData[,”no”],60)

To plot the partial autococorrelaton function of “no”, up to lag 60 type: > pacf(sunData[,”no”],60)

To fit and ARIMA model type: > arima(sunData[,2],order = c(2,0,0)) The output Call: arima(x = sunData[, "no"], order = c(2, 0, 0)) Coefficients: ar1 ar2 intercept s.e sigma^2 estimated as 227.2: log likelihood = , aic =

To fit and ARIMA model using a specific method type: > arima(sunData[,”no”],order = c(2,0,0), method ="ML") The output Call: arima(x = sunData[, "no"], order = c(2, 0, 0), method = "ML") Coefficients: ar1 ar2 intercept s.e sigma^2 estimated as 227.2: log likelihood = , aic =

The Methods: 1.“CSS-ML“ - minimize conditional sum-of- squares to find starting values then maximum likelihood (the default method) 2.“ML" - maximum likelihood 3.“CSS" - minimize conditional sum-of-squares

ARIMA modelling of a univariate time series. arima(x, order = c(0, 0, 0), seasonal = list(order = c(0, 0, 0), period = NA), xreg = NULL, include.mean = TRUE, transform.pars = TRUE, fixed = NULL, init = NULL, method = c("CSS-ML", "ML", "CSS"), n.cond, optim.method = "BFGS", optim.control = list(), kappa = 1e6)

Arguments x a univariate time series order A specification of the non-seasonal part of the ARIMA model: the three components (p, d, q) are the AR order, the degree of differencing, and the MA order. seasonal A specification of the seasonal part of the ARIMA model, plus the period (which defaults to frequency(x)). This should be a list with components order and period, but a specification of just a numeric vector of length 3 will be turned into a suitable list with the specification as the order. xreg Optionally, a vector or matrix of external regressors, which must have the same number of rows as x.

include.mean Should the ARMA model include a mean/intercept term? The default is TRUE for undifferenced series, and it is ignored for ARIMA models with differencing. transform.pars Logical. If true, the AR parameters are transformed to ensure that they remain in the region of stationarity. Not used for method = "CSS". fixed optional numeric vector of the same length as the total number of parameters. If supplied, only NA entries in fixed will be varied. transform.pars = TRUE will be overridden (with a warning) if any AR parameters are fixed. It may be wise to set transform.pars = FALSE when fixing MA parameters, especially near non-invertibility.

init optional numeric vector of initial parameter values. Missing values will be filled in, by zeroes except for regression coefficients. Values already specified in fixed will be ignored. method Fitting method: maximum likelihood or minimize conditional sum-of-squares. The default (unless there are missing values) is to use conditional-sum- of-squares to find starting values, then maximum likelihood. n.cond Only used if fitting by conditional-sum-of-squares: the number of initial observations to ignore. It will be ignored if less than the maximum lag of an AR term.

optim.method The value passed as the method argument to optim.optim optim.control List of control parameters for optim.optim kappa the prior variance (as a multiple of the innovations variance) for the past observations in a differenced model. Do not reduce this.

Autocovariance, Autocorrelation function. acf(x, lag.max = NULL, type = c("correlation", "covariance", "partial"), plot = TRUE, na.action = na.fail, demean = TRUE,...) Examples acf(arima(sunData[,”no”], 60, type = "covariance") produces the autocovariace function acf(arima(sunData[,”no”], 60, type = “partial") produces the partial autocorrelation function (same result as) pacf(arima(sunData[,”no”], 60)

Cross-covariance, Cross-correlation function. ccf(x, y, lag.max = NULL, type = c("correlation", "covariance"), plot = TRUE, na.action = na.fail,...) This R function plots the Cross Cross- covariance or the Cross-correlation function.