def model_dfm(endog=None, params=None, factor_order=2): if endog is None: levels = macrodata[['realgdp', 'realcons']] endog = np.log(levels).iloc[:21].diff().iloc[1:] * 400 if params is None: params = np.r_[0.5, 1., 1.5, 2., 0.9, 0.1] # Model mod = DynamicFactor(endog, k_factors=1, factor_order=factor_order) mod.update(params) ssm = mod.ssm ssm.filter_univariate = True init = Initialization(ssm.k_states, 'diffuse') ssm.initialize(init) return mod, ssm
def model_dfm(endog=None, params=None, factor_order=2): if endog is None: endog = (np.log( macrodata[['realgdp','realcons']]).iloc[:21].diff().iloc[1:] * 400) if params is None: params = np.r_[0.5, 1., 1.5, 2., 0.9, 0.1] # Model mod = DynamicFactor(endog, k_factors=1, factor_order=factor_order) mod.update(params) ssm = mod.ssm ssm.filter_univariate = True init = Initialization(ssm.k_states, 'diffuse') ssm.initialize(init) return mod, ssm