View source: R/TSDT_scoring_functions.R
mean_response | R Documentation |
Compute the mean response.
mean_response(data, scoring_function_parameters = NULL)
data |
data.frame containing response data |
scoring_function_parameters |
named list of scoring function control parameters |
This function will compute the mean of the response variable. If a value for trt_arm is provided the mean in that treatment arm only will be computed (and the trt variable must also be provided), otherwise the mean for all data passed to the function will be computed.
The mean of the provided response variable.
TSDT, treatment_effect
N <- 50 data <- data.frame( continuous_response = numeric(N), trt = character(N) ) data$continuous_response <- runif( min = 0, max = 20, n = N ) data$trt <- sample( c('Control','Experimental'), size = N, prob = c(0.4,0.6), replace = TRUE ) ## Compute mean response for all data mean_response( data, scoring_function_parameters = list( y_var = 'continuous_response' ) ) mean( data$continuous_response ) # Function return value should match this value ## Compute mean response for Experimental treatment arm only scoring_function_parameters <- list( y_var = 'continuous_response', trt_arm = 'Experimental' ) mean_response( data, scoring_function_parameters = scoring_function_parameters ) # Function return value should match this value mean( data$continuous_response[ data$trt == 'Experimental' ] )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.