-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathlayer_residual_quantiles.Rd
75 lines (63 loc) · 1.99 KB
/
layer_residual_quantiles.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/layer_residual_quantiles.R
\name{layer_residual_quantiles}
\alias{layer_residual_quantiles}
\title{Creates predictions based on residual quantiles}
\usage{
layer_residual_quantiles(
frosting,
...,
quantile_levels = c(0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95),
symmetrize = TRUE,
by_key = character(0L),
name = ".pred_distn",
id = rand_id("residual_quantiles")
)
}
\arguments{
\item{frosting}{a \code{frosting} postprocessor}
\item{...}{Unused, include for consistency with other layers.}
\item{quantile_levels}{numeric vector of probabilities with values in (0,1)
referring to the desired quantile. Note that 0.5 will always be included
even if left out by the user.}
\item{symmetrize}{logical. If \code{TRUE} then interval will be symmetric.}
\item{by_key}{A character vector of keys to group the residuals by before
calculating quantiles. The default, \code{c()} performs no grouping.}
\item{name}{character. The name for the output column.}
\item{id}{a random id string}
}
\value{
an updated \code{frosting} postprocessor with additional columns of the
residual quantiles added to the prediction
}
\description{
Creates predictions based on residual quantiles
}
\examples{
library(dplyr)
jhu <- covid_case_death_rates \%>\%
filter(time_value > "2021-11-01", geo_value \%in\% c("ak", "ca", "ny"))
r <- epi_recipe(jhu) \%>\%
step_epi_lag(death_rate, lag = c(0, 7, 14)) \%>\%
step_epi_ahead(death_rate, ahead = 7) \%>\%
step_epi_naomit()
wf <- epi_workflow(r, linear_reg()) \%>\% fit(jhu)
f <- frosting() \%>\%
layer_predict() \%>\%
layer_residual_quantiles(
quantile_levels = c(0.025, 0.975),
symmetrize = FALSE
) \%>\%
layer_naomit(.pred)
wf1 <- wf \%>\% add_frosting(f)
p <- forecast(wf1)
f2 <- frosting() \%>\%
layer_predict() \%>\%
layer_residual_quantiles(
quantile_levels = c(0.3, 0.7),
by_key = "geo_value"
) \%>\%
layer_naomit(.pred)
wf2 <- wf \%>\% add_frosting(f2)
p2 <- forecast(wf2)
}