Known: Specify a prior where the mean varies but is treated as...

View source: R/SpecPrior-generators.R

KnownR Documentation

Specify a prior where the mean varies but is treated as known.

Description

Specify a 'Known' prior. The prior comes in two forms. With the first form, the corresponding main effect or interaction equals the mean exactly, parameter[j] = mean[j]. With the second form, parameter[j] ~ N(mean[j], sd[j]). The second form is obtained by supplying a sd argument to function Known.

Usage

Known(mean, sd = 0)

Arguments

mean

The mean of the prior distribution. An object of class Values.

sd

The standard deviation of the prior distribution. If omitted, it is assumed to be 0. sd can be an object of class Values, or it can be a single number, in which case it is applied to all elements of mean.

Details

Internally, the mean and sd arguments are permuted and subsetted to make them compatible with the corresponding main effect or interaction. Thus, for example, if mean has values for regions A, B, and C, but data y only includes regions A and B, then C is silently ignored.

The original mean and sd arguments are, however, stored, and can be used for prediction. For example, we might supply a mean argument with values for years 2005, 2010, 2015, 2020, and 2025, then call estimateModel with data for 2005, 2010, and 2015, and finally call predictModel to obtain forecasts for 2020 and 2025.

Value

An object of class SpecKnown.

See Also

ExchFixed creates a normal prior centered at 0.

Examples

mean <- ValuesOne(c(0.1, 0.2, 0.3),
                  labels = c("A", "B", "C"),
                  name = "region")
sd <- ValuesOne(c(0.02, 0.03, 0.02),
                  labels = c("A", "B", "C"),
                  name = "region")
## No uncertainty
Known(mean)

## Some uncertainty
Known(mean = mean, sd = sd)

## Single standard deviation
Known(mean = mean, sd = 0.05)

StatisticsNZ/demest documentation built on Nov. 2, 2023, 7:56 p.m.