R Matrix Lab 1 — Covariance Geometry
R Matrix Lab 1 — Covariance Geometry
Question
How can a proposed autocovariance sequence become a valid finite-dimensional distribution?
For a weakly stationary process,
The matrix must be symmetric and positive semidefinite because, for every ,
Example 1 — AR(1) Toeplitz structure
For
stationarity requires and
The first column of is therefore
Build and audit an AR(1) covariance matrix
Read the output
- Equal diagonals confirm Toeplitz structure.
- Positive eigenvalues establish positive definiteness for this finite block.
- The Cholesky error checks the factorisation numerically.
- The quadratic-form check connects a matrix calculation to a familiar variance.
Change to . The first off-diagonal changes sign, but the matrix remains positive definite. Change it to : the process is still stationary, but the condition number rises because neighbouring variables become nearly redundant.
Example 2 — Gaussian simulation by a matrix square root
Let and choose with . Then
has mean and covariance .
R returns with , so use .
Simulate Gaussian blocks with a Cholesky factor
The empirical error will not be exactly zero because only finitely many blocks were simulated. Increase replications by a factor of four: Monte Carlo error should shrink by roughly a factor of two.
Why pairwise correlations are not enough
Values satisfying do not automatically form a valid autocorrelation sequence. All finite Toeplitz blocks must be positive semidefinite. A proposed sequence can pass every pairwise bound and still produce a negative eigenvalue.
This is the matrix reason that an ACF cannot be invented one lag at a time.
Exercises
- With and innovation variance 2, calculate and by hand.
- Replace
gammabyc(1, 0.9, -0.9)and inspect the eigenvalues oftoeplitz(gamma). Is it a valid three-lag covariance block? - Show algebraically that .
- Compare the condition numbers for , , , and . Explain the statistical meaning.
- Graduate extension: prove that every principal submatrix of a positive semidefinite matrix is positive semidefinite.
Checkpoints
- and .
- It has a negative eigenvalue, so satisfying the individual bounds was insufficient.
- Expand .
- Near one, adjacent coordinates are almost collinear; separating long-run level variation from persistence becomes numerically and statistically difficult.
Completion standard
You should be able to build from , justify positive semidefiniteness with quadratic forms, and use Cholesky reconstruction as a reproducible numerical check.
Continue to Lab 2 — AR Recursions.
R Matrix Laboratory
Four browser-based base R laboratories for covariance matrices, AR recursions, linear prediction, likelihood, and state space.
R Matrix Lab 2 — AR Recursions and Yule–Walker Equations
Convert AR models to companion form, compare polynomial roots with eigenvalues, propagate shocks, and recover coefficients from autocovariances.