Learn R Programming

TSDT (version 1.0.0)

desirable_response_proportion: desirable_response_proportion

Description

Compute proportion of subjects that have a desirable (binary) response

Usage

desirable_response_proportion(data, scoring_function_parameters = NULL)

Arguments

data

data.frame containing response data

scoring_function_parameters

named list of scoring function control parameters

Value

Proportion of (binary) response values that have a desirable value. The desirable value is 1 if desirable_response = 'increasing' and the desirable value is 0 if desirable_response = 'decreasing'.

Details

This function will compute the proportion of subjects for which the response indicates a desirable response. The response proportion can be computed for a single treatment arm only (if valued for trt_arm and trt are provided) or for all data passed to the function.

See Also

linkTSDT, binary_transform

Examples

Run this code
# NOT RUN {
N <- 50

data <- data.frame( y = numeric(N),
                    trt = character(N) )

data$y <- sample( c(0,1), size = N, prob = c(0.5,0.5), replace = TRUE )
data$trt <- sample( c('Control','Experimental'), size = N, prob = c(0.4,0.6), replace = TRUE )

## Compute desirable response proportion for all data with increasing
## desirable response (i.e. larger response value is better)
desirable_response_proportion( data, list( desirable_response = 'increasing' ) )
mean( data$y ) # Function return value should match this value

## Compute desirable response proportion for Experimental treatment arm only
## with decreasing desirable response (i.e. smaller response value is better).
desirable_response_proportion( data, list( trt_arm = 'Experimental',
                                           desirable_response = 'decreasing' ) )
# }

Run the code above in your browser using DataLab