-
Notifications
You must be signed in to change notification settings - Fork 0
/
ggohiplot_documentation-example.Rmd
77 lines (63 loc) · 1.7 KB
/
ggohiplot_documentation-example.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
title: "test examples ggphiplot"
author: "Judith Neve"
date: "10/04/2022"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
# library(CTmeta)
### Make Phi-plot ###
## Example 1 ##
# Phi(DeltaT)
DeltaT <- 1
Phi <- myPhi[1:2,1:2]
# or: Drift
Drift <- myDrift
# Example 1.1: unstandardized Phi #
#
# Make plot of Phi
ggPhiPlot(DeltaT, Phi)
ggPhiPlot(DeltaT, Phi, Min = 0, Max = 10, Step = 0.01) # Specifying range x-axis and precision
ggPhiPlot(DeltaT, Drift = Drift, Min = 0, Max = 10, Step = 0.01) # Using Drift instead of Phi
```
```{r}
# Example 1.2: standardized Phi #
q <- dim(Phi)[1]
SigmaVAR <- diag(q) # for ease
ggPhiPlot(DeltaT, Phi, Stand = 1, SigmaVAR = SigmaVAR)
```
```{r}
## Example 2: input from fitted object of class "varest" ##
DeltaT <- 1
data <- myData
if (!require("vars")) install.packages("vars")
library(vars)
out_VAR <- VAR(data, p = 1)
# Example 2.1: unstandardized Phi #
ggPhiPlot(DeltaT, out_VAR)
# Example 2.2: standardized Phi #
ggPhiPlot(DeltaT, out_VAR, Stand = 1)
```
```{r}
## Example 3: Change plot options ##
DeltaT <- 1
Phi <- myPhi[1:2,1:2]
q <- dim(Phi)[1]
SigmaVAR <- diag(q) # for ease
#
WhichElements <- matrix(1, ncol = q, nrow = q) # Now, all elements are 1
diag(WhichElements) <- 0 # Now, the autoregressive parameters are excluded by setting the diagonals to 0.
Lab <- c("12", "21")
Labels <- NULL
for(i in 1:length(Lab)){
e <- bquote(expression(Phi(Delta[t])[.(Lab[i])]))
Labels <- c(Labels, eval(e))
}
Col <- c(1,2)
Lty <- c(1,2)
# Standardized Phi
ggPhiPlot(DeltaT = 1, Phi, Stand = 1, SigmaVAR = SigmaVAR, Min = 0, Max = 10, Step = 0.05, WhichElements = WhichElements, Labels = Labels, Col = Col, Lty = Lty)
```