Likelihood ratio test for stationarity (Gaussian AD data)
Source:R/lrt_stationarity_gau.R
test_stationarity_gau.RdTests whether time-varying Gaussian AD covariance parameters can be constrained to be constant over time.
Usage
test_stationarity_gau(
y,
order = 1L,
blocks = NULL,
constrain = "both",
fit_unconstrained = NULL,
verbose = FALSE,
max_iter = 2000L,
rel_tol = 1e-08,
...
)Arguments
- y
Numeric matrix with n_subjects rows and n_time columns.
- order
Antedependence order (0, 1, or 2).
- blocks
Optional vector of block memberships (length n_subjects).
- constrain
Constraint to test: for order 0: "sigma" (or "all"); for order 1: "phi", "sigma", or "both"/"all"; for order 2: "phi1", "phi2", "phi", "sigma", or "all"/"both".
- fit_unconstrained
Optional pre-computed unconstrained fit from
fit_gau.- verbose
Logical; if TRUE, prints fitting progress.
- max_iter
Maximum number of optimization iterations for constrained fit.
- rel_tol
Relative tolerance for constrained optimization.
- ...
Additional arguments passed to
fit_gauwhenfit_unconstrainedis not provided.
Value
A list with class "test_stationarity_gau" containing:
- method
Inference method used (
"lrt").- fit_unconstrained
Unconstrained Gaussian AD fit
- fit_constrained
Constrained Gaussian AD fit
- constraint
Human-readable null constraint description
- lrt_stat
Likelihood-ratio statistic
- df
Degrees of freedom
- p_value
Chi-square p-value
- bic_unconstrained
BIC of unconstrained model
- bic_constrained
BIC of constrained model
- bic_selected
Model selected by BIC
- table
Two-row model summary table
Details
The mean structure is kept unrestricted in both models (time-specific means plus optional block shifts), and the test constrains covariance parameters: innovation standard deviations and/or antedependence coefficients.
The likelihood-ratio statistic is: $$\lambda = 2(\ell_{alt} - \ell_{null})$$ where \(\ell_{null}\) and \(\ell_{alt}\) are maximized log-likelihoods under the constrained and unconstrained models, respectively.
Degrees of freedom are computed from the number of constraints implied by
constrain.
References
Zimmerman, D.L. and Nunez-Anton, V. (2009). Antedependence Models for Longitudinal Data. Chapman & Hall/CRC. Chapter 6.
Examples
set.seed(1)
y <- simulate_gau(n_subjects = 80, n_time = 6, order = 1, phi = 0.4, sigma = 1)
# Test jointly constant phi and sigma (order 1)
out <- test_stationarity_gau(y, order = 1, constrain = "both")
out$p_value
#> [1] 0.3343081