Description Usage Arguments Details Value References Examples
Create kernel density estimate along the support of the raw data using the HADES method
1 | CreateDensity(y, optns = list())
|
y |
A vector of raw readings. |
optns |
A list of options control parameters specified by |
Available control options are
The bandwidth value for the smoothed mean function (using 'CV' or 'GCV'); positive numeric - default: determine automatically based on CV
The number of support points the KDE; numeric - default: 101
The size of the bin to be used; numeric - default: determine automatically as "max(c(diff(range(y))/1000, min(diff(sort(unique(y))))))"
smoothing kernel choice, "rect", "gauss", "epan", "gausvar", "quar" - default: "gauss"
logical if we expect the distribution to have infinite support or not; logical - default: TRUE
User defined output grid for the support of the KDE, it overrides nRegGrid; numeric - default: NULL
A list containing the following fields:
bw |
Variance for measure error.The bandwidth used by smoothing. |
x |
A vector of length nGridReg with the values of the KDE's support points. |
y |
A vector of length nGridReg with the values of the KDE at the support points. |
HG Mueller, JL Wang and WB Capra (1997). "From lifetables to hazard rates: The transformation approach." Biometrika 84, 881-892.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | par(mfrow=c(1,2))
makeComparisonPlotE <- function(N, mySeed = 123){
set.seed(mySeed)
asdf2 = (rexp(N, rate = 1.5))
plot(density(asdf2, bw = "SJ"), main= "Exponential (rate=1.5)",
xlab = paste0(collapse = '', c( "N = ", as.character(N))) , ylim = c(0, 1.45))
lines(density(asdf2), col='red')
Unormal = CreateDensity(y = asdf2, optns = list(infSupport = FALSE))
lines(col='green', x = Unormal$x, y = Unormal$y)
lines(col='magenta' , Unormal$x, dexp(Unormal$x, rate = 1.5))
abline(v = min(asdf2))
abline(v = max(asdf2))
legend(legend = c("SJ", "R-default", "HADES-like", "True PDF"),
lwd= 2, col=c("black", "red", "green", "magenta"), bty = 'n', 'topright')
}
makeComparisonPlotE(100)
makeComparisonPlotE(2000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.