Computes the partial correlation between Y[i] and Y[j] adjusting for the
"intervenor" variables Y[i+1], ..., Y[j-1]. Under an antedependence model
of order p, partial correlations for |i-j| > p should be approximately zero.
Value
A list with components:
- correlation
Matrix with correlations (upper triangle) and variances (diagonal)
- partial_correlation
Matrix with partial correlations (lower triangle) and variances (diagonal)
- significant
(If test=TRUE) Matrix flagging significant partial correlations (1 = significant)
- n_subjects
Number of subjects
- n_time
Number of time points
Details
The intervenor-adjusted partial correlation between Y[i] and Y[j] (i < j) is
computed as the correlation between the residuals from regressing Y[i] and Y[j]
on the intervenor set Y[i+1], ..., Y[j-1].
For adjacent time points (|i-j| = 1), the partial correlation equals the ordinary correlation since there are no intervenors.
The diagonal of both returned matrices contains variances (not correlations). This keeps scale information available alongside correlation structure.
The significance test uses an approximate threshold of 2/sqrt(n_eff), which corresponds roughly to a 95% confidence bound under normality. This is a rough screening tool, not a formal hypothesis test.
References
Zimmerman, D. L. and Nunez-Anton, V. (2009). Antedependence Models for Longitudinal Data. CRC Press.
See also
plot_prism for visual diagnostics
Examples
if (FALSE) { # \dontrun{
data("bolus_inad")
pc <- partial_corr(bolus_inad$y, test = TRUE)
# View partial correlations (lower triangle)
pc$partial_correlation
# Extract variances from the diagonal
variances <- diag(pc$partial_correlation)
# Check which are "significant" (rough screen for AD order)
pc$significant
} # }