rvlenth / emmeans

Estimated marginal means
https://rvlenth.github.io/emmeans/
364 stars 32 forks source link

brms intervals #127

Closed dshelldhillon closed 5 years ago

dshelldhillon commented 5 years ago

Hi Russell, Is there a way I can change the type of intervals for brms models? I'm interested in quantile based intervals rather than HDPI intervals - I was wondering if you've implemented this? For simple models I can use the posterior samples to do this but wanted to see if there's a way in emmeans.

Thanks!

rvlenth commented 5 years ago

Not directly. However, you can do something like:

emm = emmeans(model, ...)
samp = as.mcmc(emm)

Then summarize or plot samp in any way you like. It will be a matrix with each column being the respective sample of posterior EMMs.

Do you think it's important to provide other summarization options in hpd.summary()? [It seems awkward to do so, due to the name of the function...]

Russ

DominiqueMakowski commented 5 years ago

Alternatively, most of bayestestR's functions (including equal-tailed (quantile-based) and highest density intervals) are supporting emmeans objects ☺️:

library(rstanarm)
library(emmeans)
library(bayestestR)

model <- stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0)
model <- emmeans(model, "Species")

bayestestR::ci(model, method = "ETI")
#>    Parameter CI   CI_low  CI_high
#> 1     setosa 89 4.891432 5.123702
#> 2 versicolor 89 5.816330 6.051166
#> 3  virginica 89 6.472271 6.702710
bayestestR::ci(model, method = "HDI")
#>    Parameter CI   CI_low  CI_high
#> 1     setosa 89 4.890910 5.122793
#> 2 versicolor 89 5.819624 6.053941
#> 3  virginica 89 6.471102 6.701433

Created on 2019-07-19 by the reprex package (v0.3.0)

rvlenth commented 5 years ago

@DominiqueMakowski Thanks! I didn't know that

dshelldhillon commented 5 years ago

Thanks Russell!