I am forecasting a monthly time series data and want forecasted values to be displayed horizontally. Currently using forecast package i am getting those values nicely with prediction interval but in multiple rows.
Currently my output is as shown below
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
Sep 2018 6300 5287.423 7312.577 4751.396 7848.604
Oct 2018 6300 4867.999 7732.001 4109.944 8490.056
Nov 2018 6300 4546.164 8053.836 3617.740 8982.260
Dec 2018 6300 4274.845 8325.155 3202.793 9397.207
Jan 2019 6300 4035.808 8564.192 2837.217 9762.783
But i want something like this
Sep-18 Oct-18 Nov-18 Dec-18 Jan-19
6300 6300 6300 6300 6300
I am just interested in point forecast.This is to make visualisation easier as i have a handful of series to forecast. I will then just rbind each series forecasted values.
Here is my code:
library(forecast)
data = ts(c(3000,3500,2700,4200,5000,5300,5800,6300),start = c(2018,1),frequency=12)
model <- auto.arima(data)
f <- forecast(model,5)
f
Thanks
The ouput of "forecast"
function is "ts"
class, so you should convert it to "dataframe"
and then transpose a subset of it :
t(as.data.frame(f)[1])