在我预测了预测包之后,我收到一个错误,说无法找到功能" forecast.Arima",为什么?

时间:2018-01-25 10:50:46

标签: r

我的代码是:

install.packages("forecast")
library(forecast)
fit<-auto.arima(pricetimeseries)
summary(fit)
pricetimeseriesarima<-arima(pricetimeseries, order=c(0,1,1))
forecast.Arima(pricetimeseriesarima), h=5, level=c(99.5))

然后

Error in forecast.Arima(pricetimeseriesarima, h = 5, level = c(99.5)) : 
could not find function "forecast.Arima"

我正确安装了包,并且库,它除了forecast.Arima无法正常工作,还有其他的预测。功能无法使用,如forecast.lm,forecast.HoltWinters等。

那么,这里的问题是什么,我怎么能解决呢,如果有人可以帮助我,那就太棒了,谢谢!

1 个答案:

答案 0 :(得分:0)

使用forecast()没有意义,只需使用Rob Hyndman在评论(here)的网址中所述的forecast::Arima()即可。此外,作为一般规则,您应该使用Hyndman and Athanasopoulos (2014)中所述的stats::arima()而不是set.seed(100) pricetimeseries <- rnorm(100) pricetimeseriesarima <- Arima(pricetimeseries, order=c(0,1,1)) forecast(pricetimeseriesarima, h=5, level=c(99.5))

  

R中还有另一个函数arima(),它也适合ARIMA模型。但是,除非d = 0,否则它不允许常量c,并且它不返回forecast()函数所需的所有内容。最后,它不允许将估计的模型应用于新数据(这对于检查预测准确性很有用)。因此,建议您改用Arima()。

因此:

db.Collection.aggregate([
    {$match:{ "userid":"123"}}, // filter out what's not of interest
    {$facet: { // process two stages in parallel --> this will give us a single result document with the following two fields
        "newpage": [ // "newpage" holding the ids and sums per "newpage" field
            {$group:{"_id":"$newpage", "count":{"$sum":1}}}
        ],
        "page": [ // and "page" holding the ids and sums per "page" field
            {$group:{"_id":"$page", "count":{"$sum":1}}}
        ]
    }},
    {$project: {x:{$concatArrays:["$newpage", "$page"]}}}, // merge the two arrays into one
    {$unwind: "$x"}, // flatten the single result document into multiple ones so we do not need to $reduce but can nicely $group
    {$group: {_id: "$x._id", "count": {$sum: "$x.count"}}} // perform the final grouping/counting,
    {$sort: {count: -1}} // well, the sort according to your question
]);

Hyndman,Rob J.和George Athanasopoulos。预测:原则和实践。 OTexts,2014。