LN2: Log-normal model with two levels

View source: R/SpecModel-generators.R

LN2R Documentation

Log-normal model with two levels

Description

A hierarchical model for datasets with systematic biases, where these biases are modelled as proportional differences.

Usage

LN2(
  constraint,
  structuralZeros = NULL,
  concordances = list(),
  sd = HalfT(),
  add1 = TRUE
)

Arguments

constraint

An object of class Values, with values 0, -1, 1, and NA.

structuralZeros

Location of any structural zeros in the data. An object of class Values, or, for the typical case, the word "diag".

concordances

A named list of concordances used to map between y and constraint.

sd

Standard deviation of data-level errors. Either a fixed value or a prior distribution. The prior distribution is specified via HalfT or InvChiSq. Defaults to a half-t distribution.

add1

Whether to add 1 to the response and exposure.

Details

When add1 is TRUE (the default), the model assumes

y[i] + 1 \sim N(exposure[i] + 1 + alpha[j[i]], sd^2)

and when add1 is FALSE, the model assumes

y[i] \sim N(exposure[i] + alpha[j[i]], sd^2)

.

The alpha term measures bias. It has the same level of detail as the constraints, which will almost always be less than the level of detail of y.

The constraints are specified via a Values, object composed of 0s, -1s, 1s, and NAs. A 0 implies that the bias term is set to 0; a -1 implies that it must be negative; a 1 implies that it must be positive, and a NA implies that there is no constraint.

Adding 1 to the response and exposure is a way of dealing with zeros in the response.

Examples

constraint <- ValuesOne(c(NA, NA, -1),
                        labels = c("0-19", "20-64", "65"),
                        name = "age")
spec <- LN2(constraint)
spec

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