This function calls the PYdensity function from package BNPmix, to allow fitting a Pitman-Yor process mixture to the data.
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
)
The function returns a MixPY2 object. It is based on a list with the following components:
Numeric vector. Evaluation grid.
Numeric array. Matrix
of dimension \(\texttt{Nx} \times (\texttt{length(probs)} + 1)\) with the posterior mean and the desired quantiles input
in probs
.
Numeric vector of
length(Nit*(1-Pbi))
with the number of mixtures components
(clusters).
List of length(Nit*(1-Pbi))
with the clustering
allocations.
List of length(Nit*(1-Pbi))
with the
cluster means (locations). Only if extras = TRUE.
List of length(Nit*(1-Pbi))
with the
cluster standard deviations (scales). Only if extras = TRUE.
List of
length(Nit*(1-Pbi))
with the mixture weights. Only if extras = TRUE.
Integer constant. Number of MCMC iterations.
Numeric constant. Burn-in period proportion of Nit
.
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 used for the fit
A named list with the parameters of the Pitman-Yor process
Numeric vector. Data set to which the density is fitted.
Numeric vector. Desired quantiles of the density estimates.
Numeric constant. Total mass of the centering measure. See
Numeric constant. \(0\leq \texttt{Gama} \leq 1\). See details.
Numeric positive constant. Shape parameter of the gamma prior on the standard deviation of the mixture kernel. Default value suggested by package BNPmix.
Numeric positive constant. Rate parameter of the gamma prior on the standard deviation of the mixture kernel. Default value suggested by package BNPmix.
Integer constant. Number of grid points for the evaluation of the density estimate.
Integer constant. Number of MCMC iterations.
Numeric constant. Burn-in period proportion of Nit.
Numeric constant. Extension to the evaluation grid range. See details.
Logical. If TRUE, prints out the execution time.
Logical. If TRUE, gives additional objects: means and weights
# Data
data(acidity)
x <- acidity
# Fitting the model under default specifications
out <- MixPY2(x)
# Plotting density estimate + 95% credible interval
plot(out)
Run the code above in your browser using DataLab