# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Swaps values in each row
#'
#' @description
#' This function swaps the values in each row of a matrix by permuting the
#' columns via the indices provided in the `index` matrix. All
#' `swapElements()`-methods use this function internally. The code is extended
#' to `C++` using the packages `Rcpp` and `RcppArmadillo`.
#'
#' @param values A matrix containing the values to be swapped.
#' @param index An integer matrix defining how values should be swapped.
#' @return A matrix with swapped values.
#' @export
#'
#' @examples
#' values <- matrix(rnorm(10), ncol = 2)
#' index <- matrix(c(2,1), nrow = 5, ncol = 2)
#' swap_cc(values, index)
#'
#' @seealso
#' * [swapElements()] for the calling function
swap_cc <- function(values, index) {
.Call('_finmix_swap_cc', PACKAGE = 'finmix', values, index)
}
#' Swap elements in a 3d array
#'
#' @description
#' This function swaps the elements in a three-dimensional array by using the
#' scheme provided in the `index` matrix.
#'
#' @param values An array of dimension `M x r x K` of values to swap.
#' @param index An integer matrix of dimension `M x K`. containing the scheme
#' by which values should be swapped.
#' @return A three-dimensional array with swapped values.
#' @export
#'
#' @examples
#' values <- array(rnorm(40), dim = c(10, 2, 2))
#' index <- matrix(c(1,2), nrow = 10, ncol = 2)
#' swap_3d_cc(values, index)
#'
#' @seealso
#' * [swapElements()] for the calling method
#' * [swap_cc()] for the equivalent function for 2-dimensional arrays
swap_3d_cc <- function(values, index) {
.Call('_finmix_swap_3d_cc', PACKAGE = 'finmix', values, index)
}
#' Swap values in an integer matrix
#'
#' @description
#' This function swaps the values in an integer matrix column-wise defined
#' by the `index` matrix. This function is used mainly for the
#' `swapElements()`-method of MCMC samples to swap the indicator values.
#'
#' @param values An integer matrix containing the values to swap.
#' @param index An integer matrix containing the indices by which values
#' should be swapped.
#' @return An integer matrix containing the swapped values.
#' @export
#'
#' @examples
#' values <- matrix(c(2, 4, 1, 3), nrow = 10, ncol = 2)
#' index <- matrix(c(1, 2), nrow = 10, ncol = 2)
#' swapInteger_cc(values, index)
#'
#' @seealso
#' * [swap_cc()] for the equivalent function for numeric values
#' * [swap_3d_cc()] for the equivalent function for three-dimensional arrays
swapInteger_cc <- function(values, index) {
.Call('_finmix_swapInteger_cc', PACKAGE = 'finmix', values, index)
}
#' Swap values of stored indicators
#'
#' @description
#' This function is used to swap elements in the stored indicators from MCMC
#' sampling. Note that this function reuses R memory and should therefore be
#' treated with caution. Do not use this function unless you really know what
#' you are doing.
#'
#' @param values An integer matrix containing the last indicators stored in
#' MCMC sampling. The number of these last stored indicators is defined by
#' the hpyer-parameter `storeS` in the `mcmc` object.
#' @param index An integer matrix defining the swapping scheme.
#' @return A matrix with swapped values.
#' @export
#'
#' @seealso
#' * [mcmc()] for the hyper-parameter `storeS`
#' * [swapElements()] for the calling method
#' * [swapInteger_cc()] for the equivalent function that swaps simple integer
#' matrices
#' * [swap_3d_cc()] for a function that swaps values in three-dimensional
#' arrays
swapInd_cc <- function(values, index) {
.Call('_finmix_swapInd_cc', PACKAGE = 'finmix', values, index)
}
#' Swap the `ST` slot in the MCMC output
#'
#' @description
#' This function is used to swap the elements in slot `ST` of an `mcmcoutput`
#' object (An MCMC sampling output). The main difference to the
#' [swapInteger_cc()] function is that this function reuses memory from R. Do
#' only use this function, if you really know what you are doing.
#'
#' @param values An integer matrix containing the values to swap in R memory.
#' @param index An integer matrix containing the swapping scheme.
#' @return An integer matrix with swapped values.
#' @export
#'
#' @seealso
#' * [swapInteger_cc()] for the equivalent function not using R memory
#' * [swap_3d_cc()] for an equivalent function for three-dimensional arrays
#' * [swapElements()] for the calling method
swapST_cc <- function(values, index) {
.Call('_finmix_swapST_cc', PACKAGE = 'finmix', values, index)
}
#' Computes the log density of the Gamma distribution
#'
#' @description
#' For each shape and rate parameter pair the log gamma density is computed.
#' Inside the function the unsafe access functions of Armadillo `at()` and
#' `unsafe_col()` are used, so now boundary check is performed. In each step
#' the `lngamma()` function from Rcpp's `R` namespace is used. At this time
#' unused.
#'
#' @param values A matrix of dimension `M x K` for which the log-density
#' should be calculated.
#' @param shape A vector of dimension `K x 1` with Gamma shape parameters.
#' @param rate A vector of dimension `K x 1` with Gamma rate parameters.
#' @return A matrix of Gamma log-density values for each pair of parameters
#' in a column.
#' @export
ldgamma_cc <- function(values, shape, rate) {
.Call('_finmix_ldgamma_cc', PACKAGE = 'finmix', values, shape, rate)
}
#' Computes the density of the Gamma distribution
#'
#' @description
#' For each shape and rate parameter pair the gamma density is computed.
#' Inside the function the unsafe access functions of Armadillo `at()` and
#' `unsafe_col()` are used, so now boundary check is performed. In each step
#' the `lngamma()` function from Rcpp's `R` namespace is used. At this time
#' unused.
#'
#' @param values A matrix of dimension `M x K` for which the density
#' should be calculated.
#' @param shape A vector of dimension `K x 1` with Gamma shape parameters.
#' @param rate A vector of dimension `K x 1` with Gamma rate parameters.
#' @return A matrix of Gamma density values for each pair of parameters
#' in a column.
#' @export
dgamma_cc <- function(values, shape, rate) {
.Call('_finmix_dgamma_cc', PACKAGE = 'finmix', values, shape, rate)
}
#' Computes the log density of the Dirichlet distribution
#'
#' @description
#' For each shape and rate parameter pair the log-Dirichlet density is
#' computed. Inside the function the unsafe access functions of Armadillo
#' `at()` and `unsafe_col()` are used, so now boundary check is performed.
#' In each step the `lgammafn()` function from Rcpp's `R` namespace is used.
#' At this time unused.
#'
#' @param values A matrix of dimension `M x K` for which the log-density
#' should be calculated.
#' @param par A vector of dimension `K x 1` containing the Dirichlet
#' parameters.
#' @return A vector of Dirichlet log-density values.
#' @export
lddirichlet_cc <- function(values, par) {
.Call('_finmix_lddirichlet_cc', PACKAGE = 'finmix', values, par)
}
#' Computes the density of the Dirichlet distribution
#'
#' @description
#' For each shape and rate parameter pair the Dirichlet density is
#' computed. Inside the function the unsafe access functions of Armadillo
#' `at()` and `unsafe_col()` are used, so now boundary check is performed.
#' In each step the `lgammafn()` function from Rcpp's `R` namespace is used.
#' At this time unused.
#'
#' @param values A matrix of dimension `M x K` for which the log-density
#' should be calculated.
#' @param par A vector of dimension `K x 1` containing the Dirichlet
#' parameters.
#' @return A vector of Dirichlet density values.
#' @export
ddirichlet_cc <- function(values, par) {
.Call('_finmix_ddirichlet_cc', PACKAGE = 'finmix', values, par)
}
#' Compute the hungarian matrix
#'
#' @description
#' This function calls an implementation of the Hungarian algorithm by Munkres.
#' The Hungarian algorithm solves a weighted assignment problem on a bipartite
#' graph. Note, here this algorithm is used in the re-labeling algorithm by
#' Stephens (1997b).
#'
#' @param cost A matrix containing the costs for each row source and column
#' target.
#' @return An integer matrix defining the best solution to the assignment
#' problem.
#' @export
#' @seealso
#' * [mcmcpermute()] for the calling function
#' * [mcmcestimate()] for the function that uses the re-labeling algorithm by
#' Stephens (1997b)
#'
#' @references
#' * Stephens, Matthew (1997b), "Dealing with Label-Switching in Mixture
#' Models", Journal of the Royal Statistical Society Series B, 62(4)
hungarian_cc <- function(cost) {
.Call('_finmix_hungarian_cc', PACKAGE = 'finmix', cost)
}
#' Calculate moments on samples of multivariate mixture models
#'
#' @description
#' This function calculates the moments for MCMC samples of multivariate
#' mixture models. Moments like means, standard deviations, kurtosis and
#' skewness are computed for each iteration in MCMC sampling. The moments are
#' used when plotting the traces of an MCMC sample output.
#'
#' @param classS4 An `mcmcoutput` class containing the MCMC samples.
#' @return A named list with vectors containing the data moments for each
#' iteration in the MCMC sample.
#' @export
#' @seealso
#' * [mcmcoutput-class] for the `mcmcoutput` class definition
#' * [mixturemcmc()] for performing MCMC sampling
#' * [plotTraces()] for the calling function
moments_cc <- function(classS4) {
.Call('_finmix_moments_cc', PACKAGE = 'finmix', classS4)
}
#' Calculate moments on permuted samples of multivariate mixture models
#'
#' @description
#' This function calculates the moments for re-labeled MCMC samples of
#' multivariate mixture models. Moments like means, standard deviations,
#' kurtosis and skewness are computed for each iteration in MCMC sampling. The
#' moments are used when plotting the traces of an MCMC sample output.
#'
#' @param classS4 An `mcmcoutputperm` class containing the re-labeled MCMC
#' samples.
#' @return A named list with vectors containing the data moments for each
#' iteration in the re-labeled MCMC sample.
#' @export
#' @seealso
#' * [mcmcoutputperm-class] for the `mcmcoutput` class definition
#' * [mixturemcmc()] for performing MCMC sampling
#' * [mcmcpermute()] for re-labeling MCMC samples
#' * [plotTraces()] for the calling function
permmoments_cc <- function(classS4) {
.Call('_finmix_permmoments_cc', PACKAGE = 'finmix', classS4)
}
#' Performs MCMC sampling for mixtures of Binomial distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a Binomial mixture
#' model. In addition an `mcmcoutput` object is given that stores the output
#' of MCMC sampling in R memory. Note that `finmix` relies in C++ code on
#' so-called "mixin" layers that help to design a software by organizing code
#' into layers that build upon each others and enable modularity in MCMC
#' sampling by allowing to combine different sampling designs, e.g. with or
#' without a hierarchical prior, with fixed indicators or storing posterior
#' density parameters. See for more information on mixin layers Smaragdakis
#' and Butory (1998).
#'
#' @param fdata_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the Binomial finite mixture
#' model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 A `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_binomial_cc <- function(fdata_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_binomial_cc', PACKAGE = 'finmix', fdata_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Performs MCMC sampling for mixtures of conditional Poisson distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a conditional Poisson
#' mixture model. In addition an `mcmcoutput` object is given that stores the
#' output of MCMC sampling in R memory. Note that `finmix` relies in C++ code
#' on so-called "mixin" layers that help to design a software by organizing
#' code into layers that build upon each others and enable modularity in MCMC
#' sampling by allowing to combine different sampling designs, e.g. with or
#' without a hierarchical prior, with fixed indicators or storing posterior
#' density parameters. See for more information on mixin layers Smaragdakis
#' and Butory (1998).
#'
#' @param data_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the conditional Poisson finite mixture
#' model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 A `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_condpoisson_cc <- function(data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_condpoisson_cc', PACKAGE = 'finmix', data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Performs MCMC sampling for mixtures of Exponential distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a Exponential mixture
#' model. In addition an `mcmcoutput` object is given that stores the output
#' of MCMC sampling in R memory. Note that `finmix` relies in C++ code on
#' so-called "mixin" layers that help to design a software by organizing code
#' into layers that build upon each others and enable modularity in MCMC
#' sampling by allowing to combine different sampling designs, e.g. with or
#' without a hierarchical prior, with fixed indicators or storing posterior
#' density parameters. See for more information on mixin layers Smaragdakis
#' and Butory (1998).
#'
#' @param data_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the Exponential finite mixture
#' model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 A `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_exponential_cc <- function(data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_exponential_cc', PACKAGE = 'finmix', data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Performs MCMC sampling for mixtures of Normal distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a Normal mixture
#' model. In addition an `mcmcoutput` object is given that stores the output
#' of MCMC sampling in R memory. Note that `finmix` relies in C++ code on
#' so-called "mixin" layers that help to design a software by organizing code
#' into layers that build upon each others and enable modularity in MCMC
#' sampling by allowing to combine different sampling designs, e.g. with or
#' without a hierarchical prior, with fixed indicators or storing posterior
#' density parameters. See for more information on mixin layers Smaragdakis
#' and Butory (1998).
#'
#' @param data_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the Normal finite mixture
#' model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 A `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_normal_cc <- function(data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_normal_cc', PACKAGE = 'finmix', data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Performs MCMC sampling for mixtures of multivariate Normal distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a multivariate Normal
#' mixture model. In addition an `mcmcoutput` object is given that stores the
#' output of MCMC sampling in R memory. Note that `finmix` relies in C++ code
#' on so-called "mixin" layers that help to design a software by organizing
#' code into layers that build upon each others and enable modularity in MCMC
#' sampling by allowing to combine different sampling designs, e.g. with or
#' without a hierarchical prior, with fixed indicators or storing posterior
#' density parameters. See for more information on mixin layers Smaragdakis
#' and Butory (1998).
#'
#' @param data_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the multivariate Normal finite
#' mixture model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 A `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_normult_cc <- function(data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_normult_cc', PACKAGE = 'finmix', data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Performs MCMC sampling for mixtures of Poisson distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a Poisson mixture
#' model. In addition an `mcmcoutput` object is given that stores the output
#' of MCMC sampling in R memory. Note that `finmix` relies in C++ code on
#' so-called "mixin" layers that help to design a software by organizing code
#' into layers that build upon each others and enable modularity in MCMC
#' sampling by allowing to combine different sampling designs, e.g. with or
#' without a hierarchical prior, with fixed indicators or storing posterior
#' density parameters. See for more information on mixin layers Smaragdakis
#' and Butory (1998).
#'
#' @param data_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the Poisson finite mixture
#' model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 A `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_poisson_cc <- function(data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_poisson_cc', PACKAGE = 'finmix', data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Performs MCMC sampling for mixtures of Student-t distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a Student-t mixture
#' model. In addition an `mcmcoutput` object is given that stores the output
#' of MCMC sampling in R memory. Note that `finmix` relies in C++ code on
#' so-called "mixin" layers that help to design a software by organizing code
#' into layers that build upon each others and enable modularity in MCMC
#' sampling by allowing to combine different sampling designs, e.g. with or
#' without a hierarchical prior, with fixed indicators or storing posterior
#' density parameters. See for more information on mixin layers Smaragdakis
#' and Butory (1998).
#'
#' @param data_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the Student-t finite mixture
#' model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 A `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_student_cc <- function(data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_student_cc', PACKAGE = 'finmix', data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Performs MCMC sampling for mixtures of multivariate Student-t distributions
#'
#' @description
#' For internal usage only. This function gets passed the `fdata`, `model`,
#' `prior`, `mcmc` objects to perform MCMC sampling for a multivriate
#' Student-t mixture model. In addition an `mcmcoutput` object is given that
#' stores the output of MCMC sampling in R memory. Note that `finmix` relies
#' in C++ code on so-called "mixin" layers that help to design a software by
#' organizing code into layers that build upon each others and enable
#' modularity in MCMC sampling by allowing to combine different sampling
#' designs, e.g. with or without a hierarchical prior, with fixed indicators
#' or storing posterior density parameters. See for more information on mixin
#' layers Smaragdakis and Butory (1998).
#'
#' @param data_S4 An `fdata` object storing the observations and indicators.
#' @param model_S4 A `model` object specifying the multivariate Student-t
#' finite mixture model.
#' @param prior_S4 A `prior` object specifying the prior distribution for MCMC
#' sampling.
#' @param mcmc_S4 An `mcmc` object specifying the hyper-parameters for MCMC
#' sampling.
#' @param mcmcoutput_S4 An `mcmcoutput` object storing the outcomes from MCMC
#' sampling using R memory.
#' @return An `mcmcoutput` object containing the results from MCMC sampling
#' and using the R memory from the input argument `mcmcoutput_S4`.
#' @export
#'
#' @seealso
#' * [mixturemcmc()] for performing MCMC sampling
#' * [fdata-class] for the `fdata` class definition
#' * [model-class] for the `model` class definition
#' * [prior-class] for the `prior` class definition
#' * [mcmc-class] for the `mcmc` class definition
#'
#' @references
#' * Smaragdakis, Y. and Butory, D. (1998), "Implementing layered designs with
#' mixin layers." In: Jul E. (eds) ECOOP’98 — Object-Oriented Programming.
#' ECOOP 1998. Lecture Notes in Computer Science, vol 1445. Springer,
#' Berlin, Heidelberg.
mcmc_studmult_cc <- function(data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4) {
.Call('_finmix_mcmc_studmult_cc', PACKAGE = 'finmix', data_S4, model_S4, prior_S4, mcmc_S4, mcmcoutput_S4)
}
#' Stephens (1997a) relabeling algorithm for Poisson mixtures
#'
#' @description
#' For internal usage only. This function runs the re-labeling algorithm from
#' Stephens (1997a) for MCMC samples of a Poisson mixture distribution. For
#' optimization a Nelder-Mead-Algorithm from the NLopt library is used. This
#' is also the reason why the package depends on the `nloptr` package which
#' provides a header file for direct access to the C routines.
#'
#' @param values1 A matrix containing the sampled component parameters
#' `lambda`.
#' @param values2 A matrix containing the sampled weights.
#' @param pars A vector containing the parameters of the prior distributions
#' of the component parameters and weights. More specifically, the
#' parameters of the Dirichlet distribution for the weights and the
#' shape and rate parameters for the Gamma distributions of the component
#' parameters.
#' @param perm A matrix with all possible permutations of the labels.
#' @return A matrix of dimension `MxK` that holding the optimal labeling.
#' @export
#' @keywords internal
#'
#' @seealso
#' * [mcmcpermute()] for the calling function
#' * [stephens1997b_poisson_cc()] for the re-labeling algorithm from
#' Stephens (1997b)
#' * [stephens1997a_binomial_cc()] for the equivalent implementation
#' for mixtures of Binomial distributions
#'
#' @references
#' * Stephens, Matthew (1997a), Discussion of "On Bayesian Analysis of
#' Mixtures with an Unknown Number of Components", Journal of the Royal
#' Statistical Society: Series B (Statistical Methodology), 59: 731-792.
stephens1997a_poisson_cc <- function(values1, values2, pars, perm) {
.Call('_finmix_stephens1997a_poisson_cc', PACKAGE = 'finmix', values1, values2, pars, perm)
}
#' Stephens (1997a) relabeling algorithm for Binomial mixtures
#'
#' @description For internal usage only. This function runs the re-labeling
#' algorithm from Stephens (1997a) for MCMC samples of a Binomial mixture
#' distribution. For optimization a Nelder-Mead-Algorithm from the NLopt
#' library is used. This is also the reason why the package depends on the
#' `nloptr` package which provides a header file for direct access to the C
#' routines.
#'
#' @param values1 A matrix containing the sampled component parameters `p`.
#' @param values2 A matrix containing the sampled weights.
#' @param pars A vector containing the parameters of the posterior
#' distributions of the component parameters and weights. More specifically,
#' the parameters of the Dirichlet distribution for the weights and the shape
#' and rate parameters for the Beta distributions of the component
#' parameters.
#' @param perm A matrix with all possible permutations of the labels.
#' @return A matrix of dimension `MxK` that holding the optimal labeling.
#' @export
#' @keywords internal
#' @seealso
#' * [mcmcpermute()] for the calling function
#' * [stephens1997b_poisson_cc()] for the re-labeling algorithm from
#' Stephens (1997b)
#' * [stephens1997a_binomial_cc()] for the equivalent implementation
#' for mixtures of Binomial distributions
#'
#' @references
#' * Stephens, Matthew (1997a), Discussion of "On Bayesian Analysis of
#' Mixtures with an Unknown Number of Components", Journal of the Royal
#' Statistical Society: Series B (Statistical Methodology), 59: 731-792.
stephens1997a_binomial_cc <- function(values1, values2, pars, perm) {
.Call('_finmix_stephens1997a_binomial_cc', PACKAGE = 'finmix', values1, values2, pars, perm)
}
#' Stephens (1997b) relabeling algorithm for Poisson mixtures
#'
#' @description
#' For internal usage only. This function runs the re-labeling algorithm from
#' Stephens (1997b) for MCMC samples of a Poisson mixture distribution.
#'
#' @param values A matrix of observations of dimension `Nx1`.
#' @param comp_par An array of component parameter samples from MCMC sampling.
#' Dimension is `MxK`.
#' @param weight An array of weight parameter samples from MCMC sampling.
#' Dimension is `MxK`.
#' @param max_iter A signed integer specifying the number of iterations to be
#' run in optimization. Unused.
#' @return An integer matrix of dimension `MxK` that holding the optimal
#' labeling.
#' @export
#' @keywords internal
#' @seealso
#' * [mcmcpermute()] for the calling function
#' * [stephens1997a_poisson_cc()] for the re-labeling algorithm from
#' Stephens (1997a)
#' * [stephens1997b_binomial_cc()] for the equivalent implementation
#' for mixtures of Binomial distributions
#'
#' @references
#' * Stephens, Matthew (1997a), Bayesian methods for mixtures of normal
#' distributions, DPhil Thesis, University of Oxford, Oxford.
stephens1997b_poisson_cc <- function(values, comp_par, weight_par, max_iter = 200L) {
.Call('_finmix_stephens1997b_poisson_cc', PACKAGE = 'finmix', values, comp_par, weight_par, max_iter)
}
#' Stephens (1997b) relabeling algorithm for Binomial mixtures
#'
#' @description
#' For internal usage only. This function runs the re-labeling algorithm from
#' Stephens (1997b) for MCMC samples of a Binomial mixture distribution.
#'
#' @param values A matrix of observations of dimension `Nx1`.
#' @param reps A vector containing the repetitions.
#' @param comp_par An array of component parameter samples from MCMC sampling.
#' Dimension is `MxK`.
#' @param weight_par An array of weight parameter samples from MCMC sampling.
#' Dimension is `MxK`.
#' @return An integer matrix of dimension `MxK` that holding the optimal
#' labeling.
#' @export
#'
#' @seealso
#' * [mcmcpermute()] for the calling function
#' * [stephens1997a_binomial_cc()] for the re-labeling algorithm from
#' Stephens (1997a)
#' * [stephens1997b_poisson_cc()] for the equivalent implementation
#' for mixtures of Poisson distributions
#'
#' @references
#' * Stephens, Matthew (1997a), Bayesian methods for mixtures of normal
#' distributions, DPhil Thesis, University of Oxford, Oxford.
stephens1997b_binomial_cc <- function(values, reps, comp_par, weight_par) {
.Call('_finmix_stephens1997b_binomial_cc', PACKAGE = 'finmix', values, reps, comp_par, weight_par)
}
#' Stephens (1997b) relabeling algorithm for Exponential mixtures
#'
#' @description
#' For internal usage only. This function runs the re-labeling algorithm from
#' Stephens (1997b) for MCMC samples of a Exponential mixture distribution.
#'
#' @param values A matrix of observations of dimension `Nx1`.
#' @param comp_par An array of component parameter samples from MCMC sampling.
#' Dimension is `MxK`.
#' @param weight An array of weight parameter samples from MCMC sampling.
#' Dimension is `MxK`.
#' @param max_iter A signed integer specifying the number of iterations to be
#' run in optimization. Unused.
#' @return An integer matrix of dimension `MxK` that holding the optimal
#' labeling.
#' @export
#' @keywords internal
#' @seealso
#' * [mcmcpermute()] for the calling function
#' * [stephens1997b_poisson_cc()] for the equivalent implementation
#' for mixtures of Poisson distributions
#' * [stephens1997b_binomial_cc()] for the equivalent implementation
#' for mixtures of Binomial distributions
#'
#' @references
#' * Stephens, Matthew (1997a), Bayesian methods for mixtures of normal
#' distributions, DPhil Thesis, University of Oxford, Oxford.
stephens1997b_exponential_cc <- function(values, comp_par, weight_par) {
.Call('_finmix_stephens1997b_exponential_cc', PACKAGE = 'finmix', values, comp_par, weight_par)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.