Skip to contents

Builds the \(p \times p\) first-order autoregressive covariance matrix \(\Sigma = (\rho^{|i-j|})_{i,j}\), the intercorrelation structure imposed on the mediator noise throughout the article's Monte Carlo studies. It is exported as a small reusable utility so a user can inspect or reuse the exact covariance the simulations use.

Usage

mediation_ar1_cov(p, rho = 0.5)

Arguments

p

Number of mediators (matrix dimension); a positive integer.

rho

Autocorrelation parameter in \((-1, 1)\). The covariance between mediators \(i\) and \(j\) is \(\rho^{|i-j|}\), so nearby mediators are more strongly correlated and the correlation decays geometrically with separation. Default 0.5, the value used in the article.

Value

A \(p \times p\) numeric matrix with ones on the diagonal and \(\rho^{|i-j|}\) off the diagonal.

Author

Xiufan Yu and Ken Kelley

Examples

mediation_ar1_cov(4, rho = 0.5)
#>       [,1] [,2] [,3]  [,4]
#> [1,] 1.000 0.50 0.25 0.125
#> [2,] 0.500 1.00 0.50 0.250
#> [3,] 0.250 0.50 1.00 0.500
#> [4,] 0.125 0.25 0.50 1.000