Giter Site home page Giter Site logo

Comments (4)

simonpcouch avatar simonpcouch commented on August 28, 2024

Thanks for the issue, @WillemSleegers.

This result is indeed expected; the distributions resulting from those two randomization procedures are quite different. We can visualize those distributions to better understand how those p-values are derived:

library(infer)

set.seed(1)

observed_statistic <- gss %>%
   specify(hours ~ college) %>%
   calculate(stat = "diff in means", order = c("degree", "no degree"))

observed_statistic
#> Response: hours (numeric)
#> Explanatory: college (factor)
#> # A tibble: 1 × 1
#>    stat
#>   <dbl>
#> 1  1.54

boot_dist <- gss %>%
   specify(hours ~ college) %>%
   hypothesize(null = "independence") %>%
   generate(reps = 1000, type = "bootstrap") %>%
   calculate(stat = "diff in means", order = c("degree", "no degree"))

permute_dist <- gss %>%
   specify(hours ~ college) %>%
   hypothesize(null = "independence") %>%
   generate(reps = 1000, type = "permute") %>%
   calculate(stat = "diff in means", order = c("degree", "no degree"))

visualize(boot_dist) + shade_p_value(observed_statistic, direction = "two-sided")

visualize(permute_dist) + shade_p_value(observed_statistic, direction = "two-sided")

Created on 2024-01-08 with reprex v2.0.2

The distribution derived from permutation is centered at 0 since any association between hours and college has been disrupted via permuting one of the variables. The bootstrap distribution is centered at the observed statistic since whole rows are bootstrapped together, preserving any association present in the inputted data.

from infer.

WillemSleegers avatar WillemSleegers commented on August 28, 2024

Thanks for responding @simonpcouch!

I now realize it works as intended (so, sorry for making the issue!), although it's too bad it doesn't work to obtain a similar test compared to that of permute. If I understand it correctly, the bootstrap version could be obtained by sampling from each group after subtracting the observed mean of each group from each group's data point, although I suppose this might not work with how infer works under the hood.

Either way, feel free to close the issue!

from infer.

simonpcouch avatar simonpcouch commented on August 28, 2024

You're welcome!

from infer.

github-actions avatar github-actions commented on August 28, 2024

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

from infer.

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.