Skip to contents

Categorical Distribution

Usage

Cat(prob = c(0.5, 0.5))

# S4 method for class 'Cat,numeric'
d(distr, x)

# S4 method for class 'Cat,numeric'
r(distr, n)

# S4 method for class 'Cat'
mean(x)

# S4 method for class 'Cat'
mode(x)

# S4 method for class 'Cat'
var(x)

# S4 method for class 'Cat'
entro(x)

# S4 method for class 'Cat'
finf(x)

llcat(x, prob)

# S4 method for class 'Cat,numeric'
ll(distr, x)

ecat(x, type = "mle", ...)

# S4 method for class 'Cat,numeric'
mle(distr, x, dim = NULL)

# S4 method for class 'Cat,numeric'
me(distr, x, dim = NULL)

vcat(prob, type = "mle")

# S4 method for class 'Cat'
avar_mle(distr)

# S4 method for class 'Cat'
avar_me(distr)

Arguments

prob

numeric. The distribution parameters.

distr

an object of class Cat.

x

an object of class Cat. If the function also has a distr argument, x is a numeric vector, a sample of observations.

n

numeric. The sample size.

type

character, case ignored. The estimator type (mle, me, or same).

...

extra arguments.

dim

numeric. The parameter dimension. See details.

Value

Each type of function returns a different type of object:

  • Distribution Functions: When supplied with one argument (distr), the d(), p(), q(), r(), ll() functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively. When supplied with both arguments (distr and x), they evaluate the aforementioned functions directly.

  • Moments: Returns a numeric, either vector or matrix depending on the moment and the distribution. The moments() function returns a list with all the available methods.

  • Estimation: Returns a list. The estimator of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.

  • Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.

Details

The estimation of prob from a sample would by default return a vector of probabilities corresponding to the categories that appeared in the sample and 0 for the rest. However, the parameter dimension cannot be uncovered by the sample, it has to be provided separately. This can be done with the argument dim. If dim is not supplied, the dimension will be retrieved from the distr argument. Categories that did not appear in the sample will have 0 probabilities appended to the end of the prob vector.

Note that the actual dimension of the probability parameter vector is k-1, therefore the Fisher information matrix and the asymptotic variance - covariance matrix of the estimators is of dimension (k-1)x(k-1).