Learn R Programming

excessmort (version 0.8.2)

expected_diagnostic: Diagnostic Plots for Model Fit

Description

Check mean model fit via diagnostic figures of the model components

Usage

expected_diagnostic(
  expected,
  start = NULL,
  end = NULL,
  color = "#D22B2B",
  alpha = 0.5
)

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.

Arguments

expected

The output from `compute_expected` 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

Examples

Run this code

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

Run the code above in your browser using DataLab