InterventionEffectCalculator.Rd
Class that can be used to calculate the effect of a specific intervention.
For the specification of how to define interventions, look at the
InterventionParser
class.
InterventionEffectCalculator
An object of class R6ClassGenerator
of length 24.
initialize(bootstrap_iterations, outcome_variable
Creates a new InterventionEffectCalculator. @param bootstrap_iterations integer the number of bootstrap iterations to use when calculating the effect of an intervention. If there are more iterations, the result will be more reliable, but calculating will take significantly longer. @param outcome_variable string the name of the variable for which the outcome should be measured. This is usualy Y (depending on you setup). @param parallel (default = TRUE) should the effect calculator run in a multithreaded / multicore way? @param verbose (default = FALSE) the verbosity to use when running the intervention calculation
calculate_intervention_effect(osl, interventions, discrete, initial_data, tau, check = FALSE)
Calculates the actual effect of a set of interventions. This function
will call the evaluate_single_intervention
for each of the
interventions in the list of interventions passed to this functions.
When calling this function one can specify whether to use the discrete
OSL (discrete = TRUE
) or whether to uyse the contionous OSL
(discrete = FALSE
).
@param osl OnlineSuperLearner object the fitted
OnlineSuperLearner
instance. This instance is used to perform
the predictions with.
@param interventions list a list of interventions to use when
calculating the effect of the interventions. Each of these interventions
is processed in sequence and the result is stored in a list.
@param discrete boolean should the discrete superlearner (or the cts
superlearner) be used?
@param initial_data data.table the first row / set of blocks needed to
initialize the intervention estimation algorithm. This block needs to
be large enough to provide enough historical data for all summary
measures.
@param tau integer the time t at which we'd like to measure the effect
of the intervention
@param check (default = FALSE) boolean, should the input parameters be
checked for correctness? This might make the process slighly slower.
@return a list with intervention effects for each of the specified
interventions. Each intervention entry then contains a vector of
intervention effects.
evaluate_single_intervention(osl, initial_data, intervention, tau, discrete)
Calculates the effect of a single intervention. The specification of the
intervention needs to comply with the definition in the
InterventionParser
class. One can specify whether or not to use
the discrete super learner by toggling the discrete
argument.
@param osl OnlineSuperLearner object the fitted
OnlineSuperLearner
instance. This instance is used to perform
the predictions with.
@param initial_data data.table the first row / set of blocks needed to
initialize the intervention estimation algorithm. This block needs to
be large enough to provide enough historical data for all summary
measures.
@param intervention an intervention to run on the data.
@param tau integer the time t at which we'd like to measure the effect
of the intervention
@param discrete boolean should the discrete superlearner (or the cts
superlearner) be used?
@return a vector of intervention effects for each iteration of
intervention.
perform_initial_estimation(data, intervention, tau)
This function can be used to generate an initial estimation, calculated
using the plain OSL. This method then returns a value given the provided
data, tau, and intervention. Essentially, this does the same as the
calculate_intervention_effect
function, but returns the mean of
all intervention bootstraps.
@param data.table the data to seed the sampling procedure.
@param intervention the intervention itself, see
InterventionParser
for more details
@param tau integer the time at which we want to evaluate the intervention
@return double the estimated mean over all bootstrap iterations
is_parallel()
Active method. Function to check whether the current object runs in
parallel or not.
@return boolean TRUE
if parallel.
get_bootstrap_iterations()
Active method. Returns the number of bootstrap iterations specified. @return integer the number of bootstrap iterations.
get_relevant_variables)
Active method. The relevant variables specified when intializing the
object.
@return list of RelevantVariable
objects.
get_outcome_variable()
Active method. Returns the outcome variable specified on initialization (string). @return string the string representation of the name of the outcome variable.