expected_diagnostic: Diagnostic Plots for Model Fit

Description Usage Arguments Value Examples

View source: R/expected_diagnostic.R

Description

Check mean model fit via diagnostic figures of the model components

Usage

1
2
3
4
5
6
7
expected_diagnostic(
  expected,
  start = NULL,
  end = NULL,
  color = "#D22B2B",
  alpha = 0.5
)

Arguments

expected

The output from 'excess_counts' with 'keep.components = TRUE'

start

First day to show

end

Last day to show

color

Color for the expected curve

alpha

alpha blending for points

Value

A list with six ggplot objects: 'population' is a time series plot of the population. 'seasonal' is a plot showing the estimated seasonal effect. 'trend' is a time series plot showing the estimated trend. 'weekday' is a plot of the estimated weekday effects if they were estimated. 'expected'is a time series plot of the expected values. 'residual' is a time series plot of the residuals.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(dplyr)
library(lubridate)
library(ggplot2)

flu_season <- seq(make_date(2017, 12, 16), make_date(2018, 1, 16), by = "day")

exclude_dates <- c(flu_season, seq(make_date(2020, 1, 1), today(), by = "day"))

res  <- cdc_state_counts %>%
 filter(state == "Massachusetts") %>%
 compute_expected(exclude = exclude_dates,
                  keep.components = TRUE)
                  
p <- expected_diagnostic(expected = res, alpha = 0.50)

p$population
p$seasonal
p$trend
p$expected
p$residual

excessmort documentation built on Oct. 11, 2021, 9:06 a.m.