Code Monkey home page Code Monkey logo

Comments (5)

ASKurz avatar ASKurz commented on May 30, 2024 1

That’s a great suggestion! I played around with different solutions to that kind of plot in a recent blog and this is a nice addition to those methods. Thanks for bringing it to my attention. Before I release the next revision of the Rethinking project, I’ll update this plot, for sure.

from statistical_rethinking_with_brms_ggplot2_and_the_tidyverse.

ASKurz avatar ASKurz commented on May 30, 2024

I ultimately went with a different solution. But the spirit is the same. It'll appear in the upcoming bookdown update. Thanks again for opening the issue.

from statistical_rethinking_with_brms_ggplot2_and_the_tidyverse.

gglee4ai avatar gglee4ai commented on May 30, 2024

There are some zigzags in Fig. 12.2.a. I am not sure what is the reason. But the set.seed and sample_n affected the pattern. Please check the figure.

from statistical_rethinking_with_brms_ggplot2_and_the_tidyverse.

ASKurz avatar ASKurz commented on May 30, 2024

What seed values gave you noticeably different results?

from statistical_rethinking_with_brms_ggplot2_and_the_tidyverse.

gglee4ai avatar gglee4ai commented on May 30, 2024

I reproduced the graph in my PC.
I guess there is a problem in (sample_n, expand, nesting)

Fig. 12.2.b with zig-zag lines

sample_n: 35

set.seed(12)
post %>%
  sample_n(35, replace = FALSE) %>%
  expand(nesting(iter, b_Intercept, sd_tank__Intercept),
    x = seq(-4, 5, length.out = 100)
  ) %>%
  mutate(
    y = dnorm(x, b_Intercept, sd_tank__Intercept)
  ) %>%
  ggplot(aes(x = x, y = y, group = iter)) +
  geom_line(alpha = .5, color = "orange2") +
  labs(
    title = "Population survival distribution",
    subtitle = "The Gaussians are on the log-odds scale."
  ) +
  scale_y_continuous(NULL, breaks = NULL) +
  coord_cartesian(xlim = c(-3, 4)) +
  theme_fivethirtyeight() +
  theme(
    plot.title = element_text(size = 13),
    plot.subtitle = element_text(size = 10)
  )

https://raw.githubusercontent.com/gglee4ai/public/master/sample35.png

Fig. 12.2.b without zig-zag lines

sample_n: 30

set.seed(12)
post %>%
  sample_n(30, replace = FALSE) %>%
  expand(nesting(iter, b_Intercept, sd_tank__Intercept),
    x = seq(-4, 5, length.out = 100)
  ) %>%
  mutate(
    y = dnorm(x, b_Intercept, sd_tank__Intercept)
  ) %>%
  ggplot(aes(x = x, y = y, group = iter)) +
  geom_line(alpha = .5, color = "orange2") +
  labs(
    title = "Population survival distribution",
    subtitle = "The Gaussians are on the log-odds scale."
  ) +
  scale_y_continuous(NULL, breaks = NULL) +
  coord_cartesian(xlim = c(-3, 4)) +
  theme_fivethirtyeight() +
  theme(
    plot.title = element_text(size = 13),
    plot.subtitle = element_text(size = 10)
  )

https://raw.githubusercontent.com/gglee4ai/public/master/sample30.png

from statistical_rethinking_with_brms_ggplot2_and_the_tidyverse.

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.