MixPY2 {BNPdensity}R Documentation

Pitman-Yor process mixture of Type II

Description

This function calls the PYdensity function from package BNPmix, to allow fitting a Pitman-Yor process mixture to the data.

Usage

MixPY2(
  x,
  probs = c(0.025, 0.5, 0.975),
  Alpha = 1,
  Gama = 0.4,
  asigma = 2,
  bsigma = 1/var(x),
  Nx = 100,
  Nit = 1500,
  Pbi = 0.5,
  epsilon = NULL,
  printtime = TRUE,
  extras = TRUE
)

Arguments

x

Numeric vector. Data set to which the density is fitted.

probs

Numeric vector. Desired quantiles of the density estimates.

Alpha

Numeric constant. Total mass of the centering measure. See

Gama

Numeric constant. 0\leq \texttt{Gama} \leq 1. See details.

asigma

Numeric positive constant. Shape parameter of the gamma prior on the standard deviation of the mixture kernel. Default value suggested by package BNPmix.

bsigma

Numeric positive constant. Rate parameter of the gamma prior on the standard deviation of the mixture kernel. Default value suggested by package BNPmix.

Nx

Integer constant. Number of grid points for the evaluation of the density estimate.

Nit

Integer constant. Number of MCMC iterations.

Pbi

Numeric constant. Burn-in period proportion of Nit.

epsilon

Numeric constant. Extension to the evaluation grid range. See details.

printtime

Logical. If TRUE, prints out the execution time.

extras

Logical. If TRUE, gives additional objects: means and weights

Value

The function returns a MixPY2 object. It is based on a list with the following components:

xx

Numeric vector. Evaluation grid.

qx

Numeric array. Matrix of dimension \texttt{Nx} \times (\texttt{length(probs)} + 1) with the posterior mean and the desired quantiles input in probs.

R

Numeric vector of length(Nit*(1-Pbi)) with the number of mixtures components (clusters).

Allocs

List of length(Nit*(1-Pbi)) with the clustering allocations.

means

List of length(Nit*(1-Pbi)) with the cluster means (locations). Only if extras = TRUE.

sigmas

List of length(Nit*(1-Pbi)) with the cluster standard deviations (scales). Only if extras = TRUE.

weights

List of length(Nit*(1-Pbi)) with the mixture weights. Only if extras = TRUE.

Nit

Integer constant. Number of MCMC iterations.

Pbi

Numeric constant. Burn-in period proportion of Nit.

distr.k

Integer corresponding to the kernel chosen for the mixture. Always 1, since the Pitman-Yor process is only written to work with Gaussian kernels.

data

Data used for the fit

PY_params

A named list with the parameters of the Pitman-Yor process

Examples

# Data
data(acidity)
x <- acidity
# Fitting the model under default specifications
out <- MixPY2(x)
# Plotting density estimate + 95% credible interval
plot(out)

[Package BNPdensity version 2023.3.8 Index]