geom_sa {ggdemetra} | R Documentation |
Seasonal adjustment time series
Description
Performs a seasonal adjustment and plots a time series.
geom_sa()
and stat_sa()
are aliases: they both use the same arguments.
Use stat_sa()
if you want to display the results with a non-standard geom.
Usage
geom_sa(
mapping = NULL,
data = NULL,
stat = "sa",
position = "identity",
...,
method = c("x13", "tramoseats"),
spec = NULL,
frequency = NULL,
message = TRUE,
component = "sa",
show.legend = NA,
inherit.aes = TRUE
)
stat_sa(
mapping = NULL,
data = NULL,
geom = "line",
position = "identity",
...,
method = c("x13", "tramoseats"),
spec = NULL,
frequency = NULL,
message = TRUE,
component = "sa",
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping |
Set of aesthetic mappings created by aes() or
aes_(). If specified and |
data |
A |
stat |
The statistical transformation to use on the data for this layer, as a string. |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to layer(). These are
often aesthetics, used to set an aesthetic to a fixed value, like
|
method |
the method used for the seasonal adjustment. |
spec |
the specification used for the seasonal adjustment. See x13() or tramoseats(). |
frequency |
the frequency of the time series. By default ( |
message |
a |
component |
a |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom |
The geometric object to use to display the data |
Examples
p_ipi_fr <- ggplot(data = ipi_c_eu_df, mapping = aes(x = date, y = FR)) +
geom_line(color = "#F0B400") +
labs(title = "Seasonal adjustment of the French industrial production index",
x = "time", y = NULL)
# To add the seasonal adjusted series:
p_ipi_fr +
geom_sa(color = "#155692")
# To add the forecasts of the input data and the seasonal adjusted series:
p_sa <- p_ipi_fr +
geom_sa(component = "y_f", linetype = 2, message = FALSE, color = "#F0B400") +
geom_sa(component = "sa", color = "#155692", message = FALSE) +
geom_sa(component = "sa_f", color = "#155692", linetype = 2, message = FALSE)
p_sa