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

success argument in prop_test() #347

Closed
ismayc opened this issue Dec 13, 2020 · 9 comments
Closed

success argument in prop_test() #347

ismayc opened this issue Dec 13, 2020 · 9 comments
Assignees

Comments

@ismayc
Copy link
Collaborator

ismayc commented Dec 13, 2020

Reviewing https://infer.tidymodels.org/reference/prop_test.html, it strikes me that {infer} should probably have a success argument for prop_test() if testing a point estimate in much the same way that order exists in the two sample case. In the gss data below, the unique values of college are "degree" or "no degree" and it seems that "degree" is specified as a success here (maybe internally to prop.test()?), but to a beginner that wouldn't necessarily be apparent.

library(infer)

# proportion test for difference in proportions of 
# college completion by respondent sex
prop_test(gss, 
          college ~ sex,  
          order = c("female", "male"))
#> # A tibble: 1 x 6
#>   statistic chisq_df p_value alternative lower_ci upper_ci
#>       <dbl>    <dbl>   <dbl> <chr>          <dbl>    <dbl>
#> 1 0.0000204        1   0.996 two.sided     -0.101   0.0917          
# a one-proportion test for hypothesized null 
# proportion of college completion of .2
prop_test(gss,
          college ~ NULL,
          p = .2)
#> # A tibble: 1 x 4
#>   statistic chisq_df   p_value alternative
#>       <dbl>    <int>     <dbl> <chr>      
#> 1      636.        1 2.98e-140 two.sided  
@echasnovski
Copy link
Collaborator

It seems to be the same functionality as added in #344. Am I missing something here?

@ismayc
Copy link
Collaborator Author

ismayc commented Dec 13, 2020

Sorry, I didn't have the develop version of the package installed and I missed this update for some reason..

@ismayc ismayc closed this as completed Dec 13, 2020
@ismayc
Copy link
Collaborator Author

ismayc commented Dec 13, 2020

@echasnovski @simonpcouch Should we also update the example to include the new success argument?

# one-sample proportion test for hypothesized null
# proportion of college completion of .2
prop_test(gss,
          college ~ NULL,
          success = "degree",
          p = .2)

@ismayc ismayc reopened this Dec 13, 2020
@ismayc
Copy link
Collaborator Author

ismayc commented Dec 13, 2020

I know that prop.test() reports a Chi-square statistic for the point estimate test and for the difference in proportions test, but that is rarely how it is taught initially to novices. Usually, it is first taught as a z statistic (for example, from OpenIntro). Maybe having a z = FALSE argument by default could be a nice way for instructors to turn it on and then after students feel comfortable with that, they could move on to discuss how z^2 = Chi-square?

@ismayc
Copy link
Collaborator Author

ismayc commented Dec 13, 2020

This also would help prop_test() be more in alignment with the example in the Full infer Pipeline Examples vignette similar to how the other examples there match with corresponding wrapper functions like t_test():

null_distn_theoretical <- gss %>%
  specify(college ~ sex, success = "no degree") %>%
  hypothesize(null = "independence") %>%  
  calculate(stat = "z", order = c("female", "male"))

@simonpcouch
Copy link
Collaborator

I'm on board for both of your suggestions, I think!

Working on finals at the moment, so will need a few days, but glad to spend some time with this.

@ismayc
Copy link
Collaborator Author

ismayc commented Dec 14, 2020

Of course! No rush

@simonpcouch
Copy link
Collaborator

Closing in favor of #353. :-)

@github-actions
Copy link

github-actions bot commented Mar 8, 2021

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 Mar 8, 2021
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

3 participants