Giter VIP home page Giter VIP logo

Comments (5)

strengejacke avatar strengejacke commented on July 18, 2024

This is what I get right now:

tot <- rep(10, 100)
suc <- rbinom(100, prob = 0.9, size = tot)
df <- data.frame(tot, suc)
df$prop <- suc / tot

mod1 <- glm(cbind(suc, tot - suc) ~ 1,
  family = binomial,
  data = df
)

performance::check_posterior_predictions(mod1)

mod2 <- glm(prop ~ 1,
  family = binomial,
  data = df,
  weights = tot
)

performance::check_posterior_predictions(mod2)

mod3 <- glm(cbind(suc, tot) ~ 1,
  family = binomial,
  data = df
)

performance::check_posterior_predictions(mod3)

And this is when I change the code to your suggestion:

tot <- rep(10, 100)
suc <- rbinom(100, prob = 0.9, size = tot)
df <- data.frame(tot, suc)
df$prop <- suc / tot

mod1 <- glm(cbind(suc, tot - suc) ~ 1,
  family = binomial,
  data = df
)

performance::check_posterior_predictions(mod1)
#> Warning: Maximum value of original data is not included in the
#>   replicated data.
#>   Model may not capture the variation of the data.

mod2 <- glm(prop ~ 1,
  family = binomial,
  data = df,
  weights = tot
)

performance::check_posterior_predictions(mod2)

mod3 <- glm(cbind(suc, tot) ~ 1,
  family = binomial,
  data = df
)

performance::check_posterior_predictions(mod3)
#> Warning: Maximum value of original data is not included in the
#>   replicated data.
#>   Model may not capture the variation of the data.

I'll look into this, but right now I'm not sure which approach is more appropriate.

from performance.

richardjtelford avatar richardjtelford commented on July 18, 2024

Thanks for having a look at this. I appear to have given a partial fix. Looking again line 288

  out$y <- response[, 1] / response[, 2]

would also need to become

  out$y <- response[, 1] / rowSums(response)

so that it was calculated in the same way

from performance.

strengejacke avatar strengejacke commented on July 18, 2024

Ok, this would be the result:

set.seed(123)
tot <- rep(10, 100)
suc <- rbinom(100, prob = 0.9, size = tot)
df <- data.frame(tot, suc)
df$prop <- suc / tot

mod1 <- glm(cbind(suc, tot - suc) ~ 1,
  family = binomial,
  data = df
)

mod2 <- glm(prop ~ 1,
  family = binomial,
  data = df,
  weights = tot
)

mod3 <- glm(cbind(suc, tot) ~ 1,
  family = binomial,
  data = df
)

mod4 <- glm(am ~ 1,
  family = binomial,
  data = mtcars
)

performance::check_predictions(mod1)

performance::check_predictions(mod2)

performance::check_predictions(mod3)

performance::check_predictions(mod4)

from performance.

richardjtelford avatar richardjtelford commented on July 18, 2024

Thank you. That looks how I would expect it to.

Would be nice to improve the x-axis label, but not sure what would work and be easy

from performance.

strengejacke avatar strengejacke commented on July 18, 2024

After fixing a bug in insight, this is how it would look like with the current implementation, and your suggested fix.

set.seed(1)
tot <- rep(10, 100)
suc <- rbinom(100, prob = 0.9, size = tot)
df <- data.frame(tot, suc)
df$prop <- suc / tot

mod1 <- glm(cbind(suc, tot - suc) ~ 1,
  family = binomial,
  data = df
)

mod2 <- glm(prop ~ 1,
  family = binomial,
  data = df,
  weights = tot
)

mod3 <- glm(cbind(suc, tot) ~ 1,
  family = binomial,
  data = df
)

mod4 <- glm(am ~ 1,
  family = binomial,
  data = mtcars
)

Mod1

Curent (mod1)

New (mod1)

Mod2

Curent (mod2)

New (mod2)

Mod3

Curent (mod3)

New (mod3)

Mod4

Curent (mod4)

New (mod4)

from performance.

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.