Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Distribution of SD not Appropriately Calculated #523

Closed
davidaarmstrong opened this issue Jan 26, 2024 · 3 comments
Closed

Null Distribution of SD not Appropriately Calculated #523

davidaarmstrong opened this issue Jan 26, 2024 · 3 comments

Comments

@davidaarmstrong
Copy link

The problem

Using the infer package, when trying to calculate the null distribution of the standard deviation, the wrong values are produced. The problem is that the bootstrap() function that is called by generate() does not impose the null hypothesis condition when the hypothesis is about the standard deviation (like it does for the mean and median).

Reproducible example

In this example, the histogram should be centred at 5 - the null hypothesized value for sigma. Instead, it's centred around the empirical sd of the raw x variable used as input. For a slightly longer discussion, see this question that I answered on SO.

library(tidyverse)
library(infer)
set.seed(207)
dat <- tibble(x = rnorm(100, mean = 2, sd = 2))
sd(data$x)
#> Error in data$x: object of type 'closure' is not subsettable
dat %>%
  specify(response = x) %>%
  hypothesise(null = "point", sigma = 5) %>%
  generate(reps = 1000, type = "bootstrap") %>%
  calculate("sd") %>%
  visualize()

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

@simonpcouch
Copy link
Collaborator

Thanks for the issue!

Duplicate of #127 and #464. You may find the discussion in #127 eliciting. :)

Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2024
@simonpcouch
Copy link
Collaborator

Woops, wrong reference. That commit should read #532.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants