ggplot2 - Layering density plots in R without using density() -


i've computed , plotted gaussian kernel density estimates using kernsmooth package follows:

 x <- mydata$mynumericvector  h <- dpik(x)  est <- bkde(x, bandwidth=h)  plot(est, type='l') 

this method described in kernsmooth's documentation. note dpik() finds optimal bandwidth , bkde() uses bandwidth fit kernel density estimate. it's important use method instead of basic density() function.

how layer these plots on top of 1 another?

i cannot use basic density() function geom_density() ggplot2 relies upon, bandwidths , kernel density estimates best optimized using kernsmooth package (see deng & wickham, 2011 here: http://vita.had.co.nz/papers/density-estimation.pdf). since wickham wrote ggplot2 , above review of kernel density estimation packages, make sense there's way use ggplot2 layer densities aren't reliant on basic density() function, i'm not sure.

can use ggplot2 if don't wish use basic density() function? lattice ?

you geom_line:

 m <- ggplot(null, aes(x=bkde(movies$votes)$x,y=bkde(movies$votes)$y)) + geom_line()  print(m) 

if doing t lattice::densityplot, add of values drags-list:

darg
list of arguments passed density function. typically, should list 0 or more of following components : bw, adjust, kernel, window, width, give.rkern, n, from, to, cut, na.rm (see density details)


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -