ropensci / canaper

Categorical Anaysis of Neo- and Paleo-endemism in R
https://docs.ropensci.org/canaper/
Other
7 stars 2 forks source link

How to divide the values of the significance test into <0.01, <0.025 and >0.975, >0.99 #33

Closed chenwy66 closed 2 months ago

chenwy66 commented 3 months ago

I used the cpr_classify_signif function to test for significance, but the result after running the code in the example only shows <0.01, >0.99, and not significant. But I want to divide the significance into 5 levels: <0.01, <0.025, >0.975, >0.99, and not significant, how the code needs to be modified?

My code : data_canape <- cpr_classify_endem(data_rand_res) |> cpr_classify_signif("pd", one_sided = FALSE) |> cpr_classify_signif("rpd", one_sided = FALSE) |> cpr_classify_signif("pe", one_sided = FALSE) |> cpr_classify_signif("rpe", one_sided = FALSE)

1721871690287
joelnitta commented 3 months ago

Since you didn't specify which value you want to calculate the significance of, for demonstration purposes I'll use pd.

In that case, you are correct to use cpr_classify_signif("pd", one_sided = FALSE) in order to obtain results in the 5 levels <0.01, <0.025, >0.975, >0.99, and not significant. If you don't see one of those, it is probably just because it doesn't happen to be in the data.

Here is a reproducible example:

library(canaper)
library(tibble)

set.seed(1234)

data <- tibble(
  pd_obs_p_lower = runif(1000),
  pd_obs_p_upper = 1-pd_obs_p_lower
)

res <- cpr_classify_signif(data, "pd")

dplyr::count(res, pd_signif)
#> # A tibble: 5 × 2
#>   pd_signif           n
#>   <chr>           <int>
#> 1 < 0.01             11
#> 2 < 0.025            26
#> 3 > 0.975            10
#> 4 > 0.99             12
#> 5 not significant   941