Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ All notable changes to TEPP are documented here. The format follows Keep a Chang

## [Unreleased]

- `psychometric_core` recovers the Driver, Oud, and Voelkle (2017, Table 2, p. 12 `TDPREDVAR`; p. 16 `TDPREDVARstd`; footnote 4; 2017-era ctsem `summary.ctsemFit.R`; JSS PDF re-opened 2026-08-31T01:16Z from https://www.jstatsoft.org/index.php/jss/article/download/v077i05/1104) scalar standardised time-dependent predictor variance on current main (register items 106–107). Table 2 names `TDPREDVAR` the variance / covariance matrix of time dependent predictors and defaults it to 0. Page 16 prints standardised matrices with the suffix `std` when appropriate. The printed example on p. 16 is `discreteDRIFTstd`, not `TDPREDVARstd`. Footnote 4 standardises using only the relevant variance, not the total. The relevant variance for that named time-dependent predictor correlation is `TDPREDVAR` itself, not `TIPREDVAR` and not residual `MANIFESTVAR`. The 2017-era source forms `TDPREDVARstd` whenever `verbose = TRUE` and `n.TDpred > 0`, as `solve(sqrt(TDPREDVARdiag)) %&% TDPREDVAR` with `TDPREDVARdiag = diag((diag(TDPREDVAR))+diag(ridging,n.TDpred))`. OpenMx `%&%` is `t(A) %*% B %*% A`. Unlike `TRAITVARstd`, that formation adds `diag(ridging, n.TDpred)`. The default `ridging = FALSE` adds 0, not `0.0001`; that ridge is a numerical hack and is not this exact map. The 2017-era source assigns `dimnames(TDPREDVARstd)` to `TDpredNames`. The ridge length `n.TDpred` rather than `n.TDpred × Tpoints` is a source bug when the predictor matrix is stacked over occasions and is not this exact map. The scalar correlation is `v / v = 1` after strictly positive `TDPREDVAR`. Form strictly positive `v` first, then `1 / √v`, then `(1 / √v) v (1 / √v)`. Unstandardised `TDPREDVAR` is defined for a zero predictor; standardised `TDPREDVAR` is not. Zero `v` makes `solve(sqrt(0))` fail in the 2017-era source and fails closed here. Unlike `TRAITVAR` / `MANIFESTTRAITVAR`, that source does not skip forming `TDPREDVARstd` when `v = 0`. Time-dependent predictor variance is an event-time structural quantity, so a non-event clock fails closed. `TDPREDVAR` does not require stable `a < 0`. Distinct positive `v` recover the same 1. `v / v = 1` is `TIPREDVARstd` and recovers the same number and remains a distinct named quantity. `θ / θ = 1` is `MANIFESTVARstd` and recovers the same number and remains a distinct named quantity. Meredith (1993) remains unread as a cited source for this slice. Mislevy (1991, *Psychometrika, 56*, 177–196) remains unread on the same terms (DOI `10.1007/bf02294457`). Still not a Kalman filter, not a matrix `expm`, not ESEM estimation, not DSEM, and not ctsem estimation.

- `event_core` adds bounded Allen interval-consistency classification, atomic path-consistency closure, contradiction/resource refusals, and an explicit dependency-error fallback without claiming unrestricted global satisfiability.

- `psychometric_core` recovers the Driver, Oud, and Voelkle (2017, Table 2, p. 12 `MANIFESTTRAITVAR`; §7.1, p. 19; p. 16 `MANIFESTTRAITVARstd`; footnote 4; 2017-era ctsem `summary.ctsemFit.R`; JSS PDF re-opened 2026-08-27T14:20Z from https://www.jstatsoft.org/index.php/jss/article/download/v077i05/1104) scalar standardised manifest-trait variance on current main after `0ce16e8` dropped the pre-consolidation code while research notes already named the map (register items 83–84). Table 2 names `MANIFESTTRAITVAR` `Ψ_τ` the additional time-invariant variance-covariance on the measurement level and sets it `NULL` when there is no manifest trait. Equation 5 writes `Γ ~ N(τ, Ψ)` and names that covariance the manifest traits. Section 7.1 names manifest traits stable individual differences in indicator levels, distinct from process-level `TRAITVAR` `φ_ξ`. Page 16 prints standardised matrices with the suffix `std` when appropriate. The printed example on p. 16 is `discreteDRIFTstd`, not `MANIFESTTRAITVARstd`. Footnote 4 standardises using only the relevant variance, not the total. The relevant variance for that named indicator-level correlation is `MANIFESTTRAITVAR`, not process-level `TRAITVAR` and not residual `MANIFESTVAR` `θ`. The 2017-era source forms `MANIFESTTRAITVARstd` only when `MANIFESTTRAITVAR != 0`, as `solve(sqrt(diag(MANIFESTTRAITVAR) + ridging)) %&% MANIFESTTRAITVAR` when `verbose = TRUE`. OpenMx `%&%` is `t(A) %*% B %*% A`. Unlike `TRAITVARstd`, that formation adds `diag(c(ridging), n.manifest)`. The default `ridging = FALSE` adds 0, not `0.0001`; that ridge is a numerical hack and is not this exact map. The scalar correlation is `ψ / ψ = 1` after strictly positive `MANIFESTTRAITVAR`. Form strictly positive `ψ` first, then `1 / √ψ`, then `(1 / √ψ) ψ (1 / √ψ)`. Unstandardised `MANIFESTTRAITVAR` is defined for a zero trait; standardised `MANIFESTTRAITVAR` is not. Zero `MANIFESTTRAITVAR` skips forming `MANIFESTTRAITVARstd` in the 2017-era source and fails closed here. Indicator-level trait variance is an event-time structural quantity, so a non-event clock fails closed. `MANIFESTTRAITVAR` does not require stable `a < 0`. Distinct positive `ψ` recover the same 1. `trait / trait = 1` is `TRAITVARstd` and recovers the same number and remains a distinct named quantity. `θ` is `MANIFESTVAR` and is measurement error, not this correlation. Meredith (1993) remains unread (web search 2026-08-27T14:20Z: Springer/Cambridge Core paywalled; Unpaywall historically `is_oa: false`; Springer `content/pdf` is an HTML stub). Mislevy (1991, *Psychometrika, 56*, 177–196) remains unread on the same terms (DOI `10.1007/bf02294457`). Still not a Kalman filter, not a matrix `expm`, not ESEM estimation, not DSEM, and not ctsem estimation.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions crates/psychometric_core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,31 @@ pub enum PsychometricError {
/// `MANIFESTVARstd`. `λ² Var(η) + θ` is `Var(y)`, not the
/// correlation form of `Θ`.
ObservedVarianceIsNotStandardisedManifestVariance,

/// Driver p. 16 `TDPREDVARstd` was requested with a non-positive
/// time-dependent predictor variance. Unlike `TRAITVAR` /
/// `MANIFESTTRAITVAR`, the 2017-era source still forms
/// `TDPREDVARstd` when `TDPREDVAR == 0`; `solve(sqrt(0))`
/// fails. Footnote 4 standardisation requires strictly
/// positive `TDPREDVAR`.
StandardisedTimeDependentPredictorVarianceRequiresPositivePredictorVariance,
/// Driver Table 2 unstandardised `TDPREDVAR` was treated as
/// p. 16 `TDPREDVARstd`. Unstandardised time-dependent
/// predictor variance is defined for a zero predictor;
/// standardised `TDPREDVAR` is not.
UnstandardisedTimeDependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance,
/// Driver p. 16 `TIPREDVARstd` was treated as p. 16
/// `TDPREDVARstd`. Equal numbers when both correlations equal
/// 1 are still distinct named quantities. `TIPREDVAR` is the
/// time-independent predictor covariance; `TDPREDVAR` is the
/// time-dependent predictor covariance.
StandardisedTimeIndependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance,
/// Driver p. 16 `MANIFESTVARstd` was treated as p. 16
/// `TDPREDVARstd`. Equal numbers when both correlations equal
/// 1 are still distinct named quantities. `MANIFESTVAR` is
/// contemporaneous measurement error; `TDPREDVAR` is the
/// time-dependent predictor covariance.
StandardisedManifestVarianceIsNotStandardisedTimeDependentPredictorVariance,
}

impl fmt::Display for PsychometricError {
Expand Down Expand Up @@ -1235,6 +1260,18 @@ impl fmt::Display for PsychometricError {
Self::ObservedVarianceIsNotStandardisedManifestVariance => {
"observed-indicator variance is not standardised measurement-error variance"
}
Self::StandardisedTimeDependentPredictorVarianceRequiresPositivePredictorVariance => {
"standardised time-dependent predictor variance requires strictly positive time-dependent predictor variance"
}
Self::UnstandardisedTimeDependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance => {
"unstandardised time-dependent predictor variance is not standardised time-dependent predictor variance"
}
Self::StandardisedTimeIndependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance => {
"standardised time-independent predictor variance is not standardised time-dependent predictor variance"
}
Self::StandardisedManifestVarianceIsNotStandardisedTimeDependentPredictorVariance => {
"standardised measurement-error variance is not standardised time-dependent predictor variance"
}
};
formatter.write_str(message)
}
Expand Down Expand Up @@ -2073,4 +2110,28 @@ mod tests {
"measurement error is not standardised manifest-trait variance"
);
}

#[test]
fn standardised_time_dependent_predictor_variance_boundary_messages_are_stable() {
assert_eq!(
PsychometricError::StandardisedTimeDependentPredictorVarianceRequiresPositivePredictorVariance
.to_string(),
"standardised time-dependent predictor variance requires strictly positive time-dependent predictor variance"
);
assert_eq!(
PsychometricError::UnstandardisedTimeDependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance
.to_string(),
"unstandardised time-dependent predictor variance is not standardised time-dependent predictor variance"
);
assert_eq!(
PsychometricError::StandardisedTimeIndependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance
.to_string(),
"standardised time-independent predictor variance is not standardised time-dependent predictor variance"
);
assert_eq!(
PsychometricError::StandardisedManifestVarianceIsNotStandardisedTimeDependentPredictorVariance
.to_string(),
"standardised measurement-error variance is not standardised time-dependent predictor variance"
);
}
}
158 changes: 157 additions & 1 deletion crates/psychometric_core/src/event_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@
//! (`T0MEANS` is not `μ_t`; `CINT` is not that discrete increment). Equation 3's
//! fourth summand is the contemporaneous Dirac impulse `M x` (Table 2
//! `TDPREDEFFECT` is `M`, not `CINT`, not `TIPREDEFFECT`, and not
//! Voelkle et al., 2012, Eq. 14). Equations 1–2 plus the Eq. 3
//! Voelkle et al., 2012, Eq. 14). Table 2 names `TDPREDVAR` the
//! variance / covariance of those time-dependent predictors.
//! Page 16 `TDPREDVARstd` is `v / v = 1` after strictly positive
//! `TDPREDVAR` (footnote 4; 2017-era `summary.ctsemFit.R`; JSS PDF
//! re-opened 2026-08-31T01:16Z). Unstandardised `TDPREDVAR` is not
//! that correlation. `TIPREDVARstd` and `MANIFESTVARstd` recover
//! the same 1 and remain distinct named quantities. Equations 1–2 plus the Eq. 3
//! exponential map a time-dependent impulse that occurred strictly
//! inside `(t0, t)` as `e^{A(t−u)} M x` (`t0 < u < t`). That carry
//! is not the contemporaneous Dirac, not `CINT`, not `TIPREDEFFECT`,
Expand Down Expand Up @@ -1630,6 +1636,156 @@ pub fn refuse_observed_variance_as_standardised_manifest_variance(
Err(PsychometricError::ObservedVarianceIsNotStandardisedManifestVariance)
}

/// Exact scalar p. 16 `TDPREDVARstd` after strictly positive
/// `TDPREDVAR`.
///
/// Driver, Oud, and Voelkle (2017, Table 2, p. 12; p. 16; footnote
/// 4; 2017-era ctsem `summary.ctsemFit.R`; JSS PDF re-opened
/// 2026-08-31T01:16Z from
/// <https://www.jstatsoft.org/index.php/jss/article/download/v077i05/1104>)
/// name `TDPREDVAR` the variance / covariance matrix of time
/// dependent predictors and default it to 0. Page 16 prints
/// standardised matrices with the suffix `std` when appropriate.
/// The printed example on p. 16 is `discreteDRIFTstd`, not
/// `TDPREDVARstd`. Footnote 4: standardisations use only the
/// relevant variance, not the total. The relevant variance for
/// that named time-dependent predictor correlation is `TDPREDVAR`
/// itself, not `TIPREDVAR` and not residual `MANIFESTVAR`. The
/// 2017-era `summary.ctsemFit.R` forms `TDPREDVARstd` whenever
/// `verbose = TRUE` and `n.TDpred > 0`, as
/// `solve(sqrt(TDPREDVARdiag)) %&% TDPREDVAR` with
/// `TDPREDVARdiag = diag((diag(TDPREDVAR))+diag(ridging,n.TDpred))`.
/// `OpenMx` `%&%` is the quadratic form `t(A) %*% B %*% A`. Unlike
/// `TRAITVARstd`, that formation adds `diag(ridging, n.TDpred)`.
/// The default `ridging = FALSE` adds 0, not `0.0001`; that ridge
/// is a numerical hack and is not this exact map. The 2017-era
/// source assigns `dimnames(TDPREDVARstd)` to `TDpredNames`. The
/// ridge length `n.TDpred` rather than `n.TDpred × Tpoints` is a
/// source bug when the predictor matrix is stacked over occasions
/// and is not this exact map. The scalar correlation is
/// `v / v = 1` after strictly positive `TDPREDVAR`. Form strictly
/// positive `v` first, then `1 / √v`, then `(1 / √v) v (1 / √v)`.
/// Unstandardised `TDPREDVAR` is defined for a zero predictor;
/// standardised `TDPREDVAR` is not. Zero `v` makes
/// `solve(sqrt(0))` fail in the 2017-era source and fails closed
/// here. Unlike `TRAITVAR` / `MANIFESTTRAITVAR`, that source does
/// not skip forming `TDPREDVARstd` when `v = 0`; the quadratic
/// still fails. Time-dependent predictor variance is an event-time
/// structural quantity, so a non-event clock fails closed.
/// `TDPREDVAR` does not require stable `a < 0`. Distinct positive
/// `v` recover the same 1. `TIPREDVARstd` `v / v = 1` recovers the
/// same number and remains a distinct named quantity. This crate
/// does not currently export `TIPREDVARstd`; the refuse still
/// names that quantity. `MANIFESTVARstd` `θ / θ = 1` recovers the
/// same number and remains a distinct named quantity. This is not
/// a Kalman filter, not a matrix `expm`, not DSEM, and not ctsem
/// estimation.
///
/// # Errors
///
/// Returns [`PsychometricError::EventTimeRequired`] for any
/// non-event clock,
/// [`PsychometricError::StandardisedTimeDependentPredictorVarianceRequiresPositivePredictorVariance`]
/// when `TDPREDVAR` is zero, and
/// [`PsychometricError::InvalidNumericInput`] when the variance is
/// non-finite, negative, or the quadratic form overflows.
pub fn recover_standardised_time_dependent_predictor_variance(
time_dependent_predictor_variance: f64,
clock: LagClock,
) -> Result<f64, PsychometricError> {
if !clock.admits_structural_lag() {
return Err(PsychometricError::EventTimeRequired);
}
if !time_dependent_predictor_variance.is_finite() || time_dependent_predictor_variance < 0.0 {
return Err(PsychometricError::InvalidNumericInput);
}
if time_dependent_predictor_variance == 0.0 {
return Err(
PsychometricError::StandardisedTimeDependentPredictorVarianceRequiresPositivePredictorVariance,
);
}
let process_sd = time_dependent_predictor_variance.sqrt();
let inverse_sd = require_finite(1.0 / process_sd)?;
let scaled = require_finite(inverse_sd * time_dependent_predictor_variance)?;
require_finite(scaled * inverse_sd)
}

/// Refuse treating unstandardised `TDPREDVAR` as p. 16
/// `TDPREDVARstd`.
///
/// Unstandardised `TDPREDVAR` is defined for a zero predictor.
/// Footnote 4 `TDPREDVARstd` requires strictly positive
/// `TDPREDVAR`. Equal numbers when `v = 1` are still distinct
/// named quantities.
///
/// # Errors
///
/// Always returns
/// [`PsychometricError::UnstandardisedTimeDependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance`].
pub fn refuse_unstandardised_time_dependent_predictor_variance_as_standardised_time_dependent_predictor_variance(
unstandardised_time_dependent_predictor_variance: f64,
standardised_time_dependent_predictor_variance: f64,
) -> Result<f64, PsychometricError> {
let _ = (
unstandardised_time_dependent_predictor_variance,
standardised_time_dependent_predictor_variance,
);
Err(
PsychometricError::UnstandardisedTimeDependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance,
)
}

/// Refuse treating p. 16 `TIPREDVARstd` as p. 16 `TDPREDVARstd`.
///
/// Both scalar correlations equal 1 after strictly positive
/// variances. `TIPREDVARstd` standardises time-independent
/// predictor variance. `TDPREDVARstd` standardises time-dependent
/// predictor variance. Equal numbers remain distinct named
/// quantities. This crate does not currently export
/// `TIPREDVARstd`; the refuse still names that quantity.
///
/// # Errors
///
/// Always returns
/// [`PsychometricError::StandardisedTimeIndependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance`].
pub fn refuse_standardised_time_independent_predictor_variance_as_standardised_time_dependent_predictor_variance(
standardised_time_independent_predictor_variance: f64,
standardised_time_dependent_predictor_variance: f64,
) -> Result<f64, PsychometricError> {
let _ = (
standardised_time_independent_predictor_variance,
standardised_time_dependent_predictor_variance,
);
Err(
PsychometricError::StandardisedTimeIndependentPredictorVarianceIsNotStandardisedTimeDependentPredictorVariance,
)
}

/// Refuse treating p. 16 `MANIFESTVARstd` as p. 16 `TDPREDVARstd`.
///
/// Both scalar correlations equal 1 after strictly positive
/// variances. `MANIFESTVARstd` standardises contemporaneous
/// measurement error `Θ`. `TDPREDVARstd` standardises
/// time-dependent predictor variance. Equal numbers remain
/// distinct named quantities.
///
/// # Errors
///
/// Always returns
/// [`PsychometricError::StandardisedManifestVarianceIsNotStandardisedTimeDependentPredictorVariance`].
pub fn refuse_standardised_manifest_variance_as_standardised_time_dependent_predictor_variance(
standardised_manifest_variance: f64,
standardised_time_dependent_predictor_variance: f64,
) -> Result<f64, PsychometricError> {
let _ = (
standardised_manifest_variance,
standardised_time_dependent_predictor_variance,
);
Err(
PsychometricError::StandardisedManifestVarianceIsNotStandardisedTimeDependentPredictorVariance,
)
}

/// Refuse treating `τ / √(λ² Var(η) + θ)` as p. 16
/// `MANIFESTMEANSstd`.
///
Expand Down
Loading
Loading