cedalion.math package
Submodules
cedalion.math.ar_irls module
- cedalion.math.ar_irls.ar_irls_GLM(
- y,
- x,
- pmax: int | None = 40,
- M=<statsmodels.robust.norms.TukeyBiweight object>,
This function implements the AR-IRLS GLM model.
The autoregressive iteratively reweighted least squares GLM model is described in Barker et al. [BAH13]. By estimating prewhitening filters it addresses serial correlations and confounding noise components in the signal and avoids the inflated false positive rates observed when fitting the GLM with ordinary least squares.
- Parameters:
y – Dependent variable time series (pandas Series or NDTimeSeries with a
"time"dimension).x – Design matrix (pandas DataFrame).
pmax – Maximum AR model order to consider. If
None, set to2 × ceil(sampling_rate). A value of 4–5× the sampling rate is sufficient; do not set it excessively high as it reduces the number of usable time points.M – Robust norm for the IRLS step (default: Tukey bi-weight,
c=4.685). Tuning constant reference values: 4.685 → 95% efficiency, 4.00 → ~90%, 3.55 → ~85%.
- Returns:
Fitted
statsmodels.RLMresults object containing betas, t-stats, and residuals after prewhitening.
Note
Do not low-pass filter before calling this function — the AR step needs access to the full spectrum to estimate stable prewhitening filters. High-pass filtering is acceptable; prefer Legendre polynomials or discrete cosine terms in the design matrix over regular polynomials.
- Initial Contributors:
Ted Huppert | huppert1@pitt.edu | 2024
cedalion.math.ar_model module
- cedalion.math.ar_model.bic_arfit(dd, pmax=30)[source]
This function computes the ar coefficients up to a max model order.
BIC is used to select the model
- Parameters:
dd – pd.Series
pmax – int (default 30)
- Returns:
sm.tsa.AutoReg results class (includes intercept term)
cedalion.math.resample module
cedalion.math.stats_helpers module
- cedalion.math.stats_helpers.BenjaminiHochberg(p: ndarray)[source]
Apply Benjamini-Hochberg FDR correction for multiple comparisons.
See http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3530395/
- Parameters:
p – Array of uncorrected p-values, arbitrary shape.
- Returns:
Array of FDR-corrected q-values, same shape as
p, clipped to [0, 1].
Module contents
Autoregressive Modeling, Stats Helpers and (Re-)Sampling.