top_curves_to_points: Pull the points from the top (1-alpha)% percent of curves.

Description Usage Arguments Details Value Examples

View source: R/distance-depth.R

Description

pulling out data points from curves that are ranked highest based on quantile function.

Usage

1
2
3
4
5
6
7
8
top_curves_to_points(
  x,
  alpha,
  tidy_dm,
  quantile_func = distance_depth_function,
  x_names_df = NULL,
  ...
)

Arguments

x

list or grouped_df containing curves, with index ordering associated with the x_names_df and rownames of tidy_dm

alpha

the proportion of curves to be removed before presenting all the points together. Takes value in [0, 1.0].

tidy_dm

a tidy_dist_mat distance matrix

quantile_func

function to calculate quantiles via the distance_matrix, we now expect this function to handle tidy_dist_mat objects and have a parameter called df_out which we can set as true. See distance_depth_function.tidy_dist_mat for an example.

x_names_df

Only used when x is a list. Group structure associated with the ordering of the items in the list x. Assume the naming structure for tidy_dm is the same as this data frame (can have different ordering).

...

additional parameters to be passed to the quantile_func. Please also see details for more information.

Details

See top_curves_to_points.list and top_curves_to_points.grouped_df for more details and commentary on expected parameters. top_curves_to_points.list requires an additional parameter - x_names_df.

Value

data frame from curves of the top values associated with the quantile_func

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(dplyr)
set.seed(1)
random_data_list <- lapply(1:5, function(x){data.frame(matrix(rnorm(10),
                                                              ncol = 2))})

dist_mat <- dist_matrix_innersq_direction(random_data_list,
                                position = 1:2,
                                verbose = FALSE)

combined_points_list <- quantile_curves_to_points(random_data_list,
                                               alpha = .2,
                                               dist_mat)

random_data_grouped <- random_data_list %>%
  do.call(rbind, .) %>%
  mutate(id = rep(1:5, each = 5)) %>%
  group_by(id)

combined_points_grouped <- quantile_curves_to_points(random_data_grouped,
                                                  alpha = .2,
                                                  dist_mat)

skgallagher/EpiCompare documentation built on Sept. 14, 2021, 5:45 a.m.