Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove grey background confidence interval from forecasting plot

Tags:

r

I created the forecasting plot with the point forecast and confidence interval. However, i only want the point forecast(blue line) without the confidence interval(the grey background). How do i do that? Below is my current code and the screenshot of my plot.

  plot(snv.data$mean,main="Forecast for monthly Turnover in Food   
  Retailing",xlab="Years",ylab="$ million",+ geom_smooth(se=FALSE))

like image 358
Lê Đạt Avatar asked Mar 20 '17 06:03

Lê Đạt


People also ask

How do you get rid of confidence intervals in R?

The ggplot function builds a confidence interval (the gray area) around the line as a default. It is easy to remove the confidence interval. Just add se = FALSE to the geom_smooth argument.

Why is prediction interval wider?

Second, the prediction interval is much wider than the confidence interval. This is because expresses more uncertainty. On top of the sampling uncertainty, the prediction interval also expresses inherent uncertainty in the particular data point.


1 Answers

Currently it seems to me that you try a mixture between the base function plot and the ggplot2 function geom_smooth. I don't think it is a very good idea in this case.

Since you want to use geom_smooth why not try to do it all with `ggplot2'?

Here is how you would do it with ggplot2 ( I used R-included airmiles data as example data)

library(ggplot2)
data = data.frame("Years"=seq(1937,1960,1),"Miles"=airmiles) #Creating a sample dataset

ggplot(data,aes(x=Years,y=Miles))+ 
        geom_point()+ 
        geom_smooth(se=F) 

With ggplot you can set options like your x and y variables once and for all in the aes() of your ggplot() call, which is the reason why I didnt need any aes() call for geom_point().

Then I add the smoother function geom_smooth(), with option se=F to remove the confidence interval

like image 190
Tim17 Avatar answered Oct 12 '22 00:10

Tim17