environmentaltools.temporal.nonstationary_analysis
- environmentaltools.temporal.nonstationary_analysis(df: DataFrame, param: dict)[source]
Perform non-stationary probability analysis with time-varying parameters.
Conducts non-stationary analysis where distribution parameters vary over time using Fourier expansions or other basis functions. Automatically selects the best model based on BIC or negative log-likelihood criteria.
- Parameters:
df (pd.DataFrame) – Time series data containing the variable and time information
param (dict) –
Configuration dictionary containing:
- ’var’str
Variable name to analyze
- ’basis_function’dict
Basis function specification with ‘order’ key
- ’bic’bool
If True, use BIC for model selection; else use NLLF
- ’no_fun’int
Number of distribution functions
- ’initial_parameters’dict
Contains ‘make’ (bool) and ‘mode’ (list) for custom initialization
- Returns:
Updated param dictionary with fitted results:
- ’par’list
Fitted parameters for the selected model
- ’mode’list
Selected Fourier mode orders for each parameter
- ’all’list
All tested models with [mode_str, bic, parameters]
- Return type:
dict
Notes
The function tests multiple Fourier expansion modes and selects the best one based on either Bayesian Information Criterion (BIC) or negative log-likelihood (NLLF). Lower values indicate better fit.
For stationary cases (order=0), mode is set to zeros.
Model selection prioritizes: 1. BIC if param[‘bic’] is True (penalizes complexity) 2. NLLF otherwise (pure likelihood fit)
See also
nonst_fitCore fitting function called internally
stationary_analysisFor time-invariant parameter fitting
Examples
>>> param = { ... 'var': 'Hs', ... 'basis_function': {'order': 2}, ... 'bic': True, ... 'no_fun': 1, ... 'initial_parameters': {'make': False} ... } >>> param = nonstationary_analysis(df, param) >>> print(f"Selected mode: {param['mode']}") >>> print(f"Parameters: {param['par']}")