Created
August 21, 2017 13:02
-
-
Save benwhalley/36b99ecfdccb19f5a3ed8cb8b3cd0a5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dplyr') | |
require('rethinking') | |
dmode <- function(x) { | |
den <- density(x, kernel=c("gaussian")) | |
( den$x[den$y==max(den$y)] ) | |
} | |
meanhpdi <- function(x, prob=.95) { | |
i <- rethinking::HPDI(x, prob=prob) | |
data_frame(y=mean(x), ymin=i[1], ymax=i[2] ) | |
} | |
mmmhpdi <- function(x, prob=.95) { | |
i <- rethinking::HPDI(x, prob=prob) | |
data_frame(y=mean(x), mode=dmode(x), median=median(x), ymin=i[1], ymax=i[2] ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment