r - Extracting probability from density object -
i building density objects ecology project working on. density
function in r
works quite nicely fitting density functions data.
an illustration of how using density
function shown below:
dens.iris <- density(iris$sepal.length, bw = "bcv")
this works well. however, predict
function not seem work density
objects. know way extract density value specific point (e.g. in iris
dataset, extract sepal.length of 6.432)? of import utilize biased cross validation
technique this.
you utilize approxfun
function linearly interpolate points between given density result. use
diris <- with(dens.iris, approxfun(x, y, rule=1)) diris(6.432) # [1] 0.349344
also
curve(diris(x), from=4.0, to=7.9)
of course of study have remember values of density curve not same thing probabilities. continuous distribution, probability sepal length 6.432 0.
r
No comments:
Post a Comment