DFM.fit#

DFM.fit()[source]#

Extract the factors, count them if unasked, and fit their VAR.

Standardizes each column by its mean and population standard deviation (a constant column keeps scale 1), selects or accepts the count, takes the principal components, and fits a VAR with no deterministic terms to the scores under the names f1 ... fr.

Return type:

DFMResult

Returns:

The fitted DFMResult.

Raises:

SpecificationError – If order is negative, from the factor VAR.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> panel = 3.0 + rng.standard_normal((120, 6)) @ rng.standard_normal((6, 6))
>>> res = DFM(panel, order=1, n_factors=2).fit()
>>> bool(np.allclose(res.means, panel.mean(axis=0)))
True
>>> bool(np.allclose(res.scales, panel.std(axis=0)))
True
>>> bool(abs(res.factors.endog.mean()) < 1e-12)
True