我估算了VECM,然后想对估算的模型进行检查。因此,我期望拟合值将完全满足模型要求。但是,我发现事实并非如此。
model = vecm.VECM(df.values, k_ar_diff = 3, coint_rank = 1, deterministic="nc")
modelres = model.fit()
n = modelres.nobs
l = modelres.k_ar
fv = modelres.fittedvalues.T # fitted values - neq x nobs
Phi = modelres.var_rep # VAR in levels
Ybar = np.column_stack([np.sum(np.column_stack([Phi[i,:,:] @ fv[:,j-i] for i in range(l)]),axis = 1) for j in range(l-1,nobs-1)])
上面的Ybar与我期望的fv不匹配。
预先感谢
答案 0 :(得分:1)
玩了以下作品之后:
model = vecm.VECM(df.values, k_ar_diff = 3, coint_rank = 1, deterministic="nc")
modelres = model.fit()
n = modelres.nobs
l = modelres.k_ar
fv = modelres.y_all[:,l:]
Ybar = np.column_stack([np.sum(np.column_stack([Phi[i,:,:] @ fv[:,j-i] for i in range(l)]),axis = 1) for j in range(l-1,nobs-1)])
np.max(np.abs(modelres.fittedvalues.T[:,l:] - Ybar)) # check. will be close to 0!
因此,通过在嘈杂的数据上运行模型来生成model.fittedvalues。谢谢