BMMmodel {bayesmix} | R Documentation |
Creates bugs model.
Description
Creates the BUGS-model specification and return the values for the initialization, the prior specification and the observations.
Usage
BMMmodel(y, k, priors, inits = "initsFS", aprioriWeights = 1,
no.empty.classes = FALSE, restrict = "none", ...)
Arguments
y |
a numeric vector. |
k |
integer indicating the number of segments. |
priors |
specification of priors by a named list or a
|
inits |
specification of initial values by a named list or string indicating the function to be called. |
aprioriWeights |
specification of prior of the a-priori weights. If
|
no.empty.classes |
logical: should it be prevented that empty classes arise during sampling. |
restrict |
one of "none", "mu", "tau". |
... |
further parameters for the function specified in
|
Details
By default the function initsFS
is called for generating
initial values. Any other function specified by inits
is
assumed to have at least x
, k
and restrict
as
input parameters.
The parameter restrict
indicates if a
location-shift model ("tau"), a scale contaminated model
("mu") or a model where both variables vary over components shall
be fitted.
If the logical no.empty.classes
is TRUE
there
are observations added to the model that the classes are not empty. This
signifies that the likelihood when sampling the class affiliations is
changed thus that any data point which is sampled and is the last one
in its class stays there.
Value
If y
is specified an object of class BMMmodel
is
returned with components:
inits |
named list. |
data |
named list. |
bugs |
text for .bug-file with prefix missing. |
If y
is missing an object of class BMMsetup
is
returned containing the parameter specifications. When JAGScall
is called with this object as model argument, BMMmodel
is
called with y
and the other parameters as input arguments
before calling JAGS.
Author(s)
Bettina Gruen
See Also
Examples
data("fish", package = "bayesmix")
model <- BMMmodel(fish, k = 4, priors = list(kind = "independence",
parameter = "priorsFish", hierarchical = "tau"),
initialValues = list(S0 = 2))
model