dfm-python 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dfm_python/__init__.py +1 -1
- dfm_python/config.py +7 -4
- dfm_python/core/__init__.py +11 -0
- dfm_python/core/em.py +266 -108
- dfm_python/core/numeric.py +302 -1
- dfm_python/dfm.py +4 -2
- dfm_python/kalman.py +46 -47
- dfm_python/utils/data_utils.py +34 -1
- {dfm_python-0.2.3.dist-info → dfm_python-0.2.4.dist-info}/METADATA +58 -15
- dfm_python-0.2.4.dist-info/RECORD +21 -0
- dfm_python-0.2.3.dist-info/RECORD +0 -21
- {dfm_python-0.2.3.dist-info → dfm_python-0.2.4.dist-info}/WHEEL +0 -0
- {dfm_python-0.2.3.dist-info → dfm_python-0.2.4.dist-info}/licenses/LICENSE +0 -0
dfm_python/__init__.py
CHANGED
|
@@ -50,7 +50,7 @@ Example (Low-level API - For advanced usage):
|
|
|
50
50
|
For detailed documentation, see the README.md file and the tutorial notebooks/scripts.
|
|
51
51
|
"""
|
|
52
52
|
|
|
53
|
-
__version__ = "0.2.
|
|
53
|
+
__version__ = "0.2.4"
|
|
54
54
|
|
|
55
55
|
from .config import DFMConfig, SeriesConfig, BlockConfig, Params, DEFAULT_GLOBAL_BLOCK_NAME
|
|
56
56
|
from .config import (
|
dfm_python/config.py
CHANGED
|
@@ -224,9 +224,12 @@ class Params:
|
|
|
224
224
|
max_iter : int
|
|
225
225
|
Maximum EM iterations (default: 5000)
|
|
226
226
|
nan_method : int
|
|
227
|
-
Missing data handling method (1-5, default: 2 = spline interpolation)
|
|
227
|
+
Missing data handling method (1-5, default: 2 = spline interpolation).
|
|
228
|
+
This preprocessing step is followed by Kalman Filter-based missing data
|
|
229
|
+
handling during DFM estimation, following standard practice in state-space
|
|
230
|
+
models (Mariano & Murasawa 2003, Harvey 1989).
|
|
228
231
|
nan_k : int
|
|
229
|
-
Spline parameter for NaN interpolation (default: 3)
|
|
232
|
+
Spline parameter for NaN interpolation (default: 3 for cubic spline)
|
|
230
233
|
clock : str
|
|
231
234
|
Base frequency for all latent factors (default: 'm' for monthly)
|
|
232
235
|
clip_ar_coefficients : bool
|
|
@@ -340,8 +343,8 @@ class DFMConfig:
|
|
|
340
343
|
ar_lag: int = 1 # Number of lags in AR transition equation (lookback window)
|
|
341
344
|
threshold: float = 1e-5 # EM convergence threshold
|
|
342
345
|
max_iter: int = 5000 # Maximum EM iterations
|
|
343
|
-
nan_method: int = 2 # Missing data handling method (1-5)
|
|
344
|
-
nan_k: int = 3 # Spline parameter for NaN interpolation
|
|
346
|
+
nan_method: int = 2 # Missing data handling method (1-5). Preprocessing step before Kalman Filter-based handling
|
|
347
|
+
nan_k: int = 3 # Spline parameter for NaN interpolation (cubic spline)
|
|
345
348
|
clock: str = 'm' # Base frequency for nowcasting (global clock): 'd', 'w', 'm', 'q', 'sa', 'a' (defaults to 'm' for monthly)
|
|
346
349
|
|
|
347
350
|
# ========================================================================
|
dfm_python/core/__init__.py
CHANGED
|
@@ -12,6 +12,11 @@ This package contains core functionality organized by domain:
|
|
|
12
12
|
from .em import init_conditions, em_step, em_converged
|
|
13
13
|
from .numeric import (
|
|
14
14
|
_ensure_symmetric,
|
|
15
|
+
_ensure_real,
|
|
16
|
+
_ensure_real_and_symmetric,
|
|
17
|
+
_ensure_covariance_stable,
|
|
18
|
+
_ensure_innovation_variance_minimum,
|
|
19
|
+
_compute_covariance_safe,
|
|
15
20
|
_compute_principal_components,
|
|
16
21
|
_clean_matrix,
|
|
17
22
|
_ensure_positive_definite,
|
|
@@ -38,6 +43,11 @@ __all__ = [
|
|
|
38
43
|
'em_step',
|
|
39
44
|
'em_converged',
|
|
40
45
|
'_ensure_symmetric',
|
|
46
|
+
'_ensure_real',
|
|
47
|
+
'_ensure_real_and_symmetric',
|
|
48
|
+
'_ensure_covariance_stable',
|
|
49
|
+
'_ensure_innovation_variance_minimum',
|
|
50
|
+
'_compute_covariance_safe',
|
|
41
51
|
'_compute_principal_components',
|
|
42
52
|
'_clean_matrix',
|
|
43
53
|
'_ensure_positive_definite',
|
|
@@ -46,6 +56,7 @@ __all__ = [
|
|
|
46
56
|
'_apply_ar_clipping',
|
|
47
57
|
'_cap_max_eigenvalue',
|
|
48
58
|
'_estimate_ar_coefficient',
|
|
59
|
+
'_compute_variance_safe',
|
|
49
60
|
'_safe_divide',
|
|
50
61
|
'_check_finite',
|
|
51
62
|
'_ensure_square_matrix',
|