add_prior_error | R Documentation |
Defines a prior using an Inverse Gamma distribution on the variance of the unexplained error component of the model.
add_prior_error(
priors,
guess,
n,
verbose = FALSE,
plot = FALSE,
show_sigma = TRUE
)
priors |
A list containing other, already defined, priors. If NULL, a
list will be started with |
guess |
Which standard deviation do you expect? |
n |
How much weight (n terms of observations) do you want to give your prior assumption? The larger this value, the more data observations it will take to wash out your prior distribution in case it is misspecified. |
verbose |
Should summarizing information be printed using |
plot |
Should a simple plot of the implied Inverse Gamma density be drawn? |
show_sigma |
If |
Since it's usually easier to think in terms of standard deviation, guess
is at the scale of the error's standard deviation. Both guess
and n
are
translated into the shape
and scale
parameters of the Inverse Gamma
distribution.
When thinking about this prior, frame your assumptions in terms of a sample
of n
observed errors with sample standard deviation guess
.
A list that includes a list named error
, which is a list with
shape
and rate
key-value pairs.
https://en.wikipedia.org/wiki/Inverse-gamma_distribution#Probability_density_function
add_prior_trend()
, add_prior_level()
, add_prior_seasonality()
,
add_prior_anomaly()
ps <- add_prior_error(priors = list(), n = 3, guess = 0.5)
print(ps)
# overwrites the existing entry
ps <- add_prior_error(priors = ps, n = 3, guess = 0.5)
print(ps)
# print summary information
add_prior_error(priors = list(), n = 3, guess = 0.5, verbose = TRUE)
# plot the implied density function with indicator for the mean
add_prior_error(priors = list(), n = 3, guess = 0.5, plot = TRUE)
add_prior_error(priors = list(), n = 2, guess = 0.5, plot = TRUE)
add_prior_error(priors = list(), n = 3, guess = 2, plot = TRUE)
add_prior_error(priors = list(), n = 1, guess = 1, plot = TRUE)
# the prior might be easier to judge on the scale of the standard deviation
add_prior_error(priors = list(), n = 1, guess = 0.5, plot = TRUE,
show_sigma = FALSE)
add_prior_error(priors = list(), n = 1, guess = 0.5, plot = TRUE,
show_sigma = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.