Explanation of Cosinor Model Parameters
Alternative Forms of the Cosinor Model
The Cosinor model can be written in two mathematically equivalent forms:
- Standard form (intuitive):
Y = M + A × cos(2π × (t – φ) / T)
where M is the mesor, A is amplitude, φ is acrophase (in hours), and T is the period. - Linear regression form (used in our implementation):
Y = Mesor + β·cos(ω·t) + γ·sin(ω·t)
whereω = 2π / T, and β and γ are fitted using linear regression. From these, we compute:- Amplitude:
A = √(β² + γ²) - Acrophase:
φ = atan2(γ, β)
- Amplitude:
The linear form allows direct estimation using linear models and enables calculation of confidence intervals and statistical significance via the delta method and F-test.
1. Mesor
The Mesor (Midline Estimating Statistic of Rhythm) is the baseline around which rhythmic variation occurs. It corresponds to the intercept in the fitted trigonometric model.
2. Amplitude
The Amplitude quantifies the strength of the rhythmic component:
Amplitude = √(β² + γ²)
Its confidence interval is derived using the delta method.
3. Acrophase
The Acrophase indicates the timing of the rhythm’s peak, first in radians:
Acrophase = atan2(γ, β)
Then converted to hours (wrapped within 0–24h):
Acrophase (hours) = ((Acrophase × 180 / π) × period / 360) mod period
4. F-statistic and p-value
The F-statistic tests whether both β and γ are significantly different from zero (i.e., whether rhythmicity is present):
F = [(SStotal - SSresidual) / 2] / (SSresidual / (n - 3))
The p-value is derived via the regularized incomplete beta function, which approximates the tail of the F-distribution.
5. Confidence Intervals
Confidence intervals (95%) for Mesor, β, and γ are computed as:
CI = estimate ± tcrit · SE
We use tcrit based on degrees of freedom (n−3). If df ≥ 30, we use a fixed tcrit ≈ 2.042.
The amplitude CI uses the delta method (with SE derived from β and γ), without including their covariance term.
Note: Results may differ slightly from other tools (e.g., cosinor2) only when those tools do not rely on a linear regression fit. All intervals in this application are derived from the underlying linear regression model. Differences may also arise from variations in error propagation (e.g., omission of the β–γ covariance term) and numerical precision.
The shaded confidence band around the fitted curve in the plot reflects the CI of the amplitude, not the CI of individual observed values. This representation shows the uncertainty of the modelled rhythm, not of individual measurements.
6. Goodness of Fit
R² expresses the proportion of explained variance:
R² = 1 − (SSresidual / SStotal)
R is the Pearson correlation between fitted and observed values.
7. Percent Rhythm
The Percent Rhythm expresses rhythmic strength as:
Percent Rhythm = R² × 100
It matches the definition used in cosinor2 and other chronobiological tools.
8. Implementation Note
All computations are implemented in PHP, using matrix algebra, inverse, and an approximation of the incomplete beta function for statistical tests. Confidence intervals are precise to 8 decimal places, based on standard regression theory.