Get Thresholds
cross_threshold(d, group, x, y, quantiles = c(0, 0.9), participant = NULL)
d | wide,dataframe containing the |
---|---|
group | name of column (bare only) |
x, y | names of column (bare or quoted) in d with which to do the regression |
quantiles | threshold to apply. |
participant | optional secondary grouping column. Can be used to nest thresholding (e.g., calculate the quantiles within each participant separately) |
data frame object with one column for the group
, potentially another index
column for participant
, and a new column called Threshold.
The Threshold
column is crossed with the original dataset, but for each crossing, members
of group
are excluded if they do not cross the threshold.
sub02 %>% tidyr::pivot_wider(names_from = contrast, values_from = y) %>% cross_threshold(voxel, low, high)#> # A tibble: 206 x 2 #> voxel Threshold #> <fct> <dbl> #> 1 191852 0 #> 2 191852 0.9 #> 3 197706 0 #> 4 197769 0 #> 5 197842 0 #> 6 197906 0 #> 7 197907 0 #> 8 203688 0 #> 9 203689 0 #> 10 203690 0 #> # … with 196 more rows# can also calculate within groups sub02 %>% tidyr::pivot_wider(names_from = contrast, values_from = y) %>% cross_threshold(c(voxel, run), low, high, participant = sub)#> # A tibble: 3,703 x 4 #> voxel run Threshold sub #> <fct> <fct> <dbl> <fct> #> 1 191852 1 0 2 #> 2 191852 2 0 2 #> 3 191852 2 0.9 2 #> 4 191852 3 0 2 #> 5 191852 3 0.9 2 #> 6 191852 4 0 2 #> 7 191852 5 0 2 #> 8 191852 5 0.9 2 #> 9 191852 6 0 2 #> 10 191852 6 0.9 2 #> # … with 3,693 more rows