Learn R Programming

bayesforecast (version 1.0.5)

set_prior: Set a prior distribution to a model parameter.

Description

Setting a prior distribution to an specify model parameter.

Usage

set_prior(model, par = "ar", dist = normal(), lag = 0)

Value

a time series model class specified in bayesforecast with the changed prior.

Arguments

model

a time series model class specified in varstan.

par

a string value with the desired parameter which a prior is defined. Possible arguments are: "mu0", "sigma0", "ar", "ma", "arch", "garch", "mgarch", "dfv", "df", or "breg".

dist

the distribution of the prior parameter. The only accepted argument is a prior_dist object.

lag

an optional integer value, indicates the desired lag of the parameter to impose a prior. If lag = 0, then the prior distribution will be applied for all lags.

Author

Asael Alonzo Matamoros

Details

bayesforecast provides its own functions to manipulate the parameter prior, this functions return a prior_dist class, the dist argument only accepts this objects.

lag parameter is an optional value to change the prior distribution of one parameter in particular, this argument is only valid for: "ar", "ma", "arch", "garch", "mgarch", or "breg" arguments. The lag option has to be a integer lower than the total amount of lagged parameters of the model. For example, to ONLY change the prior of the second "arch" parameter in a garch(3,1) model, a lag = 2 option must be specified.

Examples

Run this code
dat = Sarima(birth,order = c(1,1,2))
dat = set_prior(model = dat, par = "ar", dist = normal(0,2))
dat

dat = set_prior(model = dat, par = "mu0", dist = student(mu = 0,sd = 2.5,df = 7))
dat

dat = set_prior(model = dat, par = "ma",dist= beta(shape1 = 2, shape2 = 2), lag = 2)
dat

Run the code above in your browser using DataLab