Skip to content

stn 05 · quantil, client engagement

Causal Inference for Drilling Operations

Estimated the causal effect of drilling practices and mud parameters on well performance across 17 wells, then separated what a driller controls from what the geology decides.

Causal inferenceDouble MLPanel dataeconmlstatsmodelsPython
contextQuantil, client engagement
scale17 wells · ≈159,000 observations
cat.noBOG–005

sec 01 · brief

The problem

Directional wells in the Colombian eastern foothills are expensive to drill, and more expensive when the string gets stuck. The formations are heterogeneous and the trajectories are complex. Time lost to tight spots, stuck pipe and slow trips adds directly to the cost of the well.

The operator had years of operational records. Every foot drilled was logged with the mechanical parameters, the mud properties and the activities performed at that depth. What the operator did not have was a measure of which of those things caused a good or a bad outcome. Correlations could not provide it, because drilling parameters are adjusted together: a variable that looks like a lever in a scatter plot is often a proxy for the formation being drilled.

So the question was causal. Of the things a driller can change during a well (bit choice, mud density, flow, viscosity, how often to ream, back-ream or circulate), which ones change well performance, by how much, and under which geological conditions?

sec 02 · approach

What I built

We answered the question with two families of models that estimate the same effects in different ways, and we trusted an effect only when both families found it.

The first family is linear: OLS with within-well demeaning and standard errors clustered by well. Demeaning subtracts each well's own mean from every observation, which is equivalent to well fixed effects. It discards all variation between wells and estimates only what happens inside a well. That removes every confound that is constant for a well, such as location, original design and base geology.

The second family is non-parametric: Causal Forest with Double Machine Learning. DML first removes from the outcome and from the treatment whatever the covariates can predict, then fits a causal forest on the residuals. The effect can then vary from one observation to the next, where the linear models assume one constant effect.

We ran both because they fail in different ways. The linear models are stable but assume a functional form. The forest is flexible but needs a large sample. An effect found by both can be handed to an operations team. An effect found by one may come from that model's assumptions.

sec 03 · method

Method

  1. 01

    Preprocessing and feature engineering

    This stage builds the matrix every later model reads. The per-foot operational records arrived already enriched with geological, directional and bottom-hole-assembly variables. We cleaned missing values and dummified the categoricals. Drilling mechanics are known to be non-linear, so we gave the linear models terms that can represent it: 20 lag-1 columns, a quadratic term on bit position and six mechanical interactions (torque×RPM, hookload², torque², RPM², torque×hookload, RPM×hookload). Everything was scaled with StandardScaler. The result is an analytical matrix of 139 treatment variables.

  2. 02

    Global OLS with within-well demeaning

    This stage measures the effect of each practice on the two outcomes the brief names, across all ≈159,000 observations. Model A takes trip speed: the average speed of the first run in hole, per foot, where a higher value means the string met less resistance. It is the practical proxy for hole quality. Model B takes tight spots: the count of sticking events per foot. Both models are demeaned by well and use well-clustered standard errors, so each coefficient reads as an effect inside a well.

  3. 03

    Segmented OLS by geological and operational context

    This stage answers the last part of the question: under which conditions each effect holds. We fit the same demeaned specification separately for each subgroup under three segmentation schemes: by formation top (20 groups, 367–22,320 rows), by geological structure (14 groups, 497–36,772 rows) and by hole-diameter range (4 groups). The grouped runs use 18 continuous treatments. They drop the dummified bits, which do not vary enough inside a subgroup to be identified.

  4. 04

    Causal Forest with Double Machine Learning

    This stage re-estimates the practices with the second family, so the effect of a practice can differ from one observation to the next. We fit CausalForestDML on a hole-quality index, with four mud treatments (density, flow, plastic viscosity, yield point) and operational activity counts, controlling for 27 covariates. The nuisance stages use LassoCV, because the operational parameters are structurally collinear: they are adjusted together at the rig, and a nuisance model without regularization does not converge cleanly. We fit two outcome specifications, levels and first differences, to test which one carries signal.

  5. 05

    Heterogeneity and variable importance

    This stage identifies which conditions make a practice's effect larger or smaller. We computed causal-forest feature importance and SHAP values over the estimated conditional treatment effects. The same stage produced the diagnostics the conclusions depend on: correlation matrices that justify the regularization, forest plots with 95% confidence intervals, and volcano plots that pair effect magnitude against significance.

sec 04 · legend

Instruments

legend · methods

Causal inferenceDouble machine learningFixed-effects panel regressionCausal forestsSHAP attribution

legend · language and data

PythonpandasNumPyStandardScaler

legend · modelling

statsmodelseconmlCausalForestDMLscikit-learnLassoCV

legend · interpretation and figures

SHAPmatplotlibseaborn

sec 05 · readings

Results

Model A · trip speed

R² 0.357 · RMSE 0.676

≈159,000 obs · 17 wells

Model B · tight spots

R² 0.161 · RMSE 0.872

≈159,000 obs · 17 wells

Best segmentation

median R² 0.45 · MAPE 2.5

by structure · 14 groups

Nuisance Y-score

0.63 → ≈0

levels → first differences

Back-reaming R-score

0.033 global · 0.12 peak

peak within a single structure

Feature space

139 OLS treatments · 27 DML covariates

incl. 20 lags and 6 mechanical interactions

plate 01

One outcome is modelable; the other is geology

Model A · trip speed

0.357

Model B · tight spots

0.161
0.000.250.500.751.00

Coefficient of determination for the two global models, on the 0–1 scale of a variance share. It shows which of the two outcomes practice can explain. Trip speed explains more than twice what tight spots do, and segmentation later raises trip speed to a median 0.45 without a comparable gain for tight spots.

source

Global OLS, ≈159,000 observations across 17 wells. RMSE is in the metric grid and off this axis, because two units on one scale would be a dual-scale plot.

plate 02

Segmenting by structure fit best and behaved best

By structure

14 groups

0.45

By formation top

20 groups · no IQR stated

0.33

By hole diameter

4 groups

0.30
0.00.20.40.60.8
interquartile rangemedianoutlier reach

Median R² across the subgroups of each segmentation scheme: 14 structures, 20 formation tops and 4 diameter ranges. It shows which definition of geological context the effects should be read under. Structure has the highest median and the narrowest spread. Formation top reaches higher in its best group than any other row and is the least reliable, because its groups run from 367 to 22,320 rows.

source

Segmented OLS. The box is an interquartile range and is drawn only where the source states one. The formation-top row reports a median and an outlier reach, so it shows those two and no box.

plate 03

Differencing the outcome removed the signal

Outcome in levels

0.63

First differences

≈0
0.000.250.500.751.00

Out-of-sample nuisance score for the outcome model, under the two outcome specifications. It shows which specification the causal forest can work from. We tested first differences expecting them to remove trend confounding. They removed the predictable structure the forest needs before it can find heterogeneity in the residuals. Every downstream R-score went flat, and we dropped the differenced specifications as the analytical base.

source

Causal Forest DML nuisance stage. Treatment-side scores stayed low and unchanged across both specifications. The sources give them as a range (≈0.05–0.10) with no point value, so they are named here and not plotted.

plate 04

Only one practice showed an effect that can be targeted

Back-reaming

0.033

Circulating + rotating

0.008

Reaming

0.005
0.000.010.020.030.04

R-score by treatment: how much of the variation in a treatment's effect the covariates can explain. It shows which practice has an effect that depends on conditions a driller can read. Back-reaming is the only one, and it keeps that position under every segmentation scheme, with a peak near 0.12 inside a single structure.

source

Causal Forest DML, outcome in levels. All three fall to approximately zero under first differences, which is the drop plate 03 shows.

plate 05

What modulates the effect

  1. 01Standpipe pressure
  2. 02Weight on bit
  3. 03Distance to casing
  4. 04Rate of penetration
  5. 05Bit position

The covariates that most determine how large a practice's causal effect is, in rank order. They are the geological and mechanical conditions the question asks about. Feature importance and SHAP agree on this set. All five are measured live at the rig, which makes a real-time advisory tool feasible.

source

Causal-forest feature importance and SHAP over estimated conditional treatment effects. This is a ranked list because the sources give the order and never the magnitudes, so bars would be invented.

sec 07 · findings

What the data said

finding · result

Bit selection is the largest lever a driller controls

Of everything a driller can change, bit choice changes trip speed the most. Around 50 variables reach significance for trip speed, and bit models are the largest effects in both directions: BIT-03, BIT-07 and BIT-10 go with the fastest first trips, and BIT-09, BIT-04, BIT-08 and BIT-01 with the slowest. For tight spots, one bit is significant.

finding · result

Trip speed is an engineering problem; tight spots are a geology problem

Practice explains trip speed far better than it explains tight spots. Model A explains more than twice the variance of Model B, and segmentation raises A to a median 0.45 without a comparable gain for B. Model B returns six significant variables, and five of them are formations. In practice, trip speed can be optimized and tight spots can be anticipated.

finding · result

Two predictors hold across specifications

Bit position and distance to casing answer the "under which conditions" part of the question. Both reach significance in more than half of all subgroups under at least two of the three grouping schemes. Hookload's effect on trip speed is always positive, but its size goes from ≈0 in FM-C to ≈1.8 in FM-F. An effect that changes this much between formations has to be modelled by subgroup.

finding · result

Finer segmentation gives less stable estimates

Segmenting by structure gave both the best median fit and the narrowest spread. Formation-top segmentation produced groups from 367 to 22,320 rows, and in the smallest groups the coefficients grew to −15 and −12 with confidence intervals of similar width. A minimum subgroup size should therefore be an inclusion criterion set before the models are fit.

finding · negative result

Differencing the outcome removed the signal

First differences of the outcome took the nuisance Y-score from 0.63 to approximately zero and flattened every R-score. We dropped the differenced specifications and re-planned the work around the levels specification.

finding · negative result

Lagged features added no usable estimate

We added twenty lag-1 columns to capture recent operational dynamics, and none supported a recommendation. Bit-position lag-1 produced the largest point estimate in the entire model (β ≈ −12.5), with p = 0.41 and a confidence interval about 22 units wide. The lags stayed in to keep the specification consistent.

finding · negative result

Low-frequency treatments could not be estimated

Wiper trips appear in a small fraction of observations, and the estimator failed on them. Under diameter segmentation it returned average treatment effects around 100,000 and R-scores near −60. We excluded every conclusion about wiper trips and washing from the recommendations.

sec 08 · forward

Recommendations

  1. 01

    Real-time parameter advisory. The conditions that change an effect are all measured live, so the estimated effects can drive a tool that suggests mechanical adjustments from the well's current geological context.

  2. 02

    Predictive models per structure. Structure segmentation fit best. With one production model per structure, trip speed could be forecast for a new well before it spuds.

  3. 03

    A controlled trial of back-reaming. Every estimate here is observational. Back-reaming has the most detectable heterogeneity, which makes it the first candidate for a controlled test.

  4. 04

    More data on the low-frequency practices. Wiper trips and washing failed for lack of sample support. Targeted collection would bring them into scope.

  5. 05

    Bayesian hierarchical models for the unbalanced segments. Partial pooling would stabilize the small formation groups by shrinking them toward the global effect, so they would not have to be discarded.

  6. 06

    Effects expressed as money. Trip-speed gains and tight-spot reductions should be converted to non-productive time avoided. Recommendations could then be ranked by expected value, where today they are ranked by statistical significance.

  7. 07

    New temporal features. Lag-1 failed. Longer windows, rolling aggregates and stationarity testing are the next things to try.

  8. 08

    Transfer to other fields. Whether these effects hold beyond the fields in scope has not been tested.

sec 09 · notes

Notes

disclosure

Field, formation and bit-model names on this page are pseudonyms. Well counts, observation counts and every model metric are the real figures from the engagement.

limits

  • The estimates are observational. No confounders were explicitly identified in this phase. The 27 covariates are observed controls, and no causal theory assigns them that role. The results should be read as effects conditional on the controls, and they are not settled causal quantities.
  • R-scores are low in absolute terms even for the best treatment. The covariates explain only a limited share of the variation in the effect.
  • Conclusions about wiper trips and washing were excluded for insufficient sample support.
  • A third method, an Arellano-Bond Lasso dynamic panel, exists in the results document as an undeveloped section and produced no results in this phase. It is not claimed here.