Giter VIP home page Giter VIP logo

Comments (15)

strengejacke avatar strengejacke commented on May 18, 2024 1

I don't think it's too hard. We could have an argument like show_priors or so, and then the layer for the prior can be completely independent from the remaining plot, it's just that we should add the prior layer first, and maybe add some alpha to both prior and posterior layer.

Here's a quick prototype:

library(see)
library(ggplot2)
library(bayestestR)
library(rstanarm)
model <- stan_glm(mpg ~ wt + am, data = mtcars, chains = 1)

p <- plot(point_estimate(model), panel = F)[[2]]
sp <- simulate_prior(model)
ed <- estimate_density(sp[["am"]])

p + geom_ribbon(
  data = ed,
  mapping = aes(
    x = x,
    ymin = 0,
    ymax = y,
    group = NA
  ),
  fill = "#FFC107",
  alpha = .3
)

Created on 2019-09-13 by the reprex package (v0.3.0)

from see.

strengejacke avatar strengejacke commented on May 18, 2024

We should probably think of limiting the range of the x-axis, though, since the prior usually is very wide compared to the posterior.

from see.

DominiqueMakowski avatar DominiqueMakowski commented on May 18, 2024

Nice!

We should probably think of limiting the range of the x-axis,

This is the case for default priors, in which case people are anyway usually not really interested in displaying them anyway, but when people care about the priors I guess it makes sense to display them entirely (even if the plot is uglier)

from see.

strengejacke avatar strengejacke commented on May 18, 2024

And you can add xlim(c(-20, 20)) or similar easily by yourself...

from see.

mattansb avatar mattansb commented on May 18, 2024

but when people care about the priors I guess it makes sense to display them entirely

True, but you still might want to limit the x axis in some way - for example, if a Cauchy prior is used, some very very extreme samples can be drawn - which not only messes up the x-axis, it also messes up the density estimation (which is where logspline shines)...

See how I've dealt with this here (lines 377-390): https://github.com/easystats/bayestestR/blob/master/R/bayesfactor_parameters.R#L377

from see.

strengejacke avatar strengejacke commented on May 18, 2024

So you suggest limiting the range to +/- 7SD (or MAD)? Sounds feasible to me.

from see.

mattansb avatar mattansb commented on May 18, 2024

Yes, I suggest using MAD - SD gives a very wide window with Cauchy / t(df<3).

from see.

strengejacke avatar strengejacke commented on May 18, 2024

hm, doesn't geom_ridgeline_gradient an alpha option?

from see.

strengejacke avatar strengejacke commented on May 18, 2024

ok, geom_ridgeline() has, and I don't need geom_ridgeline_gradient() for the prior layer

from see.

strengejacke avatar strengejacke commented on May 18, 2024

It is probably better to add the prior layer onto the main layer for those plots where we have to use geom_ridgeline_gradient, because that geom allows no alpha.

from see.

strengejacke avatar strengejacke commented on May 18, 2024

I started adding the prior-feature to some of the plots:

https://easystats.github.io/see/articles/bayestestR.html

  • Do we want the argument to be names show_priors or just priors?
  • What about the other arguments, like priors_alpha?

In some cases we hard-code colors (e.g. point-estimate). We may think changing this somewhen in the future...

from see.

mattansb avatar mattansb commented on May 18, 2024

from see.

DominiqueMakowski avatar DominiqueMakowski commented on May 18, 2024

I like when args controlling a main arg stems out of it, so if we go for priors_alpha it makes sense to leave it just as priors = TRUE

from see.

DominiqueMakowski avatar DominiqueMakowski commented on May 18, 2024

from see.

strengejacke avatar strengejacke commented on May 18, 2024

I'm not sure whether there are any plots left to add priors? For HDI, we have the simple density plots, so I think we don't additionally need this option for HDI, do we?

from see.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.