# Package `mixAK`

This package contains a mixture of statistical methods including the MCMC methods to analyze normal mixtures. Methods from the following areas can be found here

- Density estimation via normal mixtures and MCMC
- Multivariate generalized linear mixed models with a normal mixture in the distribution of random effects
- Univariate distributions
- Multivariate distributions
- Miscellaneous random number generation
- Matrix linear algebra
- Basic statistics
- Utilities
- Datasets

Additional information can be found in the references mentioned below and at personal webpage of Arnošt Komárek.

This overview provides a sorted list of the functions of the package and links to few more involved examples.

# 1. Density estimation via normal mixtures and MCMC

- NMixMCMC
  - There exists a print method for objects of class NMixMCMC.
- NMixChainsDerived
- NMixSummComp
- NMixRelabel
- NMixPredDA
- NMixPlugDA
- NMixPredDensJoint2
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPredDensJoint2.
- NMixPredCondDensJoint2
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPredCondDensJoint2.
- NMixPlugDensJoint2
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPlugDensJoint2.
- NMixPlugCondDensJoint2
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPlugCondDensJoint2.
- NMixPredDensMarg
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPredDensMarg.
- NMixPredCDFMarg
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPredCDFMarg.
- NMixPredCondDensMarg
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPredCondDensMarg.
- NMixPlugDensMarg
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPlugDensMarg.
- NMixPlugCondDensMarg
  - This is a generic function with default method and a method for objects of class NMixMCMC and GLMM_MCMC implemented.
  - There is also a plot method for objects of class NMixPlugCondDensMarg.
- Y2T
  - This is a generic function with default method to transform a fitted distribution of Y = trans(T) into a distribution of T = itrans(Y).
  - There are methods for objects of class NMixPredDensMarg, NMixPlugDensMarg, NMixPredCDFMarg, NMixPredDensJoint2, NMixPlugDensJoint2, NMixPredCondDensMarg, NMixPlugCondDensMarg, NMixPredCondDensJoint2, NMixPlugCondDensJoint2.

Supplementary material for this part is available:

- Komárek, A. (2009). A new R package for Bayesian estimation of multivariate normal mixtures allowing for selection of the number of components and interval-censored data. Computational Statistics and Data Analysis, 53(12). 3932-3947, doi: 10.1016/j.csda.2009.05.006.
  Paper describing the methods implemented in the package.
- Komarek-NMix-supplement.pdf
  Supplement to the paper which includes some technical details.
- Galaxy.pdf, Galaxy.R, Galaxy.Rnw
  Example of 1 dimensional analysis using the RJ-MCMC.
- Faithful.pdf, Faithful.R, Faithful.Rnw
  Example of 2 dimensional analysis.
- Tandmob.pdf, Tandmob.R, Tandmob.Rnw
  Example of 6 dimensional analysis with the interval-censored data.

# 2. Multivariate generalized linear mixed models with a normal mixture in the distribution of random effects

This part of the package is under development and hence not fully implemented with only a limitted documentation.

- GLMM_MCMC
  - There exists a print method for objects of class GLMM_MCMC.
- GLMM_longitDA

# 3. Univariate distributions

- rTNorm
  Random number generation from a truncated normal distribution.

# 4. Multivariate distributions

- dMVN, rMVN, rcMVN
  (Log-)density and random number genaration for a multivariate normal distribution.
- rTMVN
  Random number genaration from a truncated multivariate normal distribution.
- dMVNmixture, dMVNmixture2, rMVNmixture, rMVNmixture2
  (Log-)density and random number genaration for a mixture of (multivariate) normal distributions.
- dWishart, rWishart
  (Log-)density and random number genaration for a Wishart distribution.
- rDirichlet
  Random number genaration from a Dirichlet distribution.

# 5. Miscellaneous random number generation

- rRotationMatrix
  Random rotation matrix.
- rSamplePair
  Sample a random pair.

# 6. Matrix linear algebra

- MatMPpinv
  Moore-Penrose pseudoinverse of a squared matrix.
- MatSqrt
  Square root of a matrix.

# 7. Basic statistics

- BLA
  Best linear approximation with respect to the mean squared error (theoretical least squares).

# 8. Utilities

- generatePermutations
  Generate all permutations of (1, ..., K).
- SP2Rect
  Conversion of a symmetric matrix stored in a packed format (lower triangle only) into a matrix.
- autolayout

# 9. Datasets

- Acidity
  Acidity index measured in a sample of 155 lakes in North-Central Wisconsin.
- Enzyme
  Enzymatic activity in the blood, for an enzyme involved in the metabolism of carcinogenic substances, among a group of 245 unrelated individuals.
- Faithful
  Waiting time between eruptions and the duration of the eruption for the Old Faithful geyser in Yellowstone National Park, Wyoming, USA, version used in Härdle (1991).
- Galaxy
  Velocities of 82 distant galaxies, diverging from our own galaxy.
- Tandmob
  Dental (Signal Tandmobiel) data for 4430 6-12 year old children.
- TandmobEmer
  Data derived from Tandmob.