StandPhi: Calculate standardized lagged effects matrix and accompanying...

View source: R/Calc CovMx stand Phi.r

StandPhiR Documentation

Calculate standardized lagged effects matrix and accompanying matrices

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

StandPhi(N = NULL, Phi, SigmaVAR = NULL, Gamma = NULL, alpha = 0.05)

Arguments

N

Optional. 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. By default, N = NULL.

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.

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 is set to 0.05, resulting in a 95% CI.

Value

This function returns the vectorized standardized lagged effects and - if N is part of input - their covariance matrix and the corresponding elliptical/multivariate 95% CI.

Examples


# library(CTmeta)

## 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)
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 SigmaVAR is known and Gamma unknown
StandPhi(N, Phi, SigmaVAR)

#Example where Gamma is known and SigmaVAR unknown
StandPhi(N, Phi, NULL, Gamma)
# or
StandPhi(N, Phi, Gamma = Gamma)


## 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)
StandPhi(N, out_VAR)


## Example 3: obtain only standardized lagged effects ##
Phi <- myPhi[1:2,1:2]
q <- dim(Phi)[1]
SigmaVAR <- diag(q) # for ease
#
StandPhi(N = NULL, Phi, SigmaVAR)
# or
StandPhi(Phi = Phi, SigmaVAR = SigmaVAR)


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