Calculating an area under a continuous density plot

前端 未结 2 1587
旧巷少年郎
旧巷少年郎 2021-02-10 16:07

I have two density curves plotted using this:

Network <- Mydf$Networks
quartiles <-  quantile(Mydf$Avg.Position,  probs=c(25,50,75)/100)
density <- ggpl         


        
2条回答
  •  梦毁少年i
    2021-02-10 16:39

    Three possibilities:

    The logspline package provides a different method of estimating density curves, but it does include pnorm style functions for the result.

    You could also approximate the area by feeding the x and y variables returned by the density function to the approxfun function and using the result with the integrate function. Unless you are interested in precise estimates of small tail areas (or very small intervals) then this will probably give a reasonable approximation.

    Density estimates are just sums of the kernels centered at the data, one such kernel is just the normal distribution. You could average the areas from pnorm (or other kernels) with the sd defined by the bandwidth and centered at your data.

提交回复
热议问题