Learn R Programming

probhat (version 0.4.1)

22_categorical_distributions: Categorical Models

Description

Fit categorical distributions, from data.

NOTE THAT THESE OBJECTS ARE LIKELY TO BE CONVERTED TO S4 OBJECTS, IN THE NEAR FUTURE. ALSO, NOTE THAT THEIR INTERNAL STRUCTURE (THAT IS, THEIR ATTRIBUTES/SLOTS), IS SUBJECT TO CHANGE.

IN PRINCIPLE, YOU SHOULD NOT ACCESS ATTRIBUTES/SLOTS, DIRECTLY.

Usage

#univariate
pmfuv.cat (g, h=1)
cdfuv.cat (g, h=1)
qfuv.cat (g, h=1)

#conditional pmfc.cat (g, h=1, …, conditions, warning=TRUE) cdfc.cat (g, h=1, …, conditions, warning=TRUE) qfc.cat (g, h=1, …, conditions, warning=TRUE)

Arguments

g

Integer/factor/character vector of groups. Also, can be a named list of such vectors. For univariate distributions, the list should only have one vector. For conditional distributions, the list needs two or more equal-length vectors.

h

Optional numeric vector of frequencies (or weights). It's length should be one or n, equal the length of the g vectors.

conditions

An integer vector of category indices, a character vector of category names, or a list which can contain either integers (indices) or strings (names). The vector or list can be named (which is preferable) or unnamed. If named, then the names are matched against the variable names. If unnamed, then the first condition applies to the first variable, and the second condition applies to the second variable, and so on. Note that the number of conditions needs to equal the number of variables minus one.

warning

Logical, if true, generate warning if there's no observations within the conditional window.

Additional arguments not allowed.

Value

Self-referencing function objects.

Refer to Runtime Function Objects

Except: The constructors for conditional distributions, return NULL, if there's no observations within the conditional window. (And by default, generate a warning).

Details

PLEASE SET NOTES IN DESCRIPTION FIELD.

Refer to the vignette for more information.

Default variable names are generated, if the g list is unnamed. (In conditional models, a warning is generated).

References

Refer to the vignette for an overview, references and better examples.

See Also

Succinct Constructors Discrete Kernel Smoothing, Continuous Kernel Smoothing, Empirical-Like Distributions

Conditional Distributions with Mixed Input Types These can be used for statistical classification purposes.

is.cat, ph.printf.phmodel, ph.plotf.catuv

Examples

Run this code
# NOT RUN {
prep.ph.data ()

gfh <- pmfuv.cat (crime.type, n.arrests)
gFht <- qfuv.cat (crime.type, n.arrests)

plot (gfh, freq=TRUE)
ph.mode (gfh)
ph.mode (gfh, level.names=TRUE)

gFht (0.5)
gFht (0.5, category=TRUE)
# }

Run the code above in your browser using DataLab