R 是否可以将BST所做的预测仅限于正值?

R 是否可以将BST所做的预测仅限于正值?,r,time-series,forecasting,bayesian,R,Time Series,Forecasting,Bayesian,我正在学习使用R中提供的各种预测包,并遇到了bsts()。我处理的数据是需求的时间序列 data=c(27, 2, 7, 7, 9, 4, 3, 3, 3, 9, 6, 2, 6, 2, 3, 8, 6, 1, 3, 8, 4, 5, 8, 5, 4, 4, 6, 1, 6, 5, 1, 3, 0, 2, 6, 7, 1, 2, 6, 2, 8, 6, 1, 1, 3, 2, 1, 3, 1, 6, 3, 4, 3, 7, 3, 4, 1, 7, 5, 6, 3, 4, 3, 9, 2, 1,

我正在学习使用R中提供的各种预测包,并遇到了bsts()。我处理的数据是需求的时间序列

data=c(27, 2, 7, 7, 9, 4, 3, 3, 3, 9, 6, 2, 6, 2, 3, 8, 6, 1, 3, 8, 4, 5, 8, 5, 4, 4, 6, 1, 6, 5, 1, 3, 0, 2, 6, 7, 1, 2, 6, 2, 8, 6, 1, 1, 3, 2, 1, 3, 1, 6, 3, 4, 3, 7, 3, 4, 1, 7, 5, 6, 3, 4, 3, 9, 2, 1, 7, 2, 2, 9, 4, 5, 3, 4, 2, 4, 4, 8, 6, 3, 9, 2, 9, 4, 1, 3, 8, 1, 7, 7, 6, 0, 1, 4, 8, 9, 2, 5)
ts.main=ts(data, start=c(1910,1), frequency=12)
ss <- AddLocalLinearTrend(list(), y=ts.main)
ss <- AddSeasonal(ss, y=as.numeric(ts.temp), nseasons=12)
model <- bsts(as.numeric(ts.temp),
          state.specification = ss,
          niter = 1000)
pred <- predict(model, horizon = 12)
(2)2、2、3、3、3、6、6、6、2、2、2、2、2、2、3、3、3、3、3、3、3、4、5、5、5、5、5、5、5、5、5、5、5、5、4、4、4、4、4、4、4、4、4、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、4、4、4、4、4、4、4、6、6、6、6、6、6、1、1、6、1、1、1、6、6、1、6、6、6、6、6、6、6、6、6、1、6、6、6、6、6、6、6、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、5、(一、四、八、九、二、五) ts.main=ts(数据,开始=c(1910,1),频率=12)
ss由于您的数据是计数的时间序列,您需要考虑到这一点,而不是假设高斯误差;有关这方面的一些讨论和一些方法的详细说明,请参见示例和。幸运的是,
bsts
软件包为此内置了一个功能,即
系列
选项(请参见本手册第24至26页)

所以,你可以这么做

model <- bsts(as.numeric(ts.main),
              state.specification = ss,
              family = 'poisson',
              niter = 1000)

model由于您的数据是计数的时间序列,您需要考虑到这一点,而不是假设高斯误差;有关这方面的一些讨论和一些方法的详细说明,请参见示例和。幸运的是,
bsts
软件包为此内置了一个功能,即
系列
选项(请参见本手册第24至26页)

所以,你可以这么做

model <- bsts(as.numeric(ts.main),
              state.specification = ss,
              family = 'poisson',
              niter = 1000)

模型这是一个计数时间序列吗?是的,这是一个计数时间序列。这是一个计数时间序列吗?是的,这是一个计数时间序列。非常感谢,我将浏览您提供的参考资料。非常感谢,我将浏览您提供的参考资料。