diff_quantile_response: diff_quantile_response

View source: R/TSDT_scoring_functions.R

diff_quantile_responseR Documentation

diff_quantile_response

Description

Return the difference across treatment arms of a specified response quantile

Usage

diff_quantile_response(data, scoring_function_parameters = NULL)

Arguments

data

data.frame containing response data

scoring_function_parameters

named list of scoring function control parameters

Details

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.

Value

A difference of response quantiles across treatment arms

See Also

TSDT, quantile_response, quantile

Examples

## 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'] )

TSDT documentation built on April 7, 2022, 1:07 a.m.