Learn R Programming

bivariate (version 0.7.0)

43_density_matrices: Density Matrices

Description

Compute density (and probability) matrices.

Usage

########################################
#(du) discrete uniform 
#(bn) binomial
#(p)  poisson
########################################
# S3 method for DUBV
bvmat(sf, xlim, ylim, …)
# S3 method for BNBV
bvmat(sf, xlim, ylim, …)
# S3 method for PBV
bvmat(sf, xlim, ylim, …)

######################################## #(cu) continuous uniform #(n) normal #(bm) bimodal ######################################## # S3 method for CUBV bvmat(sf, xlim, ylim, …, n=10) # S3 method for NBV bvmat(sf, xlim, ylim, …, n=10) # S3 method for BMBV bvmat(sf, xlim, ylim, …, n=10)

######################################## #(g) categorical #(d) dirichlet #(k) kernel #(e) empirical ######################################## # S3 method for GBV bvmat(sf, …) # S3 method for DTV bvmat(sf, …, log=FALSE, n=10) # S3 method for KBV bvmat(sf, xlim, ylim, …, n=10) # S3 method for EBV bvmat(sf, …, reg=TRUE)

######################################## #additional functions #(called by the ebv method, above) ######################################## ebvmat_reg (sf, xlim, ylim, …, n=10) ebvmat_step (sf, …, extend=FALSE)

Arguments

sf

A suitable function object. Which here, represents one of the probability distributions from this package. Refer to the see also section.

xlim, ylim

A length-two vector for the evaluation window. For discrete distributions, this should be an integer vector, and for continuous distributions, this should be a numeric vector.

n

Integer vector of length one or two, number of grid points. (Except for Dirichlet distributions where it needs to be scalar).

log

Logical, if true, return log-transformed densities.

reg

Logical, if true, evaluate the ECDF over a regularly-spaced grid. In general, reg should be true, for large sample sizes.

extend

Logical vector or length one or two, if true, compute a rim (of probabilities) outside the observed values.

Ignored.

Value

An S4 object with:

An fv slot, which is a matrix, of densities or probabilities.

x and y slots, which are the evaluation points. (This length of x should equal the number of rows, and the length of y should equal the number of columns).

And exception to the above is ECDFs with reg=FALSE, where x and y are breakpoints. (The length of x should be equal to the number of rows plus one, and the length of y should be equal to the number of columns plus one).

Details

These methods work for both PMFs/PDFs and CDFs, where applicable.

For example: If bvmat is called with a normal density function it will return densities (from the density function), however, if called with a normal distribution function it will return the probabilities (from the distribution function).

Note that the ebv (empirical) method calls either the ebvmat_reg or ebvmat_step function, depending on the reg argument.

References

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

See Also

Uniform For uniform distributions.

Binomial, Poisson and Categorical For other probability distributions of discrete random variables.

Normal, Bimodal, Dirichlet and Nonparametric For other probability distributions of continuous random variables.

Main Plotting Functions

Examples

Run this code
# NOT RUN {
data (geyser, package="MASS")
attach (geyser)

#adapted from the KernSmooth package
fh <- kbvpdf (duration, waiting, 0.7, 7)

bvmat (fh)

detach (geyser)
# }

Run the code above in your browser using DataLab