A multinomial proportions model will tell you what proportion each class has versus others in the data set. In this case the denominator is the total count across across all classes.
Usage
plot_multinomial(
modelled = i_multinomial_proportion_model,
...,
mapping = ggplot2::aes(fill = class),
events = i_events,
normalise = FALSE
)Arguments
- modelled
the multinomial count data - a dataframe with columns:
time (ggoutbreak::time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`
class (factor) - A factor specifying the type of observation. This will be things like variant, or serotype, for a multinomial model. Any missing data points are ignored.
proportion.0.5 (proportion) - median estimate of proportion (true scale)
Must be grouped by: class (exactly).
- ...
Named arguments passed on to
geom_eventseventsSignificant events or time spans - a dataframe with columns:
label (character) - the event label
start (date) - the start date, or the date of the event
end (date) - the end date or NA if a single event
Any grouping allowed.
A default value is defined.
- mapping
a
ggplot2::aesmapping. Usually this will be left as the default- events
Significant events or time spans - a dataframe with columns:
label (character) - the event label
start (date) - the start date, or the date of the event
end (date) - the end date or NA if a single event
Any grouping allowed.
A default value is defined.
- normalise
make sure the probabilities add up to one - this can be a bad idea if you know you may have missing values, on the other hand not all proportions models are guaranteed to add up to one.
Examples
tmp = ggoutbreak::england_covid_proportion_age_stratified() %>%
dplyr::glimpse()
#> Rows: 26,790
#> Columns: 20
#> Groups: class [19]
#> $ class <fct> 00_04, 00_04, 00_04, 00_04, 00_04, 00_04, 00_04…
#> $ time <time_prd> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, …
#> $ proportion.fit <dbl> -1000.00000, -1000.00000, -1000.00000, -1000.00…
#> $ proportion.se.fit <dbl> 0.01129143, 0.01127551, 0.01125958, 0.01124366,…
#> $ proportion.0.025 <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000…
#> $ proportion.0.05 <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000…
#> $ proportion.0.25 <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000…
#> $ proportion.0.5 <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000…
#> $ proportion.0.75 <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000…
#> $ proportion.0.95 <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000…
#> $ proportion.0.975 <dbl> 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000…
#> $ relative.growth.fit <dbl> 0.00000000, 0.00000000, 0.00000000, 0.00000000,…
#> $ relative.growth.se.fit <dbl> 1.626352e-05, 1.626352e-05, 1.626352e-05, 1.626…
#> $ relative.growth.0.025 <dbl> -3.187591e-05, -3.187591e-05, -3.187591e-05, -3…
#> $ relative.growth.0.05 <dbl> -2.675111e-05, -2.675111e-05, -2.675111e-05, -2…
#> $ relative.growth.0.25 <dbl> -1.096958e-05, -1.096958e-05, -1.096958e-05, -1…
#> $ relative.growth.0.5 <dbl> 0.00000000, 0.00000000, 0.00000000, 0.00000000,…
#> $ relative.growth.0.75 <dbl> 1.096958e-05, 1.096958e-05, 1.096958e-05, 1.096…
#> $ relative.growth.0.95 <dbl> 2.675111e-05, 2.675111e-05, 2.675111e-05, 2.675…
#> $ relative.growth.0.975 <dbl> 3.187591e-05, 3.187591e-05, 3.187591e-05, 3.187…
if(interactive()) {
plot_multinomial(tmp, normalise=TRUE)+
ggplot2::scale_fill_viridis_d()
}
