View source: R/TSDT_scoring_functions.R
diff_quantile_response | R Documentation |
Return the difference across treatment arms of a specified response quantile
diff_quantile_response(data, scoring_function_parameters = NULL)
data |
data.frame containing response data |
scoring_function_parameters |
named list of scoring function control parameters |
This function returns the difference across treatment arms of the response quantile associated with a specified percentile. The default behavior is to return the difference in medians.
A difference of response quantiles across treatment arms
TSDT, quantile_response, quantile
## Generate example data containing response and treatment N <- 100 y = runif( min = 0, max = 20, n = N ) df <- as.data.frame( y ) names( df ) <- "y" df$trt <- sample( c('Control','Experimental'), size = N, prob = c(0.4,0.6), replace = TRUE ) ## Default behavior is to return the median diff_quantile_response( df ) # should match previous result from quantile_response median( df$y[df$trt!='Control'] ) - median( df$y[df$trt=='Control'] ) ## Get Q1 response diff_quantile_response( df, scoring_function_parameters = list( percentile = 0.25 ) ) # should match previous result from quantile_response quantile( df$y[df$trt!='Control'], 0.25 ) - quantile( df$y[df$trt=='Control'], 0.25 ) ## Get max response diff_quantile_response( df, scoring_function_parameters = list( percentile = 1 ) ) # should match previous result from quantile_response max( df$y[df$trt!='Control'] ) - max( df$y[df$trt=='Control'] )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.