plotPrediction: Plot prediction based on a time series

Description Usage Arguments Value Examples

View source: R/timeseries.R

Description

This plots estmated value vs observed for a given time series. It also visualized upper and lower level for that estimate.

Usage

1

Arguments

preddf

the prediction data to plot

Value

a ggplot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(ggplot2)
library(dplyr)
data(economics)
myfit <- lm(unemploy ~ pop + psavert, data = economics)
preddf <- predict(myfit, interval = "predict") %>% as_tibble()
preddf <- preddf %>% transmute(
  date = as.Date(economics$date),
  observed = economics$unemploy,
  estimate = fit,
  lower = lwr,
  upper = upr
)
plotPrediction(preddf)

DoktorMike/datools documentation built on Feb. 28, 2021, 8:39 a.m.