calc.CovMxStandPhi: calc.CovMxStandPhi

View source: R/HelpFiles_Calc CovMx stand Phi.r

calc.CovMxStandPhiR Documentation

calc.CovMxStandPhi

Description

This function calculates the (vectorized) standardized lagged effects matrix, their covariance matrix, and corresponding 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

calc.CovMxStandPhi(N, Phi, Gamma = NULL, SigmaVAR = NULL, alpha = 0.05)

Arguments

N

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

Phi

(Un)standardized lagged effects matrix. If necessary, it is standardized and for the standardized and 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.

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).

SigmaVAR

Residual covariance matrix of the first-order discrete-time vector autoregressive (DT-VAR(1)) model. 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

The alpha level in determining the (1-alpha)*100% CI. By default, alpha is set to 0.05, resulting in a 95% CI.

Value

This function returns the vectorized standardized lagged effects, their covariance matrix, and the corresponding elliptical/multivariate 95% CI.

Examples

## Example 1 ##

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

#Example where only SigmaVAR is known and not Gamma
calc.CovMxStandPhi(N, Phi, NULL, SigmaVAR)
# or
calc.CovMxStandPhi(N, Phi, SigmaVAR = SigmaVAR)

#Example where only Gamma is known and not SigmaVAR
calc.CovMxStandPhi(N, Phi, Gamma)
# or
calc.CovMxStandPhi(N, Phi, Gamma, NULL)


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


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