MaxDeltaT: Time-interval (DeltaT) for which Phi_ij(DeltaT) reaches its...

View source: R/Calc Max Delta t.r

MaxDeltaTR Documentation

Time-interval (DeltaT) for which Phi_ij(DeltaT) reaches its minimum or maximum (together with that minimum or maximum)

Description

Time-interval (DeltaT) for which Phi_ij(DeltaT) reaches its minimum or maximum (together with that minimum or maximum). 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.

Usage

MaxDeltaT(DeltaT = 1, Phi = NULL, Drift = NULL)

Arguments

DeltaT

Optional. The time interval used. By default, DeltaT = 1.

Phi

Matrix of size q times q of (un)standardized lagged effects. 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.

Drift

Optional (either Phi or Drift). Matrix of size q times q of (un)standardized continuous-time lagged effects, called drift matrix. Note that Phi(DeltaT) = expm(Drift*DeltaT). By default, input for Phi is used; only when Phi = NULL, Drift will be used.

Value

The output renders, per element (i,j), the time-interval for which Phi_ij reaches its minimum/maximum together with this minimum/maximum Phi_ij. Note that even though a matrix is presented, the elements in it refer to different time-intervals when DeltaT differs per element (see in examples below).

Examples


# library(CTmeta)

## Example 1 ##

##################################################################################################
# Input needed in examples below with q=2 variables.
# I will use the example matrices stored in the package:
DeltaT <- 1
Phi <- myPhi[1:2, 1:2]
# or: Drift
Drift <- myDrift
##################################################################################################

MaxDeltaT(DeltaT = DeltaT, Phi = Phi)
# or
MaxDeltaT(DeltaT, Phi)

# Note that the DeltaT for which Phi_ij reaches its maximum or minimum ('DeltaT_MinOrMaxPhi') differs per Phi_ij.
# Therefore, the matrix 'MinOrMaxPhi' is not a Phi-matrix, but each element should be inspected separately.
# To obtain the full Phi-matrix for a specific DeltaT one can use:
DeltaT_MinOrMaxPhi <- MaxDeltaT(DeltaT, Phi)$DeltaT_MinOrMaxPhi
StandTransPhi(DeltaTStar = DeltaT_MinOrMaxPhi[1,2], DeltaT, N = NULL, Phi)$Phi_DeltaTStar

# If you would use the drift matrix Drift as input, then use:
MaxDeltaT(DeltaT, Drift = Drift)


# Note that the function 'PhiPlot' can help to see (per element) whether a minimum or maximum is reached.
PhiPlot(DeltaT, Phi)
# or:
ggPhiPlot(DeltaT, Phi)

# Often there is a minimum and a maximum, the function can give this by
# calculating the optimum from three different starting points.



## Example 2: input from fitted object of class "varest" ##
#
data <- myData
if (!require("vars")) install.packages("vars")
library(vars)
out_VAR <- VAR(data, p = 1)
DeltaT <- 1
MaxDeltaT(DeltaT, out_VAR)
#
ggPhiPlot(DeltaT, out_VAR)


rebeccakuiper/CTmeta documentation built on Nov. 2, 2024, 4:42 p.m.