Learn R Programming

Kernelheaping (version 1.5)

dclass: Kernel density estimation for classified data

Description

Kernel density estimation for classified data

Usage

dclass(xclass, classes, burnin = 2, samples = 5, boundary = FALSE,
  bw = "nrd0", evalpoints = 200, adjust = 1)

Arguments

xclass
classified values; factor with ordered factor values
classes
numeric vector of classes; Inf as last value is allowed
burnin
burn-in sample size
samples
sampling iteration size
boundary
TRUE for positive only data (no positive density for negative values)
bw
bandwidth selector method, defaults to "nrd0" see density for more options
evalpoints
number of evaluation grid points
adjust
as in density, the user can multiply the bandwidth by a certain factor such that bw=adjust*bw

Value

  • The function returns a list object with the following objects (besides all input objects):
  • Mestimateskde object containing the corrected density estimate
  • gridxVector Grid on which density is evaluated
  • resultDensityMatrix with Estimated Density for each iteration
  • resultXMatrix of true latent values X estimates

Examples

Run this code
x=rlnorm(500, meanlog = 8, sdlog = 1)
classes <- c(0,500,1000,1500,2000,2500,3000,4000,5000,6000,8000,10000,15000,Inf)
xclass <- cut(x,breaks=classes)
densityEst <- dclass(xclass=xclass, classes=classes, burnin=2, samples=5, evalpoints=1000)
hist(densityEst$xclass,breaks=densityEst$classes)
lines(densityEst$Mestimates~densityEst$gridx,col="purple",lwd=2)

Run the code above in your browser using DataLab