我试图复制一个在R中工作的BSTS模型 例如:
ss <- list()
ss <- AddLocalLevel(ss, train_serie)
model <- bsts(train_serie, state_specification=ss, niter=500, ping=0, seed=510)
burn <- SuggestBurn(0.1, model)
其中train_serie是我想要用来预测的价值列表
使用PyBsts库在python中似乎是等效的,我无法使用相同的数据重现相同的结果
下面是python代码:
import pybsts
import numpy as np
import pandas as pd
# I skipped the code where I import the df
# creation of an np array as input
y = df.loc['20180101':'20181201', 'value'].astype(float).values
specification = {"ar_order": 1,
"local_trend": {"local_level": True},
"sigma_prior": np.std(y, ddof=1),
"initial_value": y[0]}
b = pybsts.PyBsts("gaussian", specification, {"ping": 0,
"niter":12,
"seed": 510,
"burn": 0.1})
b.fit(y, seed=510)
res = b.predict(seed=510)
print(res)
我试图找到比R one更多的文档和Pypi上可用的小示例,但没有成功
目前没有回答
相关问题 更多 >
编程相关推荐