stn 01 · 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 the levers a driller controls from the geology they cannot.
sec 01 · brief
The problem
Directional wells in the Colombian eastern foothills are expensive to drill and expensive to get stuck in. The formations are heterogeneous, the trajectories are complex, and non-productive time from tight spots, stuck pipe and slow trips lands directly on the cost of the well.
The operator had years of operational records — every foot drilled, logged with the mechanical parameters, the mud properties and the activities performed at that depth — and no quantitative account of which of those things actually caused good or bad outcomes. Correlations were plentiful and useless: drilling parameters get adjusted together, so anything that looks like a lever in a raw scatter is probably a proxy for the formation being drilled.
The question was causal, not predictive. Of the things a driller can change mid-well — bit choice, mud density, flow, viscosity, how often to ream or back-ream or circulate — which ones measurably move well performance, by how much, and under which geological conditions?
sec 02 · approach
What I built
A two-family modelling system, deliberately redundant. The first family is linear: OLS with within-well demeaning — subtract each well's own mean from every observation — plus standard errors clustered by well. Demeaning is equivalent to well fixed effects, so it discards all between-well variation and estimates only what happens inside a well. That removes, in one step, every confound that is constant for a well: location, original design, base geology.
The second family is non-parametric: Causal Forest with Double Machine Learning. DML orthogonalizes the outcome and the treatment against the covariates first, then fits a causal forest on the residuals, letting the effect vary observation by observation instead of assuming one constant treatment effect.
Running both was the point. They fail differently — the linear models are stable but assume a functional form, the forest is flexible but hungry for sample. A finding that survives both is worth handing to an operations team. A finding that appears in only one is a finding about the model.
sec 03 · method
Method
01
Preprocessing and feature engineering
Load the per-foot operational records, already enriched with geological, directional and bottom-hole-assembly variables. Clean missing values, dummify the categoricals. Engineer 20 lag-1 columns, a quadratic term on bit position and six mechanical interactions — torque×RPM, hookload², torque², RPM², torque×hookload, RPM×hookload — to give a linear model a chance at the known non-linearities in drilling mechanics. Scale with StandardScaler. Output: an analytical matrix of 139 treatment variables.
02
Global OLS with within-well demeaning
Two models over ≈159,000 observations. Model A takes average first run-in-hole trip speed per foot — higher means less resistance to running the string, the practical proxy for hole quality. Model B takes tight-spot count per foot, the frequency of sticking events. Both demeaned by well with well-clustered standard errors, so the coefficients read as within-well effects.
03
Segmented OLS by geological and operational context
The same demeaned specification fit independently per 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 and drop the dummified bits, which do not vary enough inside a subgroup to identify.
04
Causal Forest with Double Machine Learning
CausalForestDML on a hole-quality index, with four mud treatments — density, flow, plastic viscosity, yield point — and operational activity counts, controlling for 27 covariates. LassoCV in the nuisance stages, chosen because the operational parameters are structurally collinear: they get adjusted together at the rig, so an unregularized nuisance model does not converge cleanly. Fit in two outcome specifications, levels and first differences, to test which carries signal.
05
Heterogeneity and variable importance
Causal-forest feature importance plus SHAP values over the estimated conditional treatment effects, to identify which conditions amplify or suppress each practice's effect. Plus the diagnostic layer the conclusions rest on: correlation matrices justifying the regularization, forest plots with 95% confidence intervals, and volcano plots pairing effect magnitude against significance.
sec 04 · legend
Instruments
legend · methods
legend · language and data
legend · modelling
legend · interpretation and figures
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
Model B — tight spots
Coefficient of determination for the two global models, on the natural 0–1 scale for a variance share. Trip speed explains more than twice what tight spots do, and segmentation later lifts trip speed to a median 0.45 while doing nothing comparable for tight spots.
source
Global OLS, ≈159,000 observations across 17 wells. RMSE is in the metric grid rather than on this axis — different units on one scale would be a dual-scale plot.
plate 02
Segmenting by structure fit best and behaved best
By structure
14 groups
By formation top
20 groups · no IQR stated
By hole diameter
4 groups
Median R² across the subgroups of each segmentation scheme — 14 structures, 20 formation tops and 4 diameter ranges. Structure wins on both counts, highest median and tightest spread. Formation top reaches higher in its best group than anything else on the chart and is the least trustworthy, 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 and nothing else, so that is all it shows.
plate 03
Differencing the outcome destroyed the signal
Outcome in levels
First differences
Out-of-sample nuisance score for the outcome model. First-differencing was tested on the theory that it would strip out trend confounding; instead it removed the predictable structure the causal forest needs before it can find heterogeneity in the residuals. Every downstream R-score went flat, and the differenced specifications were dropped 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) rather than a point, so they are named here instead of plotted.
plate 04
Only one practice showed effect worth targeting
Back-reaming
Circulating + rotating
Reaming
R-score by treatment — how much of the variation in the treatment effect itself the covariates can explain. Back-reaming is the only practice with heterogeneity worth acting on, and it holds that position under every segmentation scheme, peaking near 0.12 inside a single structure.
source
Causal Forest DML, outcome in levels. All three fall to approximately zero under first differences — plate 03 is that collapse.
plate 05
What modulates the effect
- 01Standpipe pressure
- 02Weight on bit
- 03Distance to casing
- 04Rate of penetration
- 05Bit position
The covariates that most determine how large a practice's causal effect is, in rank order. Feature importance and SHAP agree on this set. All five are available live at the rig, which is what makes a real-time advisory tool feasible at all.
source
Causal-forest feature importance and SHAP over estimated conditional treatment effects. Rendered as a ranked list and not a bar chart on purpose: the sources give the ordering and never the magnitudes, so bars would be invented.
sec 07 · findings
What the data said
finding · result
Trip speed is an engineering problem; tight spots are a geology problem
Model A explains more than twice the variance of Model B, and segmentation lifts A to a median 0.45 while doing nothing comparable for B. Model B returns six significant variables and five of them are formations. The two indicators do not deserve the same treatment: one is worth optimizing, the other is worth anticipating.
finding · negative result
Differencing the outcome destroyed the signal
First-differencing collapsed the nuisance Y-score from 0.63 to approximately zero and flattened every R-score. The differenced specifications were dropped rather than reported alongside, and the effort re-planned around the levels specification.
finding · result
Bit selection is the dominant controllable lever
Around 50 variables reach significance for trip speed and bit models dominate both tails — BIT-03, BIT-07 and BIT-10 track with the fastest first trips, BIT-09, BIT-04, BIT-08 and BIT-01 with the slowest. For tight spots exactly one bit is significant, which is the same finding from the other direction.
finding · negative result
Lagged features earned nothing
Twenty lag-1 columns went in expecting to capture recent operational dynamics. 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 for specification consistency and supported no recommendation.
finding · negative result
Low-frequency treatments produce pathological estimates
Wiper trips appear in a small fraction of observations. Under diameter segmentation the estimator returned average treatment effects around 100,000 and R-scores near −60 — not a weak result, a broken one. Conclusions about wiper trips and washing were excluded from the recommendation set rather than reported with caveats.
finding · result
Fine segmentation buys resolution and pays in stability
Formation-top segmentation produced groups from 367 to 22,320 rows, and in the smallest ones coefficients inflated to −15 and −12 with confidence intervals to match. Structure gave both the best median fit and the tightest spread. Together those are the argument for a minimum subgroup size as an inclusion criterion rather than a judgement call after the fact.
finding · result
Two predictors survive every specification
Bit position and distance to casing 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 consistently positive but swings from ≈0 in FM-C to ≈1.8 in FM-F — which is itself the argument for modelling by subgroup rather than globally.
sec 08 · forward
Recommendations
01
Real-time parameter advisory. The modulators the model identified are all available live, so the estimated effects can drive a tool that suggests mechanical adjustments from the well's current geological context.
02
Predictive models per structure. Structure segmentation fit best, so consolidating production models per structure would let trip speed be forecast for a new well before it spuds.
03
Validate causally, with a controlled trial. Every estimate here is observational. Back-reaming has the most detectable heterogeneity and is the obvious candidate for a controlled test.
04
Instrument the low-frequency practices. Wiper trips and washing broke the estimator through sample support alone; targeted collection would bring them into scope.
05
Bayesian hierarchical models for the unbalanced segments. Partial pooling would stabilize the small formation groups by shrinking them toward the global effect instead of discarding them.
06
Translate the effects into money. Expressing trip-speed gains and tight-spot reductions as non-productive time avoided would let recommendations be ranked by expected value rather than by statistical significance.
07
Rework the temporal features. Lag-1 failed; longer windows, rolling aggregates and stationarity testing are the next thing to try.
08
Test transfer to other fields. Whether these effects generalize beyond the fields in scope is an open empirical question.
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 without a causal theory assigning them that role, so the results read as effects conditional on the controls rather than as settled causal quantities.
- R-scores are low in absolute terms even for the best treatment, meaning the covariates explain only a limited share of the variation in the effect itself.
- 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.