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

Validate single numeric value for alpha argument #184

Merged
merged 2 commits into from
Sep 14, 2020

Conversation

juliasilge
Copy link
Member

This PR closes #180 by validating that the alpha argument for the three bootstrap CI functions is a single numeric value.

library(tidyverse)
library(rsample)
library(broom)

lm_est <- function(split, ...) {
  lm(mpg ~ disp + hp, data = analysis(split)) %>%
    tidy()
}

set.seed(52156)

car_rs <-
  bootstraps(mtcars, 200, apparent = TRUE) %>%
  mutate(results = map(splits, lm_est))

int_pctl(car_rs, results, alpha = c(0.05, 0.2))
#> Error: `alpha` must be a single numeric value.
#> Backtrace:
#>     █
#>  1. └─rsample::int_pctl(car_rs, results, alpha = c(0.05, 0.2))
int_t(car_rs, results, alpha = "potato")
#> Error: `alpha` must be a single numeric value.
#> Backtrace:
#>     █
#>  1. └─rsample::int_t(car_rs, results, alpha = "potato")
int_bca(car_rs, results, alpha = 1:4, .fn = lm_est)
#> Error: `alpha` must be a single numeric value.
#> Backtrace:
#>     █
#>  1. └─rsample::int_bca(car_rs, results, alpha = 1:4, .fn = lm_est)

int_bca(car_rs, results, alpha = 0.2, .fn = lm_est)
#> Warning: Recommend at least 1000 non-missing bootstrap resamples for terms:
#> `(Intercept)`, `disp`, `hp`.
#> # A tibble: 3 x 6
#>   term         .lower .estimate  .upper .alpha .method
#>   <chr>         <dbl>     <dbl>   <dbl>  <dbl> <chr>  
#> 1 (Intercept) 28.5      30.9    32.6       0.2 BCa    
#> 2 disp        -0.0425   -0.0299 -0.0221    0.2 BCa    
#> 3 hp          -0.0426   -0.0270 -0.0149    0.2 BCa

Created on 2020-09-14 by the reprex package (v0.3.0.9001)

@juliasilge juliasilge requested a review from topepo September 14, 2020 22:26
@juliasilge juliasilge merged commit e1f149d into master Sep 14, 2020
@juliasilge juliasilge deleted the validate-alpha-arg branch September 15, 2020 16:56
@github-actions
Copy link

This pull request 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 21, 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

Successfully merging this pull request may close these issues.

int_pctl alpha parameter accepts numeric arguments, but does not apply them correctly
2 participants