Description Details Slots See Also
The fdata class holds the data for finite mixture distributions.
The fdata class defines an essential part of the finmix package and
MCMC sampling for finite mixture distributions. It stores the data for
finite mixture distributions which includes always the observations stored
in slot y and occasionally also known indicators in slot S. The latter
ones define either a so-called finite mixture model with fixed indicators
or are used as starting indicators in MCMC sampling for a model with unknown
indicators.
Observations can be stored in either in row or column format (default). In
the former case the slot bycolumn has to be set to FALSE to indicate the
safeguard functions in methods that the observations are stored in row
format. If indicators are stored in the fdata object they must be stored
in the same format as the observations. When using the setter setS()<-
converting the repetitions to the right format is handled for the user.
For discrete mixture models with Poisson or Exponential distributions
exposures can be added to the data (and model). Exposures scale the rate
parameters individually for each observation. Exposures get stored in the
slot exp and have to be either of dimension Nx1 or of dimension 1x1.
Like observations and indicators, exposures also have to be provided in the
same data format, i.e. either row or column depending on the slot bycolumn
set to FALSE or TRUE. When using the setter setExp()<- converting the
repetitions to the right format is handled for the user.
For mixtures of binomial distributions it is possible to include repetitions
in the slot T of the fdata object. Repetitions can be constant or
varying. In the former case the dimension of slot T is 1x1 and in the
latter one it is Nx1. Depending on the slot bycolumn the repetitions
have to be provided in row or column format. When using the setter
setT()<- converting the repetitions to the right format is handled for the
user.
For mixtures of multivariate data the slot r is larger than one. For all
other mixtures it is equal to one. Note that in case of multivariate mixture
models the data in slot y has to be of dimension Nxr or rxN depending
on the slot bycolumn set to TRUE or FALSE.
There are a couple of methods that intend to simplify the handling of data for the user. These methods are listed below.
show() gives a short summary of the object's slots.
getY() returns the y slot.
getColY() returns the y slot in column format independent of
bycolumn.
getRowY() returns the y slot in row format independent of bycolumn.
getN() returns the N slot.
getr() returns the r slot.
getS() returns the S slot.
getColS() returns the S slot in column format independent of
bycolumn.
getRowS() returns the S slot in row format independent of bycolumn.
getBycolumn() returns the bycolumn slot.
getName() returns the name slot.
getType() returns the type slot.
getSim() returns the sim slot.
getExp() returns the exp slot.
getColExp() returns the y slot in column format independent of
bycolumn.
getRowExp() returns the y slot in row format independent of bycolumn.
getT() returns the T slot.
getColT() returns the T slot in column format independent of
bycolumn.
getRowT() returns the T slot in row format independent of bycolumn.
All setters help the user to set the slots in the right format and with the correct class (integer, matrix, etc.). It is internally checked, if the new value fits the other slots of the object.
setY()<- sets the y slot.
setN()<- sets the N slot.
setR()<- sets the r slot.
setS()<- sets the S slot.
setBycolumn sets the bycolumn slot.
setName()<- sets the name slot.
setType()<- sets the type slot.
setSim()<- sets the sim slot.
setExp()<- sets the exp slot.
setT()<- sets the T slot.
The checking methods are provided to allow a user to integrate the finmix
classes more easily into a larger code basis. They check, if the slots are
available and return a logical.
hasY() checks, if slot y is not empty.
hasS() checks, if slot S is not empty.
hasExp() checks, if the slot exp is not empty.
hasT() checks, if the slot T is not empty.
The plotting function should help the user to get an impression of how the
data in the fdata object is distributed. This is important for evaluating
what kind of distribution to choose and how many mixture components to test
for.
plot(x, y, dev=TRUE, ...) plots the observations in the y slot. If the
type is "discrete" a barplot() is shown. In the "continuous" case
the plot depends on the number of dimensions: if the dimension r of the
data is one, a histogram() shows the distribution of the observations.
In case of a two-dimensional data set, histograms of the marginal
distributions are plotted together with a scatter plot() and a
two-dimensional kernel-density (see bkde2D()). In case of a multivariate
data set with more than two dimensions a pairs() plot is returned. The
argument dev should be put to FALSE if the output should be in a file.
... allows the user to pass further arguments to the internal functions.
yA matrix containing the observations for finite mixture estimation.
Can be by column or row depending on the slot bycolumn.
NAn integer holding the number of observations.
rAn integer defining the dimension of the data. Only for multivariate
distributions like normult or studmult the dimension is
larger one.
SA matrix containing the indicators of the data. If the fdata class
contains indicators estimation is performed with a fixed indicator
approach.
bycolumnA logical indicating if the data in y and S is sorted by
by column (TRUE) or row (FALSE).
nameA character specifying a name for the data. Optional.
typeA character specifying the data type: either discrete for
discrete data or continuous for continuous data. The two data types are
treated differently when calculating data moments.
simA logical indicating, if the data was simulated.
expA matrix containing the exposures of Poisson data.
TA matrix containing the (optional) repetitions of binomial or Poisson data. Must be of type integer.
fdata() for the class constructor
model for the class from which data can be simulated
simulate() for the method of the model class simulating data from a
finite mixture model
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.