View source: R/Calc Diag Delta t.r
DiagDeltaT | R Documentation |
Time-interval (DeltaT) for which the (discrete-time) residual covariance matrix (i.e., SigmaVAR(DeltaT)) is diagonal (together with that diagonal SigmaVAR and corresponding lagged-effects matrix Phi). The interactive web application 'Phi-and-Psi-Plots and Find DeltaT' also contains this functionality, you can find it on my website: https://www.uu.nl/staff/RMKuiper/Websites%20%2F%20Shiny%20apps.
DiagDeltaT(
Phi = NULL,
SigmaVAR = NULL,
Drift = NULL,
Sigma = NULL,
Gamma = NULL,
xstart_DeltaT = 1
)
Phi |
Matrix of size q times q of (un)standardized lagged effects of the first-order discrete-time vector autoregressive (DT-VAR(1)) model. It also takes a fitted object from the classes "varest" (from the VAR() function in vars package) and "ctsemFit" (from the ctFit() function in the ctsem package); see example below. From such an object, the (standardized) Drift matrix is calculated/extracted. |
SigmaVAR |
Residual covariance matrix of the first-order discrete-time vector autoregressive (DT-VAR(1)) model. |
Drift |
Optional (either Phi or Drift). Underling first-order continuous-time lagged effects matrix (i.e., Drift matrix) of the discrete-time lagged effects matrix Phi(DeltaT). By default, input for Phi is used; only when Phi = NULL, Drift will be used. |
Sigma |
Optional (either SigmaVAR, Sigma or Gamma). Residual covariance matrix of the first-order continuous-time (CT-VAR(1)) model, that is, the diffusion matrix. By default, input for SigmaVAR is used; only when SigmaVAR = NULL, Sigma will be used. |
Gamma |
Optional (either SigmaVAR, Sigma or Gamma). Stationary covariance matrix, that is, the contemporaneous covariance matrix of the data. By default, input for SigmaVAR is used; only when SigmaVAR = NULL, Gamma will be used. Note that if Phi and SigmaVAR (or Drift and Sigma) are known, Gamma can be calculated; hence, only one out of SigmaVAR, Sigma, and Gamma is needed as input. |
xstart_DeltaT |
Optional. Starting value for DeltaT. If you see in the SigmaVAR-plot a DeltaT for which SigmaVAR is diagonal (i.e., the covariances are zero) and the function renders DeltaT_diag = 0 as a solution, then change this start value accordingly. By default, xstart_DeltaT = 1 |
The output renders the time-interval for which the (discrete-time) residual covariance matrix (SigmaVAR) is diagonal (DeltaT_diag), together with that diagonal SigmaVAR and corresponding lagged-effects matrix Phi (i.e., SigmaVAR(DeltaT_diag) and Phi(DeltaT_diag)).
# library(CTmeta)
## Example 1 ##
# Here, DeltaT_diag = 0
##################################################################################################
# Input needed in examples below with q=2 variables.
# I will use the example matrices stored in the package:
Phi <- myPhi[1:2, 1:2] # = Phi(1), that is, Phi when DeltaT = 1
q <- dim(Phi)[1]
#SigmaVAR <- diag(q) # Then, DeltaT_diag = 1 (since, implicitly, DeltaT = 1)
Gamma <- matrix(c(1, 0.5, 0.4, 1), byrow = T, nrow = q, ncol = q)
SigmaVAR <- Gamma - Phi %*% Gamma %*% t(Phi)
# or:
Drift <- myDrift
Sigma <- diag(2) # for ease. Note that this is not the CT-equivalent of SigmaVAR.
##################################################################################################
DiagDeltaT(Phi, SigmaVAR)
# If you would use the drift matrix Drift as input, then use:
DiagDeltaT(Drift = Drift, Sigma = Sigma)
# Note that the function 'SigmaVARPlot' can help to see whether there is a DeltaT for which SigmaVAr(DeltaT) is diagonal.
SigmaVARPlot(DeltaT, Phi, SigmaVAR)
## Example 2: input from fitted object of class "varest" ##
# Here, there exists a DeltaT_diag unequal to 0
#
data <- myData
if (!require("vars")) install.packages("vars")
library(vars)
out_VAR <- VAR(data, p = 1)
DiagDeltaT(out_VAR)
# Note that the function 'SigmaVARPlot' can help to see whether there is a DeltaT for which SigmaVAr(DeltaT) is diagonal.
SigmaVARPlot(DeltaT, out_VAR)
SigmaVARPlot(DeltaT, out_VAR, Min = 0, Max = 1)
## Example 3 ##
Here, there exists a DeltaT_diag unequal to 0 (DeltaT_diag = 0.3565)
q <- 2
Phi_2 <- matrix(c(0.5543025, 0.2547274,
0.1477329, 0.6612970),
nrow = q, ncol = q)
SigmaVAR_2 <- matrix(c(1.1990749, 0.1990749,
0.1990749, 1.1990749),
nrow = q, ncol = q)
DiagDeltaT(Phi_2, SigmaVAR_2)
# Note that the function 'SigmaVARPlot' can help to see whether there is a DeltaT for which SigmaVAr(DeltaT) is diagonal.
DeltaT <- 1
SigmaVARPlot(DeltaT, Phi_2, SigmaVAR_2)
SigmaVARPlot(DeltaT, Phi_2, SigmaVAR_2, Min = 0, Max = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.