StandTransPhi: StandTransPhi

View source: R/Calc CovMx stand transformed Phi.r

StandTransPhiR Documentation

StandTransPhi

Description

This function calculates the (vectorized) transformed standardized Phi, their covariance matrix and elliptical 95% confidence interval (CI). There is also an interactive web application on my website: Standardizing and/or transforming lagged regression estimates (https://www.uu.nl/staff/RMKuiper/Websites%20%2F%20Shiny%20apps).

Usage

StandTransPhi(
  DeltaTStar,
  DeltaT = 1,
  N = NULL,
  Phi,
  SigmaVAR = NULL,
  Gamma = NULL,
  alpha = 0.05
)

Arguments

DeltaTStar

The time interval to which the (un)standardized lagged effects matrix (Phi) should be transformed to.

DeltaT

Optional. The time interval used. Hence, Phi(DeltaT) will be transformed to Phi(DeltaTStar) and standardized. By default, DeltaT = 1.

N

Optional. Number of persons (panel data) or number measurement occasions - 1 (time series data). This is used in determining the covariance matrix of the vectorized standardized lagged effects. By default, N = NULL.

Phi

(Un)standardized lagged effects matrix. If necessary, it is standardized, then it is transformed and for this vectorized Phi the covariance matrix is determined. 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 Phi, SigmaVAR, and Gamma matrices are calculated/extracted.

SigmaVAR

Residual covariance matrix of the first-order discrete-time vector autoregressive (DT-VAR(1)) model.

Gamma

Optional (either SigmaVAR or Gamma). Stationary covariance matrix, that is, the contemporaneous covariance matrix of the data. Note that if Phi and SigmaVAR are known, Gamma can be calculated; hence, only SigmaVAR or Gamma is needed as input (if only Gamma, then use 'Gamma = Gamma' or set SigmaVAR to NULL, see examples below).

alpha

Optional. The alpha level in determining the (1-alpha)*100% CI. By default, alpha = 0.05; resulting in a 95% CI

Value

This function returns the vectorized transformed (standardized) lagged effects and - if N is part of input - their covariance matrix and the corresponding elliptical/multivariate 95% CI. If both Sigma and Gamma are not part of the input, only the transformed Phi is calculated.

Examples


# library(CTmeta)

## Example 1 ##

# Input for examples below
DeltaTStar <- 1
DeltaT <- 2
N <- 643
# Phi(DeltaT)
Phi <- myPhi[1:2,1:2]
#Phi <- matrix(c(0.25, 0.10,
#               0.20, 0.36), byrow=T, ncol = 2)
# SigmaVAR(DeltaT)
q <- dim(Phi)[1]
SigmaVAR <- diag(q) # for ease
# Calculate the Gamma corresponding to Phi and SigmaVAR - used in the second example
Gamma <- Gamma.fromVAR(Phi, SigmaVAR) # ?Gamma.fromVAR

#Example where only SigmaVAR is known and not Gamma
StandTransPhi(DeltaTStar, DeltaT, N, Phi, SigmaVAR)

#Example where only Gamma is known and not SigmaVAR
StandTransPhi(DeltaTStar, DeltaT, N, Phi, NULL, Gamma)
# or
StandTransPhi(DeltaTStar, DeltaT, N, Phi, Gamma = Gamma)


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


## Example 3: obtain only (un)standardized transformed lagged effects ##
# Note: Use Phi and SigmaVAR from Example 1
DeltaTStar <- 1
DeltaT <- 2
StandTransPhi(DeltaTStar, DeltaT, N = NULL, Phi, SigmaVAR)
# or
StandTransPhi(DeltaTStar, DeltaT, Phi = Phi, SigmaVAR = SigmaVAR)


## Example 4: obtain only (unstandardized) transformed lagged effects ##
# Note: Use Phi from Example 1
DeltaTStar <- 1
DeltaT <- 2
StandTransPhi(DeltaTStar, DeltaT, N = NULL, Phi)
# or
StandTransPhi(DeltaTStar, DeltaT, Phi = Phi)


rebeccakuiper/CTmeta documentation built on Oct. 17, 2023, 7:01 a.m.