Product Research Pricing About Careers Blog Private beta Talk to us Get the private beta →
Research Study design · 10 December 2024 · 22 min read

Designing a twelve-month cohort study of agentic coding: power, confounding and attrition by simulation

Next month we start following working engineers for a year to measure what agentic tools do to their understanding of the code they ship. Before recruiting anyone, we simulated the study a few thousand times. The sample size was the easy part. The hard parts are that engineers choose when to use an agent, and that a company-randomised intervention would have lied to us one time in ten.

ReportAWL-2024-03
Versionv1.0
AreaStudy design

Published 10 December 2024 · accompanies the pre-registration of the twelve-month cohort study

A fan of power curves rising toward an 80% line Cover generated from this paper’s simulation
Abstract

We report the simulation-based design analysis behind a pre-registered twelve-month cohort study. Engineers are nested in companies; each month one diff they merged is assessed for comprehension by two raters on a five-point rubric, and the primary contrast is AI-authored against self-authored diffs within engineer, estimated with engineer fixed effects and company-clustered standard errors. With 14 companies and rater reliability 0.8, 200 engineers give 85% power for a contrast of 0.15 rubric points and 47% for 0.10. Company-level variation in the effect matters more than company count above about ten. If engineers reach for an agent on harder diffs, a true contrast of −0.10 is estimated as −0.27; adjusting for a complexity proxy correlated 0.7 with true complexity recovers only half the bias, so we will sample assessed diffs in complexity-matched pairs. Dropout concentrated among the most affected engineers biases the contrast by 10% at 25% attrition. For a secondary agent-free-day intervention, randomising 30% of engineers within each company holds a 3.5% false-positive rate and gives 86% power for a 15% effect on unassisted throughput; randomising whole companies gives a 10% false-positive rate and 40% power.

200engineers in 14 companies: 85% power for a 0.15-point comprehension contrast
−0.27estimate of a true −0.10 contrast when agent use tracks diff complexity
10% vs 3.5%false positives: company-randomised against engineer-randomised intervention

Two years after ChatGPT, the evidence on productivity is accumulating quickly and the evidence on capability barely at all. Controlled tasks show engineers finishing faster with assistance; field experiments this year show throughput gains across thousands of developers; a randomised study in a school setting found that unrestricted access to a model improved practice performance and harmed later unassisted performance. Nobody has followed working engineers long enough to see what happens to their understanding of the code they own.

That is the study we begin in January: working engineers, followed for twelve months, with monthly comprehension assessments on diffs they personally merged, and a nested intervention. This paper is not a result. It is the design analysis we did first, by simulating the study under the threats we could anticipate, and it is published before recruitment so that the choices it justifies cannot later be adjusted to fit the data.

What this paper is

A simulation study of a planned design. No participant has been recruited and no data exists. The effect sizes below are assumptions chosen to bracket what would matter, not predictions.

The planned study

Population
Working engineers shipping to production, recruited through their employers
Window
Twelve months from January 2025
Exposure
Whether each assessed diff was substantially agent-authored, from tool telemetry and self-report
Outcome
Comprehension of a merged diff 30 days after merge: explain, trace, predict, modify; two independent raters on a 1 to 5 rubric
Primary contrast
AI-authored against self-authored diffs, within engineer
Secondary
An agent-free day each week for twelve weeks, randomised, on unassisted throughput
Instruments
The item bank and scoring approach of AWL-2023-01; review-state telemetry from AWL-2024-01 as an exploratory covariate

The primary analysis model is a linear model with engineer fixed effects. For engineer i in company c, assessed in month t on a diff with agent indicator Ait:

Yit = αi + β Ait + γ′wit + εit,   SE(β̂) clustered by company, tG−1 reference(1)

where αi absorbs everything stable about the engineer (seniority, ability, team) and wit holds diff-level covariates. Clustering by company, with a t distribution on G − 1 degrees of freedom, guards against company-level correlation in the effect, which with a dozen or so companies is the dominant inferential risk.

The simulated study

Each simulated engineer has a stable comprehension level (SD 0.6 rubric points) and a personal agent-usage share drawn from a Beta(2.2, 2.0) distribution that rises slowly over the year. Each month a diff is drawn with a complexity xit ~ N(0, 1) that lowers comprehension by 0.35 points per SD. The engineer’s effect βi varies around the cohort mean by 0.10 (0.15 in the attrition analysis), plus a company-level deviation where stated. Diff-to-diff noise has SD 0.75, and the two-rater average adds rater error set by the single-rater reliability:

σrater = σdiff √((1 − ρ)/ρ),   observed = latent + e/√2,   e ~ N(0, σrater2)(2)

Each design point was simulated 200 to 400 times. Unless stated, the design is 200 engineers in 14 companies, single-rater reliability 0.8, and 10% dropout at random.

Result 1: how many engineers

Figure 0%25%50%75%100%60100150200300Contrast 0.05Contrast 0.10Contrast 0.15
Power of the within-engineer contrast by number of engineers, for three true contrasts in rubric points. 14 companies, reliability 0.8, 10% dropout.

A contrast of 0.15 rubric points, about a quarter of the between-engineer standard deviation and the smallest difference we would regard as practically important, is detected with 85% power at 200 engineers and 98% at 300. A contrast of 0.10 needs about 300 engineers for 73%; at 200 the study has a coin-toss chance of detecting it. A contrast of 0.05 is beyond any cohort we can recruit. We will recruit 200 and say in advance that a null result rules out effects of 0.15 or more, not effects in general.

Single-rater reliabilityPower, contrast 0.10, 200 engineers
0.646%
0.750%
0.854%
0.958%
Raising reliability from 0.6 to 0.9 is worth about as much power as 50 extra engineers. 400 simulations per row; Monte Carlo standard error about 2.5 points. The 0.8 row is the same design point as the 200-engineer, 0.10 point in the chart above (47%); the two independent estimates differ by more than their noise suggests, so we treat its power as about 50%.

Rater reliability helps less than we expected, because the two-rater average already halves rater variance and diff-to-diff variation dominates. We will still train raters to a target of 0.8, but we will not spend recruitment budget on a third rater.

Result 2: how many companies

Figure 02040608043.5%38.5%23.5%6 companies51%48.5%38%1054%47.5%40.5%1451%53%44.5%20τ = 0τ = 0.05τ = 0.10
Power for a 0.10 contrast with 200 engineers, by number of companies and the standard deviation of the effect across companies (τ). 200 simulations per bar.

Engineer fixed effects absorb company differences in comprehension level, so company count barely matters when the effect is the same everywhere: power is 44% with six companies and 51 to 54% with ten or more. What matters is whether the effect itself varies by company, as it plausibly will with different tools, review cultures and codebases. With τ = 0.10, six companies give 24% power and 14 give 41%, because the clustered standard error now carries the between-company variation and the t reference has few degrees of freedom. We set a minimum of 14 companies, no company contributing more than 15% of engineers.

Result 3: engineers choose when to use the agent

The within-engineer design removes stable differences between people. It does not remove differences between diffs. If engineers reach for an agent more often on harder changes, and harder changes are harder to explain a month later, the contrast attributes difficulty to the agent. We simulated selection on complexity, adding λ·xit to the logit of agent use.

Figure -0.5-0.4-0.3-0.2-0.10Truth-0.1No selection, unadjusted-0.1Moderate selection, unadjusted-0.27Moderate selection, adjusted-0.19Strong selection, unadjusted-0.39Strong selection, adjusted-0.26
Estimated contrast against the truth (−0.10) under selection on diff complexity, unadjusted and adjusted for a complexity proxy correlated 0.7 with true complexity. 200 simulations each.

With moderate selection (λ = 0.5) the estimate is −0.27, nearly three times the truth; with strong selection (λ = 1), −0.39. Adjusting for a complexity proxy as good as we think we can build from diff size, files touched and cyclomatic change (correlation 0.7 with true complexity) brings those to −0.19 and −0.26: about half the bias remains, as measurement-error theory predicts for an imperfect control. Covariate adjustment alone is not an adequate defence.

We therefore change the sampling, not just the model. Each month, instead of assessing one randomly chosen merged diff, we will assess a matched pair: one agent-authored and one self-authored diff from the same engineer, matched on the complexity proxy within a caliper. The comparison is then made within pairs of similar difficulty, and the proxy is used for matching and adjustment both. Where an engineer has no self-authored diff of comparable complexity that month, the month is recorded as unmatched and excluded from the primary analysis, which costs power and is reported.

Design decision

The single most consequential choice in this study is which diffs get assessed. Choosing them at random would have produced an estimate nearly three times too large under plausible selection, with a confidence interval that looked excellent.

Result 4: who leaves

Over a year some engineers will change jobs or stop responding. If dropout is unrelated to the effect, the fixed-effects estimate is unbiased for the cohort. If the engineers most harmed by agent use are more likely to leave, perhaps because they struggle, the completers understate the effect.

DropoutMechanismEstimateCohort mean effectBias
10%Random−0.103−0.101−0.002
10%Concentrated among most affected−0.097−0.101+0.003
25%Random−0.098−0.100+0.001
25%Concentrated among most affected−0.091−0.101+0.010
Informative dropout multiplies the monthly hazard by exp(−0.8z), where z is the engineer’s standardised individual effect. 200 simulations per row.

The bias is small at plausible dropout, and a tenth of the effect at 25% informative dropout. Because each engineer contributes observations until they leave, the fixed-effects model uses partial histories rather than discarding them, which is most of the protection. We will record the reason for every departure and pre-register a sensitivity analysis that re-weights completers by the inverse of their estimated probability of remaining.

Result 5: randomise engineers, not companies

The secondary question is whether one agent-free day per week for twelve weeks raises unassisted throughput. Randomising whole companies is operationally easier, since one manager agrees, and it avoids contamination between colleagues. We compared it with randomising 30% of engineers within each company, analysing both by regression of post-period log throughput on treatment and pre-period throughput, with company-clustered standard errors. The simulation includes a company-specific shock in the intervention months (a release crunch, a reorganisation) that a company-level design cannot separate from treatment.

Figure 02550751003.5%10%False positive53.5%24.5%Effect 10%86%40%Effect 15%97%63.5%Effect 20%Engineers randomised within companyCompanies randomised
False-positive rate (true effect zero) and power for 10%, 15% and 20% effects on unassisted throughput, by design. 200 engineers, 14 companies, 30% treated. 200 simulations per bar.

Company randomisation treats four companies. Its clustered standard error, with four treated clusters, is too small, and the test rejects a true null 10% of the time at a nominal 5%; this is the few-treated-clusters problem documented by MacKinnon and Webb. Even with that inflation it has 40% power for a 15% effect. Randomising engineers within companies holds 3.5% false positives and has 86% power, because each company’s shock hits treated and control engineers alike. We accept the contamination risk, measure it by asking control engineers about their own agent use each week, and randomise within company.

What we are registering

Method

Engineers
Comprehension level N(0, 0.6²); usage share Beta(2.2, 2.0), rising over the year
Diffs
Complexity N(0, 1), effect −0.35 per SD; diff noise SD 0.75; two-rater average
Effects
Individual effect SD 0.10 (0.15 for attrition); company effect SD τ where stated
Estimator
Engineer-demeaned least squares, CR1 company-clustered SE, t on G − 1 df
Intervention
Log unassisted throughput, six pre and three post months; ANCOVA; company shock SD 0.08; effect heterogeneity SD 0.05 across companies
Replicates
400 per design point for power and reliability; 200 for the others

Limitations

A design simulation is only as good as the threats it imagines. We assumed the effect is constant over the year, while the interesting possibility is that it grows; a study powered for a constant effect is somewhat over-powered for a growing one and blind to its shape unless the analysis models time. We assumed the agent indicator is measured without error, while in practice agent-authored is a matter of degree. We modelled selection on one complexity dimension; engineers may also choose agents for unfamiliar code, which is a different confounder our matching does not address. And the rubric itself has not yet been validated outside our own raters.

Simulation only. No participant data exists. The simulation script, its seed and the results file are under Artefacts, and the registration will cite this report.

The productivity evidence the study builds on is Peng and colleagues [1] and the field experiments of Cui and colleagues [2]; Bastani and colleagues [3] found the pattern we are looking for, better assisted performance and worse unassisted learning, in a school setting. Simulation-based power analysis follows Arnold and colleagues [4] and Green and MacLeod [5]. Fixed-effects estimation and its limits are standard [6]; clustered inference follows Cameron and Miller [7], and the few-treated-clusters problem that rules out company randomisation is MacKinnon and Webb [8]. Cluster-randomised design is Hayes and Moulton [9]. Missing-data mechanisms are Little and Rubin [10]; rater reliability, Shrout and Fleiss [11]; the case for registering all of this before data exist, Nosek and colleagues [12]. Our instruments are AWL-2023-01 [13] and AWL-2024-01 [14].

Artefacts

Everything below is published or available on request. A number nobody can reproduce is an advertisement, not a result.

Codeawl_2024_03_cohort_power.pyCohort generator, within estimator, power, confounding, attrition, intervention designs · Python, MIT
Dataawl_2024_03.jsonResults file, every number quoted in this paper

References

  1. Peng, S., Kalliamvakou, E., Cihon, P., & Demirer, M. (2023). The Impact of AI on Developer Productivity: Evidence from GitHub Copilot. arXiv:2302.06590.
  2. Cui, Z., Demirer, M., Jaffe, S., Musolff, L., Peng, S., & Salz, T. (2024). The Effects of Generative AI on High Skilled Work: Evidence from Three Field Experiments with Software Developers. SSRN Working Paper.
  3. Bastani, H., Bastani, O., Sungu, A., Ge, H., Kabakcı, Ö., & Mariman, R. (2024). Generative AI Can Harm Learning. SSRN Working Paper.
  4. Arnold, B. F., Hogan, D. R., Colford, J. M., & Hubbard, A. E. (2011). Simulation Methods to Estimate Design Power: An Overview for Applied Research. BMC Medical Research Methodology, 11, 94.
  5. Green, P., & MacLeod, C. J. (2016). SIMR: An R Package for Power Analysis of Generalized Linear Mixed Models by Simulation. Methods in Ecology and Evolution, 7(4).
  6. Wooldridge, J. M. (2010). Econometric Analysis of Cross Section and Panel Data (2nd ed.). MIT Press.
  7. Cameron, A. C., & Miller, D. L. (2015). A Practitioner’s Guide to Cluster-Robust Inference. Journal of Human Resources, 50(2).
  8. MacKinnon, J. G., & Webb, M. D. (2018). The Wild Bootstrap for Few (Treated) Clusters. The Econometrics Journal, 21(2).
  9. Hayes, R. J., & Moulton, L. H. (2017). Cluster Randomised Trials (2nd ed.). CRC Press.
  10. Little, R. J. A., & Rubin, D. B. (2019). Statistical Analysis with Missing Data (3rd ed.). Wiley.
  11. Shrout, P. E., & Fleiss, J. L. (1979). Intraclass Correlations: Uses in Assessing Rater Reliability. Psychological Bulletin, 86(2).
  12. Nosek, B. A., Ebersole, C. R., DeHaven, A. C., & Mellor, D. T. (2018). The Preregistration Revolution. Proceedings of the National Academy of Sciences, 115(11).
  13. Bhardwaj, M. (2023). An item bank for code comprehension: calibration, adaptive testing and fairness checks with item response theory. AI Work Lab Research, AWL-2023-01.
  14. Bhardwaj, M. (2024). Reading the review state: a hidden Markov model of how engineers accept AI suggestions. AI Work Lab Research, AWL-2024-01.
Cite this work

Bhardwaj, M. (2024). Designing a twelve-month cohort study of agentic coding: power, confounding and attrition by simulation. AI Work Lab Research, AWL-2024-03.

Mohit Bhardwaj

Head of Research · aiworklab

Mohit led AI Work Lab’s research programme from January 2023 to March 2025: the comprehension item bank, the statistics of code-model leaderboards, review-state telemetry, variance in agent evaluations, and the design of the twelve-month cohort study that the Measurement team went on to run.