View source: R/bage_mod-constructors.R
mod_norm | R Documentation |
Specify a model where the outcome is drawn from a normal distribution.
mod_norm(formula, data, weights)
formula |
An R formula, specifying the outcome and predictors. |
data |
A data frame containing outcome, predictor, and, optionally, weights variables. |
weights |
Name of the weights variable,
a |
The model is hierarchical. The means in the normal distribution are described by a prior model formed from dimensions such as age, sex, and time. The terms for these dimension themselves have models, as described in priors. These priors all have defaults, which depend on the type of term (eg an intercept, an age main effect, or an age-time interaction.)
Internally, the outcome variable scaled to have mean 0 and sd 1.
An object of class bage_mod_norm
.
The likelihood is
y_i \sim \text{N}(\mu_i, \xi^2 / w_i)
where
y_i
is a scaled value for an, such of the log of income, for some
combination i
of classifying variables,
such as age, sex, and region;
\mu_i
is a mean;
\xi
is a standard deviation parameter; and
w_i
is a weight.
The scaling of the outcome variable is done internally.
If y_i^*
is the original, then y_i = (y_i^* - m)/s
where m
and s
are the sample mean and standard
deviation of y_i^*
.
In some applications, w_i
is set to 1
for all i
.
The means \mu_i
equal the sum of terms formed
from classifying variables,
\mu_i = \sum_{m=0}^{M} \beta_{j_i^m}^{(m)}
where
\beta^{0}
is an intercept;
\beta^{(m)}
, m = 1, \dots, M
, is a main effect
or interaction; and
j_i^m
is the element of \beta^{(m)}
associated with
cell i
.
The \beta^{(m)}
are given priors, as described in priors.
The prior for \xi
is described in set_disp()
.
The weights
argument can take three forms:
the name of a variable in data
, with or without
quote marks, eg "wt"
or wt
;
the number 1
, in which no weights are used; or
a formula, which is evaluated with data
as its
environment (see below for example).
mod_pois()
Specify Poisson model
mod_binom()
Specify binomial model
set_prior()
Specify non-default prior for term
set_disp()
Specify non-default prior for standard deviation
fit()
Fit a model
forecast()
Forecast a model
report_sim()
Do a simulation study on a model
mod <- mod_norm(value ~ diag:age + year,
data = nld_expenditure,
weights = 1)
## use formula to specify weights
mod <- mod_norm(value ~ diag:age + year,
data = nld_expenditure,
weights = ~sqrt(value))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.