时间序列预测 - 不遵守上限和下限的Logistic回归

时间:2018-03-21 15:20:21

标签: r time-series regression logistic-regression facebook-prophet

我试图在这里发布大约2年的日期时间数据曲线,并预测一年的5分钟间隔。我正在Facebook Prophet使用此input data

无论我进行线性拟合还是逻辑拟合,我都会得到一些比任何输入值更大或更小的离谱值(线性模型甚至产生负值)。我试图利用逻辑模型来指定一个下限和上限,但这并没有阻止不正常的数字。

例如,在输出的105120预测记录中,25131低于指定楼层。有人可以告诉我我做错了什么吗?或者,如果存在预期的行为,我没有正确解释?

library(prophet)
library(dplyr)

url <- 'https://gist.githubusercontent.com/thomasnield/501b355a24a3a5f736b2c8510bfb0098/raw/b9dedf2f4170e3dc20cf7c1d2f39f2c2ef66b954/gistfile1.txt'

df <- read.csv(url) %>% mutate(y=log(y))

#floor and cap
lower = quantile(df$y, .05)
upper = quantile(df$y, .95)

df <- df %>% mutate(floor = lower, cap = upper)

# modeling
m <- prophet(df, 
             changepoint.prior.scale=0.01, 
             growth = 'logistic')

future <- make_future_dataframe(m, periods = (24*12*365), 
                                freq = 60 * 5, 
                                include_history = FALSE)  %>% mutate(floor = lower, cap = upper)
# forecast every 5 minutes
forecast <- predict(m,future)
#prophet_plot_components(m, forecast)

write.csv(forecast %>% 
            select(ds, yhat_lower, yhat_upper, yhat) %>% 
            mutate(floor = exp(lower), 
                   cap = exp(upper),
                   ln_yhat_lower = yhat_lower,
                   ln_yhat_upper = yhat_upper, 
                   ln_yhat = yhat,
                   ln_floor = lower, 
                   ln_cap = upper,
                   yhat_lower = exp(yhat_lower), 
                   yhat_upper = exp(yhat_upper), 
                   yhat = exp(yhat)
                   ), 'problem_output.csv')

0 个答案:

没有答案