zesla
zesla

Reputation: 11793

How to control the confidence interval in autoplot.forecast?

After forecasting a time series, we can use autoplot to plot the time series, along with its predictions. I'm using the forecast package. But I want to control the confidence interval in the forecasted part. How do I make the plot show only 95% interval or only 80% interval, or not showing intervals at all. I set the argument conf.int to FALSE. But it does not seem to suppress the conf interval in the plot. Can anyone help to make it work? Thanks.

fc <- ses(AirPassengers, h = 5)
autoplot(fc, conf.int = F)

Upvotes: 1

Views: 4184

Answers (1)

Rob Hyndman
Rob Hyndman

Reputation: 31800

The help files are very instructive. Read them. From ?forecast you'll find this line:

level Confidence level for prediction intervals.

and from ?autoplot.forecast you will learn the following argument:

PI Logical flag indicating whether to plot prediction intervals.

So you can do what you want as follows:

# Show 95% interval
fc <- ses(AirPassengers, h = 5, level=95)
autoplot(fc)
# Show no intervals
autoplot(fc, PI = FALSE)

Upvotes: 5

Related Questions