Dr. James H. Watson was Sherlock's friend, flatmate, and assistant. He often contributed to Sherlock's work, usually by accompanying him in the field and providing advice that could guide Sherlock towards a solution to the case. Within sherlock's causal segmentation framework, watson_segment mirrors Dr. Watson's role by assigning a treatment rule after Sherlock has completed a preliminary consultation via sherlock_calculate. The output is a slightly augmented version of the data structure produced by sherlock_calculate; however, this step is necessary. After Dr. Watson has helped Sherlock in finalizing the segmentation analysis, the segmentation quality may be evaluated via mycroft_assess.

watson_segment(data_with_consult, segment_fun, ..., type = c("inferential",



A data.table containing the output sherlock_calculate, which matches the input data, augmented with cross-validated nuisance parameter estimates and an estimate of the CATE. A summary of the estimates across segmentation strata is made available as an attribute of the data.table.


A particular choice of function for the assignment of a treatment rule to a segment based on a specified threshold or constraint. For details on these, consult the documentation in cost_funs.


Additional arguments passed to segment_fun. For details, see the documentation for the cost functions in cost_funs.


A character string (of length one) specifying how the treatment decision based on the CATE is to be made. There are two options:

  • "inferential" (the default) uses a hypothesis test to evaluate whether the estimated CATE is statistically different from a threshold and assigns a treatment decision based on the resultant p-value.

  • "analytic" simply evaluates whether the estimated CATE exceeds a given threshold and assigns treatment to segments for which this holds. Note that in both cases the threshold must be either provided directly (as an input to cost_threshold) or will be discovered based on specified constraints (as in cost_budget).