Learn R Programming

fMultivar (version 251.70)

BivariateTools: Handling Missing Values

Description

A collection and description of functions for managing bivariate data sets. The functions include a grid generator, a kernel density estimator, a histogram counter, and a suite of bivariate elliptical distribution functions. The functions are: ll{ grid2d Creates from two vectors x-y grid coordinates, density2d returns 2D Kernel Density Estimates, hist2d returns 2D Histogram Counts, integrate2d integrates over a two dimensional unit square, pnorm2d computes bivariate normal distribution function, dnorm2d computes bivariate normal density function, rnorm2d generates bivariate normal random deviates, pcauchy2d computes bivariate Cauchy distribution function, dcauchy2d computes bivariate Cauchy density function, rcauchy2d generates bivariate Cauchy random deviates, pt2d computes bivariate Student-t distribution function, dt2d computes bivariate Student-t density function, rt2d generates bivariate Student-t random deviates, delliptical2d computes bivariate density for elliptical distributions. }

Usage

grid2d(x = (0:10)/10, y = x)
density2d(x, y = NULL, n = 20, h = NULL, limits = c(range(x), range(y))) 
hist2d(x, y = NULL, n = c(20, 20))
integrate2d(fun, error = 1.0e-5, ...)

pnorm2d(x, y = x, rho = 0) dnorm2d(x, y = x, rho = 0) rnorm2d(n, rho = 0)

pcauchy2d(x, y = x, rho = 0) dcauchy2d(x, y = x, rho = 0) rcauchy2d(n, rho = 0)

pt2d(x, y = x, rho = 0, nu = 4) dt2d(x, y = x, rho = 0, nu = 4) rt2d(n, rho = 0, nu = 4)

delliptical2d(x, y = x, rho = 0, param = NULL, type = c("norm", "cauchy", "t", "logistic", "laplace", "kotz", "epower"), output = c("vector", "list"))

Arguments

error
[integrate2d] - the error bound to be achieved by the integration formula. A numeric value.
fun
[integrate2d] - the function to be integrated. The first argument requests the x values, the second the y values, and the remaining are reserved for additional parameters. The integration is over the unit square "[0,1]^2".
h
[density2d] - a vector of bandwidths for x and y directions. Defaults to normal reference bandwidth.
limits
[hist2d] - the limits of the rectangle covered by the grid.
n
[density2d] - n - an integer specifying the number of grid points in each direction. The default value is 20. [hist2D] - In this case n may be a scalar or a two element vector. The default value is 20. [rnorm2d] - the num
nu
[*t2d] - the number of degrees of freedom, a numeric value ranging between two and infinity, by default four.
output
[*elliptical2d] - output - a character string specifying how the output should be formatted. By default a vector of the same length as u and v. If specified as "list" then u and
param
[delliptical2d] - additional parameters to specify the bivariate density function. Only effective for the Kotz and Exponential Power distribution. For the Kotz distribution we can specify a numeric value, by default defined as
rho
[*norm2d][*cauchy2d][*t2d][*elliptical2d] - the correlation parameter, a numeric value ranging between minus one and one, by default zero.
type
[*elliptical2d] - the type of the elliptical copula. A character string selected from: "norm", "cauchy", "t", "laplace", "kotz", or "epower".
x, y
[grid2d][*norm2d][*t2d] - two numeric vectors defining the x and y coordinates. [density2D][hist2D] - two vectors of coordinates of data. If y is NULL then x is assumed to be a two column matrix, where the first
...
[integrate2d] - parameters passed to the function to be integrated.

Value

  • grid2d returns a list with two vectors named $x and $y spanning the grid defined by the coordinate vectors x and y. density2d hist2d returns a list with three elements $x, $y, and $z. x and y are vectors spanning the two dimensional grid and z the corresponding matrix. The output can directly serve as input to the plotting functions image, contour and persp. integrate2d returns a list with the $value of the integral over the unit square [0,1]^2, an $error estimate and the number of grid $points used by the integration function. pnorm2d returns a vector of probabilities for the normal distribution function. pnorm2d returns a two column matrix of random deviates generated from the bivariate normal distribution function.

References

Azzalini A., (2004); The sn Package; R Reference Guide available from www.r-project.org. Venables W.N., Ripley B.D., (2002); Modern Applied Statistics with S, Fourth Edition, Springer. Warnes G.R., (2004); The gregmisc Package; R Reference Guide available from www.r-project.org.

Examples

Run this code
## Normal Density:
   x = (-40:40)/10
   X = grid2d(x)
   z = dnorm2d(X$x, X$y, rho = 0.5)
   Z = list(x = x, y = x, z = matrix(z, ncol = length(x)))
   persp(Z, theta = -40, phi = 30, col = "steelblue")

Run the code above in your browser using DataLab