ddbpmm: Density function for MOBSTER.

View source: R/density.R

ddbpmmR Documentation

Density function for MOBSTER.

Description

The density function for a MOBSTER mixture. The function allows to compute the density from the data and parameters stored inside an object of class dbpmm, or from a custom set of parameters and data that can be passed as input. The function can also compute the density only for a subset of components of the mixture.

Usage

ddbpmm(
  x,
  data = NULL,
  components = 1:x$K,
  a = NULL,
  b = NULL,
  pi = NULL,
  scale = NULL,
  shape = NULL,
  log = TRUE
)

Arguments

x

An object of class "dbpmm".

data

Data to compute the (log)-likelihood, if this is null the data stored inside x$data is used.

components

A vector specifying which components should be used to compute the density. Position 1 is reserved for the tail (regardless that is fit or not to the data), the other positions refer to Beta components.

a

Vector of parameters for the Beta components; if this is null values stored inside x are used.

b

Vector of parameters for the Beta components; if this is null values stored inside x are used.

pi

Mixing proportions for the mixture; if this is null values stored inside x are used.

scale

Scale of the power law; if this is null values stored inside x are used.

shape

Shape of the power law; if this is null values stored inside x are used.

log

Boolean value to select the log-likelihood, or the likelihood.

Value

The density for the data. Notice that to compute the negative log-likelihood used during fit one needs to use log = TRUE and change sign.

Examples

library(ggplot2)
data('fit_example', package = 'mobster')

# Use the full mixture, and its internal data
ddbpmm(fit_example$best)

# Use only some of the mixture components, and pass some data
ddbpmm(fit_example$best, data = .4, components = 1)

# An internal function to get f(x) with x the [0,1] range.
ggplot(mobster:::template_density(fit_example$best, reduce = TRUE),
       aes(x = x, y = y, color = cluster)) + geom_line()

caravagnalab/mobster documentation built on March 25, 2023, 3:40 p.m.