TransPhi_Corr: TransPhi_Corr

View source: R/Calc CovMx stand transformed Phi _ based on Corr.r

TransPhi_CorrR Documentation

TransPhi_Corr

Description

Calculates the (vectorized) transformed standardized Phi, their covariance matrix, the corresponding elliptical 95% confidence interval (CI) from a correlation matrix with contemporaneous and lagged correlations. 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

TransPhi_Corr(DeltaTStar, DeltaT = 1, N = NULL, corr_YXYX, alpha = 0.05)

Arguments

DeltaTStar

The time interval to which the 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 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.

corr_YXYX

The correlation matrix of the variables and the lagged variables (of size 2q x 2q). The upper q x q matrix is the correlation matrix between the (q) variables and the lower q x q matrix is the correlation matrix between the (q) lagged variables.

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 (i.e., for DeltaTStar) and - if N is part of input - their covariance matrix and the corresponding elliptical/multivariate 95% CI; SigmaVAR: residual covariance matrix for DeltaTStar; and Gamma: stationary covariance matrix.

Examples


# library(CTmeta)

# In the examples below, the following values are used:
DeltaTStar <- 12
DeltaT <- 24
N <- 2235

# Example with full correlation matrix
corr_YXYX <- matrix(c(1.00, 0.40, 0.63, 0.34,
0.40, 1.00, 0.31, 0.63,
0.63, 0.31, 1.00, 0.41,
0.34, 0.63, 0.41, 1.00), byrow = T, ncol = 2*2)
# Run function
TransPhi_Corr(DeltaTStar, DeltaT, N, corr_YXYX)

# Example with vector of lower triangular correlation matrix
LT <- c(0.40, 0.63, 0.34, 0.31, 0.63, 0.41) # corr_YXYX[lower.tri(corr_YXYX,diag = F)]
# Make full correlation matrix of size 2*q times 2*q, with q=2 and thus 2*q=4
corr_YXYX <- diag(4) # As check: length(LT) = 4*(4-1)/2
corr_YXYX[lower.tri(corr_YXYX,diag = F)] <- LT
corr_YXYX[upper.tri(corr_YXYX,diag = F)] <- t(corr_YXYX)[upper.tri(t(corr_YXYX),diag = F)]
# Run function
TransPhi_Corr(DeltaTStar, DeltaT, N, corr_YXYX)

# Example with vector of lower triangular correlation matrix including diagonals
LTD <- c(1.00, 0.40, 0.63, 0.34, 1.00, 0.31, 0.63, 1.00, 0.41, 1.00) # corr_YXYX[lower.tri(corr_YXYX,diag = T)]
# Make full correlation matrix of size 2*q times 2*q, with q=2 and thus 2*q=4
corr_YXYX <- matrix(NA, nrow=(4), ncol=(4))  # As check: length(LTD) = 4*(4+1)/2
corr_YXYX[lower.tri(corr_YXYX,diag = T)] <- LTD
corr_YXYX[upper.tri(corr_YXYX,diag = F)] <- t(corr_YXYX)[upper.tri(t(corr_YXYX),diag = F)]
# Run function
TransPhi_Corr(DeltaTStar, DeltaT, N, corr_YXYX)

# The output (standPhi_DeltaTStar, standSigmaVAR_DeltaTStar, and standGamma) can be used to make stacked matrices or arrays which can serve as input for continuous-time meta-analysis CTmeta (using the function CTmeta; see ?CTmeta).


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