SlideShare a Scribd company logo
1 of 18
Chapter 2. Multivariate Analysis of
     Stationary Time Series




          Cheng-Jun Wang
Contents
w
                     No
          2000s




                     C   M
                  VE
          1990s
History



                         e   r     &
                       ng
                  Gr a        tion
                           gra tion
                      Inte tegra
                           in
                        Co
          1987
                    Sim        R
                             VA
          1980
VAR
Matrix Multiplication




http://en.wikipedia.org/wiki/Matrix_multiplication
Matrix Addition
R Code 2.1
                Simulation of Var (2)-process

## Simulate VAR(2)-data                                 ## Obtaining the generated series
library(dse1)                                           vardat <- matrix(varsim$output, nrow = 500, ncol = 2)
library(vars)
                                                        colnames(vardat) <- c("y1", "y2")
## Setting the lag-polynomial A(L)
Apoly <- array(c(1.0, -0.5, 0.3, 0,                     ## Plotting the series
          0.2, 0.1, 0, -0.2,                            plot.ts(vardat, main = "", xlab = "")
          0.7, 1, 0.5, -0.3) ,                          ## Determining an appropriate lag-order
         c(3, 2, 2))                                    infocrit <- VARselect(vardat, lag.max = 3,
## Setting Covariance to identity-matrix                             type = "const")
B <- diag(2)
## Setting constant term to 5 and 10
                                                        ## Estimating the model
TRD <- c(5, 10)                                         varsimest <- VAR(vardat, p = 2, type = "const",
## Generating the VAR(2) model                                    season = NULL, exogen = NULL)
var2 <- ARMA(A = Apoly, B = B, TREND = TRD)             ## Alternatively, selection according to AIC
## Simulating 500 observations                          varsimest <- VAR(vardat, type = "const",
varsim <- simulate(var2, sampleT = 500,
                                                                  lag.max = 3, ic = "SC")
          noise = list(w = matrix(rnorm(1000),
nrow = 500, ncol = 2)), rng = list(seed = c(123456)))   ## Checking the roots
                                                        roots <- roots(varsimest)
R Code 2.2
     Diagnostic tests of VAR(2)-process

∗   ## testing serial correlation                          ∗   ## class and methods for diganostic tests
∗   args(serial.test)
∗   ## Portmanteau-Test                                    ∗   class(var2c.serial)
∗   var2c.serial <- serial.test(varsimest, lags.pt = 16,   ∗   class(var2c.arch)
∗                   type = "PT.asymptotic")
∗   var2c.serial                                           ∗   class(var2c.norm)
∗   plot(var2c.serial, names = "y1")                       ∗   methods(class = "varcheck")
∗   plot(var2c.serial, names = "y2")
∗   ## testing heteroscedasticity
                                                           ∗   ## Plot of objects "varcheck"
∗   args(arch.test)                                        ∗   args(vars:::plot.varcheck)
∗
∗
    var2c.arch <- arch.test(varsimest, lags.multi = 5,     ∗   plot(var2c.serial, names = "y1")
                 multivariate.only = TRUE)
∗   var2c.arch                                             ∗   ## Structural stability test
∗   ## testing for normality                               ∗   reccusum <- stability(varsimest,
∗   args(normality.test)
∗   var2c.norm <- normality.test(varsimest,                ∗      type = "OLS-CUSUM")
∗                    multivariate.only = TRUE)             ∗   fluctuation <- stability(varsimest,
∗   var2c.norm
                                                           ∗      type = "fluctuation")
Causality Analysis

∗ Granger causality
∗ Wald-type instantaneous causality
∗ ## Causality tests
∗ ## Granger and instantaneous causality
∗ var.causal <- causality(varsimest, cause = "y2")
Forecasting


       ∗ ## Forecasting objects of class varest
       ∗ args(vars:::predict.varest)
       ∗ predictions <- predict(varsimest, n.ahead
         = 25,
       ∗              ci = 0.95)
       ∗ class(predictions)
       ∗ args(vars:::plot.varprd)
       ∗ ## Plot of predictions for y1
       ∗ plot(predictions, names = "y1")
       ∗ ## Fanchart for y2
       ∗ args(fanchart)
       ∗ fanchart(predictions, names = "y2")
Impulse Response Function

∗ Causality test falls short of quantifying the impact of the
  impulse variable on the response variable over time.
∗ The impulse response analysis is used to investigate these kinds
  of dynamic interactions between the endogenous variables and
  is based upon the Wold moving average representation of a
  VAR(p)-process.
## Forecast error variance
## Impulse response analysis                           decomposition

∗ irf.y1 <- irf(varsimest, impulse = "y1",    ∗ fevd.var2 <- fevd(varsimest,
∗          response = "y2", n.ahead = 10,
∗          ortho = FALSE, cumulative =          n.ahead = 10)
  FALSE,                                      ∗ args(vars:::plot.varfevd)
∗          boot = FALSE, seed = 12345)
∗ args(vars:::plot.varirf)                    ∗ plot(fevd.var2, addbars = 2)
∗ plot(irf.y1)
∗ irf.y2 <- irf(varsimest, impulse = "y2",
∗          response = "y1", n.ahead = 10,
∗          ortho = TRUE, cumulative = TRUE,
∗          boot = FALSE, seed = 12345)
∗ plot(irf.y2)
SVAR

∗ An SVAR-model can be used to identify shocks and trace these
  out by employing IRA and/or FEVD through imposing
  restrictions on the matrices A and/or B.
SVAR: A-model


∗   library(dse1)                               ∗   ## Obtaining the generated series
∗   library(vars)                               ∗   svardat <- matrix(svarsim$output, nrow = 500, ncol =
∗   ## A-model                                      2)
                                                ∗   colnames(svardat) <- c("y1", "y2")
∗   Apoly <- array(c(1.0, -0.5, 0.3, 0.8,
                                                ∗   ## Estimating the VAR
∗             0.2, 0.1, -0.7, -0.2,             ∗   varest <- VAR(svardat, p = 2, type = "none")
∗             0.7, 1, 0.5, -0.3) ,              ∗   ## Setting up matrices for A-model
∗            c(3, 2, 2))                        ∗   Amat <- diag(2)
∗   ## Setting covariance to identity-matrix    ∗   Amat[2, 1] <- NA
∗   B <- diag(2)                                ∗   Amat[1, 2] <- NA
∗   ## Generating the VAR(2) model              ∗   ## Estimating the SVAR A-type by direct
∗   svarA <- ARMA(A = Apoly, B = B)                 maximisation
∗   ## Simulating 500 observations              ∗   ## of the log-likelihood
∗   svarsim <- simulate(svarA, sampleT = 500,   ∗   args(SVAR)
                                                ∗   svar.A <- SVAR(varest, estmethod = "direct",
∗              rng = list(seed = c(123456)))
                                                ∗           Amat = Amat, hessian = TRUE)
SVAR: B-model


∗   library(dse1)                              ∗   ## Simulating 500 observations
∗   library(vars)                              ∗   svarsim <- simulate(svarB, sampleT = 500,
∗   ## B-model                                 ∗              rng = list(seed = c(123456)))
                                               ∗   svardat <- matrix(svarsim$output, nrow = 500,
∗   Apoly <- array(c(1.0, -0.5, 0.3, 0,            ncol = 2)
∗               0.2, 0.1, 0, -0.2,             ∗   colnames(svardat) <- c("y1", "y2")
∗               0.7, 1, 0.5, -0.3) ,           ∗   varest <- VAR(svardat, p = 2, type = "none")
∗              c(3, 2, 2))                     ∗   ## Estimating the SVAR B-type by scoring
                                                   algorithm
∗   ## Setting covariance to identity-matrix   ∗   ## Setting up the restriction matrix and vector
∗   B <- diag(2)                               ∗   ## for B-model
∗   B[2, 1] <- -0.8                            ∗   Bmat <- diag(2)
∗   ## Generating the VAR(2) model             ∗   Bmat[2, 1] <- NA
∗   svarB <- ARMA(A = Apoly, B = B)            ∗   svar.B <- SVAR(varest, estmethod = "scoring",
                                               ∗           Bmat = Bmat, max.iter = 200)
## Impulse response analysis of        ## FEVD analysis of SVAR B-type
     SVAR A-type model                             model

∗ args(vars:::irf.svarest)             ∗ args(vars:::fevd.svarest)
∗ irf.svara <- irf(svar.A, impulse =   ∗ fevd.svarb <- fevd(svar.B, n.ahead
  "y1", response = "y2", boot =          = 5)
  FALSE)                               ∗ class(fevd.svarb)
∗ args(vars:::plot.varirf)             ∗ methods(class = "varfevd")
∗ plot(irf.svara)                      ∗ plot(fevd.svarb)
20121209

More Related Content

What's hot

深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscex
jeffz
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
Giordano Scalzo
 
Dynamic Mesh in OpenFOAM
Dynamic Mesh in OpenFOAMDynamic Mesh in OpenFOAM
Dynamic Mesh in OpenFOAM
Fumiya Nozaki
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
ujihisa
 

What's hot (17)

深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscex
 
Random stability in systemVerilog and UVM based testbench
Random stability in systemVerilog and UVM based testbenchRandom stability in systemVerilog and UVM based testbench
Random stability in systemVerilog and UVM based testbench
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
 
sas aeroplan sample
sas aeroplan samplesas aeroplan sample
sas aeroplan sample
 
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++
 
Jamming attack in wireless network
Jamming attack in wireless networkJamming attack in wireless network
Jamming attack in wireless network
 
V8
V8V8
V8
 
Live Updating Swift Code
Live Updating Swift CodeLive Updating Swift Code
Live Updating Swift Code
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Swift 3 Programming for iOS : subscript init
Swift 3 Programming for iOS : subscript initSwift 3 Programming for iOS : subscript init
Swift 3 Programming for iOS : subscript init
 
Breaking the wall
Breaking the wallBreaking the wall
Breaking the wall
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
 
The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196
 
Dynamic Mesh in OpenFOAM
Dynamic Mesh in OpenFOAMDynamic Mesh in OpenFOAM
Dynamic Mesh in OpenFOAM
 
Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
 

Viewers also liked

Oil Prices Modelling
Oil Prices ModellingOil Prices Modelling
Oil Prices Modelling
Hanan Naser
 
E views 7 student version
E views 7 student versionE views 7 student version
E views 7 student version
Hyun Bin Kim
 
On clustering financial time series - A need for distances between dependent ...
On clustering financial time series - A need for distances between dependent ...On clustering financial time series - A need for distances between dependent ...
On clustering financial time series - A need for distances between dependent ...
Gautier Marti
 

Viewers also liked (15)

isi
isiisi
isi
 
Oil Prices Modelling
Oil Prices ModellingOil Prices Modelling
Oil Prices Modelling
 
E views 6 users guide i
E views 6 users guide iE views 6 users guide i
E views 6 users guide i
 
E views 7 student version
E views 7 student versionE views 7 student version
E views 7 student version
 
Serial correlation
Serial correlationSerial correlation
Serial correlation
 
Cours econométrie des séries temporelles (1)
Cours econométrie des séries temporelles (1)Cours econométrie des séries temporelles (1)
Cours econométrie des séries temporelles (1)
 
Heteroskedasticity
HeteroskedasticityHeteroskedasticity
Heteroskedasticity
 
Estimation de l'ecart de production et inflation dans la CEMAC
Estimation de l'ecart de production et inflation dans la CEMACEstimation de l'ecart de production et inflation dans la CEMAC
Estimation de l'ecart de production et inflation dans la CEMAC
 
Use of R in Actuarial Works
Use of R in Actuarial WorksUse of R in Actuarial Works
Use of R in Actuarial Works
 
Using R for Analyzing Loans, Portfolios and Risk: From Academic Theory to Fi...
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Fi...Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Fi...
Using R for Analyzing Loans, Portfolios and Risk: From Academic Theory to Fi...
 
Déterminants de l'inflation dans la CEMAC: le rôle de la monnaie
Déterminants de l'inflation dans la CEMAC: le rôle de la monnaieDéterminants de l'inflation dans la CEMAC: le rôle de la monnaie
Déterminants de l'inflation dans la CEMAC: le rôle de la monnaie
 
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
Spillover Dynamics for Systemic Risk Measurement Using Spatial Financial Time...
 
On clustering financial time series - A need for distances between dependent ...
On clustering financial time series - A need for distances between dependent ...On clustering financial time series - A need for distances between dependent ...
On clustering financial time series - A need for distances between dependent ...
 
R in finance: Introduction to R and Its Applications in Finance
R in finance: Introduction to R and Its Applications in FinanceR in finance: Introduction to R and Its Applications in Finance
R in finance: Introduction to R and Its Applications in Finance
 
Econometrics theory and_applications_with_eviews
Econometrics theory and_applications_with_eviewsEconometrics theory and_applications_with_eviews
Econometrics theory and_applications_with_eviews
 

Similar to Chapter 2. Multivariate Analysis of Stationary Time Series

Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macros
univalence
 
Error Control in Multimedia Communications using Wireless Sensor Networks report
Error Control in Multimedia Communications using Wireless Sensor Networks reportError Control in Multimedia Communications using Wireless Sensor Networks report
Error Control in Multimedia Communications using Wireless Sensor Networks report
Muragesh Kabbinakantimath
 
Meta-objective Lisp @名古屋 Reject 会議
Meta-objective Lisp @名古屋 Reject 会議Meta-objective Lisp @名古屋 Reject 会議
Meta-objective Lisp @名古屋 Reject 会議
dico_leque
 
Datamining R 4th
Datamining R 4thDatamining R 4th
Datamining R 4th
sesejun
 

Similar to Chapter 2. Multivariate Analysis of Stationary Time Series (20)

Ns2programs
Ns2programsNs2programs
Ns2programs
 
2.3 implicits
2.3 implicits2.3 implicits
2.3 implicits
 
Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macros
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
Error Control in Multimedia Communications using Wireless Sensor Networks report
Error Control in Multimedia Communications using Wireless Sensor Networks reportError Control in Multimedia Communications using Wireless Sensor Networks report
Error Control in Multimedia Communications using Wireless Sensor Networks report
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVM
 
Groovy collection api
Groovy collection apiGroovy collection api
Groovy collection api
 
Eta
EtaEta
Eta
 
Time Series Analysis on Egg depositions (in millions) of age-3 Lake Huron Blo...
Time Series Analysis on Egg depositions (in millions) of age-3 Lake Huron Blo...Time Series Analysis on Egg depositions (in millions) of age-3 Lake Huron Blo...
Time Series Analysis on Egg depositions (in millions) of age-3 Lake Huron Blo...
 
numdoc
numdocnumdoc
numdoc
 
Hello scala
Hello scalaHello scala
Hello scala
 
tutorial5
tutorial5tutorial5
tutorial5
 
1.5.recommending music with apache spark ml
1.5.recommending music with apache spark ml1.5.recommending music with apache spark ml
1.5.recommending music with apache spark ml
 
Lisp Macros in 20 Minutes (Featuring Clojure)
Lisp Macros in 20 Minutes (Featuring Clojure)Lisp Macros in 20 Minutes (Featuring Clojure)
Lisp Macros in 20 Minutes (Featuring Clojure)
 
How to use SVM for data classification
How to use SVM for data classificationHow to use SVM for data classification
How to use SVM for data classification
 
Ridge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power AnalysisRidge-based Profiled Differential Power Analysis
Ridge-based Profiled Differential Power Analysis
 
Meta-objective Lisp @名古屋 Reject 会議
Meta-objective Lisp @名古屋 Reject 会議Meta-objective Lisp @名古屋 Reject 会議
Meta-objective Lisp @名古屋 Reject 会議
 
Write a Matlab code (a computerized program) for calculating plane st.docx
 Write a Matlab code (a computerized program) for calculating plane st.docx Write a Matlab code (a computerized program) for calculating plane st.docx
Write a Matlab code (a computerized program) for calculating plane st.docx
 
Datamining R 4th
Datamining R 4thDatamining R 4th
Datamining R 4th
 

More from Chengjun Wang

Randomly sampling YouTube users
Randomly sampling YouTube usersRandomly sampling YouTube users
Randomly sampling YouTube users
Chengjun Wang
 
Pajek chapter2 Attributes and Relations
Pajek chapter2 Attributes and RelationsPajek chapter2 Attributes and Relations
Pajek chapter2 Attributes and Relations
Chengjun Wang
 
Calculate Thresholds of Diffusion with Pajek
Calculate Thresholds of Diffusion with PajekCalculate Thresholds of Diffusion with Pajek
Calculate Thresholds of Diffusion with Pajek
Chengjun Wang
 
人类行为与最大熵原理
人类行为与最大熵原理人类行为与最大熵原理
人类行为与最大熵原理
Chengjun Wang
 
Impact of human value, consumer perceived value
Impact of human value, consumer perceived valueImpact of human value, consumer perceived value
Impact of human value, consumer perceived value
Chengjun Wang
 
Introduction to News diffusion On News Sharing Website
Introduction to News diffusion On News Sharing WebsiteIntroduction to News diffusion On News Sharing Website
Introduction to News diffusion On News Sharing Website
Chengjun Wang
 
Suppressor and distort variables
Suppressor and distort variablesSuppressor and distort variables
Suppressor and distort variables
Chengjun Wang
 
Stata Learning From Treiman
Stata Learning From TreimanStata Learning From Treiman
Stata Learning From Treiman
Chengjun Wang
 
A M O S L E A R N I N G
A M O S  L E A R N I N GA M O S  L E A R N I N G
A M O S L E A R N I N G
Chengjun Wang
 

More from Chengjun Wang (15)

计算传播学导论
计算传播学导论计算传播学导论
计算传播学导论
 
数据可视化 概念案例方法 王成军 20140104
数据可视化 概念案例方法 王成军 20140104数据可视化 概念案例方法 王成军 20140104
数据可视化 概念案例方法 王成军 20140104
 
Randomly sampling YouTube users
Randomly sampling YouTube usersRandomly sampling YouTube users
Randomly sampling YouTube users
 
An introduction to computational communication
An introduction to computational communication An introduction to computational communication
An introduction to computational communication
 
Pajek chapter2 Attributes and Relations
Pajek chapter2 Attributes and RelationsPajek chapter2 Attributes and Relations
Pajek chapter2 Attributes and Relations
 
Calculate Thresholds of Diffusion with Pajek
Calculate Thresholds of Diffusion with PajekCalculate Thresholds of Diffusion with Pajek
Calculate Thresholds of Diffusion with Pajek
 
人类行为与最大熵原理
人类行为与最大熵原理人类行为与最大熵原理
人类行为与最大熵原理
 
Impact of human value, consumer perceived value
Impact of human value, consumer perceived valueImpact of human value, consumer perceived value
Impact of human value, consumer perceived value
 
Introduction to News diffusion On News Sharing Website
Introduction to News diffusion On News Sharing WebsiteIntroduction to News diffusion On News Sharing Website
Introduction to News diffusion On News Sharing Website
 
The Emergence of Spiral of Silence from Individual behaviors: Agent-based Mod...
The Emergence of Spiral of Silence from Individual behaviors: Agent-based Mod...The Emergence of Spiral of Silence from Individual behaviors: Agent-based Mod...
The Emergence of Spiral of Silence from Individual behaviors: Agent-based Mod...
 
Suppressor and distort variables
Suppressor and distort variablesSuppressor and distort variables
Suppressor and distort variables
 
Pajek chapter1
Pajek chapter1Pajek chapter1
Pajek chapter1
 
Stata Learning From Treiman
Stata Learning From TreimanStata Learning From Treiman
Stata Learning From Treiman
 
A M O S L E A R N I N G
A M O S  L E A R N I N GA M O S  L E A R N I N G
A M O S L E A R N I N G
 
Amos Learning
Amos LearningAmos Learning
Amos Learning
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Chapter 2. Multivariate Analysis of Stationary Time Series

  • 1. Chapter 2. Multivariate Analysis of Stationary Time Series Cheng-Jun Wang
  • 3. w No 2000s C M VE 1990s History e r & ng Gr a tion gra tion Inte tegra in Co 1987 Sim R VA 1980
  • 4. VAR
  • 7. R Code 2.1 Simulation of Var (2)-process ## Simulate VAR(2)-data ## Obtaining the generated series library(dse1) vardat <- matrix(varsim$output, nrow = 500, ncol = 2) library(vars) colnames(vardat) <- c("y1", "y2") ## Setting the lag-polynomial A(L) Apoly <- array(c(1.0, -0.5, 0.3, 0, ## Plotting the series 0.2, 0.1, 0, -0.2, plot.ts(vardat, main = "", xlab = "") 0.7, 1, 0.5, -0.3) , ## Determining an appropriate lag-order c(3, 2, 2)) infocrit <- VARselect(vardat, lag.max = 3, ## Setting Covariance to identity-matrix type = "const") B <- diag(2) ## Setting constant term to 5 and 10 ## Estimating the model TRD <- c(5, 10) varsimest <- VAR(vardat, p = 2, type = "const", ## Generating the VAR(2) model season = NULL, exogen = NULL) var2 <- ARMA(A = Apoly, B = B, TREND = TRD) ## Alternatively, selection according to AIC ## Simulating 500 observations varsimest <- VAR(vardat, type = "const", varsim <- simulate(var2, sampleT = 500, lag.max = 3, ic = "SC") noise = list(w = matrix(rnorm(1000), nrow = 500, ncol = 2)), rng = list(seed = c(123456))) ## Checking the roots roots <- roots(varsimest)
  • 8. R Code 2.2 Diagnostic tests of VAR(2)-process ∗ ## testing serial correlation ∗ ## class and methods for diganostic tests ∗ args(serial.test) ∗ ## Portmanteau-Test ∗ class(var2c.serial) ∗ var2c.serial <- serial.test(varsimest, lags.pt = 16, ∗ class(var2c.arch) ∗ type = "PT.asymptotic") ∗ var2c.serial ∗ class(var2c.norm) ∗ plot(var2c.serial, names = "y1") ∗ methods(class = "varcheck") ∗ plot(var2c.serial, names = "y2") ∗ ## testing heteroscedasticity ∗ ## Plot of objects "varcheck" ∗ args(arch.test) ∗ args(vars:::plot.varcheck) ∗ ∗ var2c.arch <- arch.test(varsimest, lags.multi = 5, ∗ plot(var2c.serial, names = "y1") multivariate.only = TRUE) ∗ var2c.arch ∗ ## Structural stability test ∗ ## testing for normality ∗ reccusum <- stability(varsimest, ∗ args(normality.test) ∗ var2c.norm <- normality.test(varsimest, ∗ type = "OLS-CUSUM") ∗ multivariate.only = TRUE) ∗ fluctuation <- stability(varsimest, ∗ var2c.norm ∗ type = "fluctuation")
  • 9. Causality Analysis ∗ Granger causality ∗ Wald-type instantaneous causality
  • 10. ∗ ## Causality tests ∗ ## Granger and instantaneous causality ∗ var.causal <- causality(varsimest, cause = "y2")
  • 11. Forecasting ∗ ## Forecasting objects of class varest ∗ args(vars:::predict.varest) ∗ predictions <- predict(varsimest, n.ahead = 25, ∗ ci = 0.95) ∗ class(predictions) ∗ args(vars:::plot.varprd) ∗ ## Plot of predictions for y1 ∗ plot(predictions, names = "y1") ∗ ## Fanchart for y2 ∗ args(fanchart) ∗ fanchart(predictions, names = "y2")
  • 12. Impulse Response Function ∗ Causality test falls short of quantifying the impact of the impulse variable on the response variable over time. ∗ The impulse response analysis is used to investigate these kinds of dynamic interactions between the endogenous variables and is based upon the Wold moving average representation of a VAR(p)-process.
  • 13. ## Forecast error variance ## Impulse response analysis decomposition ∗ irf.y1 <- irf(varsimest, impulse = "y1", ∗ fevd.var2 <- fevd(varsimest, ∗ response = "y2", n.ahead = 10, ∗ ortho = FALSE, cumulative = n.ahead = 10) FALSE, ∗ args(vars:::plot.varfevd) ∗ boot = FALSE, seed = 12345) ∗ args(vars:::plot.varirf) ∗ plot(fevd.var2, addbars = 2) ∗ plot(irf.y1) ∗ irf.y2 <- irf(varsimest, impulse = "y2", ∗ response = "y1", n.ahead = 10, ∗ ortho = TRUE, cumulative = TRUE, ∗ boot = FALSE, seed = 12345) ∗ plot(irf.y2)
  • 14. SVAR ∗ An SVAR-model can be used to identify shocks and trace these out by employing IRA and/or FEVD through imposing restrictions on the matrices A and/or B.
  • 15. SVAR: A-model ∗ library(dse1) ∗ ## Obtaining the generated series ∗ library(vars) ∗ svardat <- matrix(svarsim$output, nrow = 500, ncol = ∗ ## A-model 2) ∗ colnames(svardat) <- c("y1", "y2") ∗ Apoly <- array(c(1.0, -0.5, 0.3, 0.8, ∗ ## Estimating the VAR ∗ 0.2, 0.1, -0.7, -0.2, ∗ varest <- VAR(svardat, p = 2, type = "none") ∗ 0.7, 1, 0.5, -0.3) , ∗ ## Setting up matrices for A-model ∗ c(3, 2, 2)) ∗ Amat <- diag(2) ∗ ## Setting covariance to identity-matrix ∗ Amat[2, 1] <- NA ∗ B <- diag(2) ∗ Amat[1, 2] <- NA ∗ ## Generating the VAR(2) model ∗ ## Estimating the SVAR A-type by direct ∗ svarA <- ARMA(A = Apoly, B = B) maximisation ∗ ## Simulating 500 observations ∗ ## of the log-likelihood ∗ svarsim <- simulate(svarA, sampleT = 500, ∗ args(SVAR) ∗ svar.A <- SVAR(varest, estmethod = "direct", ∗ rng = list(seed = c(123456))) ∗ Amat = Amat, hessian = TRUE)
  • 16. SVAR: B-model ∗ library(dse1) ∗ ## Simulating 500 observations ∗ library(vars) ∗ svarsim <- simulate(svarB, sampleT = 500, ∗ ## B-model ∗ rng = list(seed = c(123456))) ∗ svardat <- matrix(svarsim$output, nrow = 500, ∗ Apoly <- array(c(1.0, -0.5, 0.3, 0, ncol = 2) ∗ 0.2, 0.1, 0, -0.2, ∗ colnames(svardat) <- c("y1", "y2") ∗ 0.7, 1, 0.5, -0.3) , ∗ varest <- VAR(svardat, p = 2, type = "none") ∗ c(3, 2, 2)) ∗ ## Estimating the SVAR B-type by scoring algorithm ∗ ## Setting covariance to identity-matrix ∗ ## Setting up the restriction matrix and vector ∗ B <- diag(2) ∗ ## for B-model ∗ B[2, 1] <- -0.8 ∗ Bmat <- diag(2) ∗ ## Generating the VAR(2) model ∗ Bmat[2, 1] <- NA ∗ svarB <- ARMA(A = Apoly, B = B) ∗ svar.B <- SVAR(varest, estmethod = "scoring", ∗ Bmat = Bmat, max.iter = 200)
  • 17. ## Impulse response analysis of ## FEVD analysis of SVAR B-type SVAR A-type model model ∗ args(vars:::irf.svarest) ∗ args(vars:::fevd.svarest) ∗ irf.svara <- irf(svar.A, impulse = ∗ fevd.svarb <- fevd(svar.B, n.ahead "y1", response = "y2", boot = = 5) FALSE) ∗ class(fevd.svarb) ∗ args(vars:::plot.varirf) ∗ methods(class = "varfevd") ∗ plot(irf.svara) ∗ plot(fevd.svarb)