histde: Histogram density estimate

View source: R/hist.R

histdeR Documentation

Histogram density estimate

Description

Histogram density estimate for 1- and 2-dimensional data.

Usage

histde(x, binw, xmin, xmax, adj=0)

## S3 method for class 'histde'
predict(object, ..., x)

Arguments

x

matrix of data values

binw

(vector) of binwidths

xmin,xmax

vector of minimum/maximum values for grid

adj

displacement of default anchor point, in percentage of 1 bin

object

object of class histde

...

other parameters

Details

If binw is missing, the default binwidth is \hat{b}_i = 2 \cdot 3^{1/(d+2)} \pi^{d/(2d+4)} S_i n^{-1/(d+2)}, the normal scale selector.

If xmin is missing then it defaults to the data minimum. If xmax is missing then it defaults to the data maximum.

Value

A histogram density estimate is an object of class histde which is a list with fields:

x

data points - same as input

eval.points

vector or list of points at which the estimate is evaluated

estimate

density estimate at eval.points

binw

(vector of) bandwidths

nbin

(vector of) number of bins

names

variable names

See Also

plot.histde

Examples

## positive data example
set.seed(8192)
x <- 2^rnorm(100)
fhat <- histde(x=x)
plot(fhat, border=6)
points(c(0.5, 1), predict(fhat, x=c(0.5, 1)))

## large data example on a non-default grid
set.seed(8192)
x <- rmvnorm.mixt(10000, mus=c(0,0), Sigmas=invvech(c(1,0.8,1)))
fhat <- histde(x=x, xmin=c(-5,-5), xmax=c(5,5))
plot(fhat)

## See other examples in ? plot.histde

ks documentation built on Aug. 11, 2023, 1:10 a.m.