In this paper, we explore using generative agent-based models for a classical ABM application: testing how individual-level behavioral rules produce collective phenomena. We introduce RePair, a method that calibrates simulation worlds, operationalizes candidate mechanisms as natural-language rules, estimates their effects through matched interventions, and examines behavioral traces. We assess the method by testing it in four simulation worlds grounded in established social-science models and empirical studies. Our results reveal that (1) natural-language rules can produce measurable collective effects; (2) rule comparisons can converge as configurations accumulate; and (3) behavioral traces connect collective effects to agents' actions and interactions, helping researchers evaluate the proposed causal process. Together, these findings show the feasibility of using generative agent-based models to explore causal mechanisms and provide practical guidance for producing reliable, interpretable explanations.
Figures & tables
Figure 1: Overview of RePair’s four-step method , illustrated with residential segregation. Panels A–D correspond to Steps 1–4 in Section 3 . (A) Calibrate and fix a baseline world that executes correctly, supports the relevant actions and interactions, and leaves room for the outcome to change. (B) Operationalize candidate mechanisms as local rules, register their predicted effects, and prepare semantically equivalent wordings. (C) Compare each rule condition with a matched baseline and aggregate signed outcome differences across configurations to estimate effects, quantify uncertainty, and compare rules. (D) Examine behavioral traces to assess whether the observed actions and their temporal sequence support the proposed pathway to the collective outcome.
Figure 2: Calibrating the baseline world , illustrated with the residential segregation study in Section 5 . The figure shows the world without a candidate rule. Top: Structural settings fix the social situation and research question. Left: Step 1 calibrates the operation settings through baseline runs, varying one setting at a time. Grey values show alternatives, and bold values mark retained levels used in all further steps. Right: Agents express intentions, and the environment updates the world over twenty periods. In the further steps, the rule condition adds one candidate rule sentence to each agent’s profile . Both conditions use the same calibrated operation settings.
Figure 3: Step 1: calibrate and fix the baseline world. With structural settings fixed, researchers vary one operation setting at a time and select an alternative using verified baseline runs. No candidate rule is tested during calibration. A usable baseline supports the required actions and interactions and leaves the outcome room to change in both directions; it need not already exhibit the target collective pattern. Once all operation settings are fixed, the same criteria screen the candidate LLMs for subsequent steps.
Figure 4: Testing several expressions of the same rule. We begin with an anchor sentence and rewrite it while preserving who holds the attitude, what the attitude is, and what it concerns. After these checks, the rewrites form a wording pool from which each configuration selects one sentence to append to every agent’s profile. We then compare the resulting run with a baseline that uses the same model and background prompts but omits the rule sentence. Repeating this comparison assesses how the estimated effect varies across different expressions of the same rule.
Mechanism
Sample injected sentence
Amplifying: the mechanism’s own literature predicts more sorting
R1
Minority-status aversion [ 5 , 65 ]
“Your family would rather not live where most of the neighbors are not your own kind.”
R2
Own-group attraction [ 62 , 66 ]
“Your family would rather live where most of the neighbors are your own kind.”
R3
Out-group prejudice [ 67 ]
“Your family would rather not live beside families unlike yourselves.”
R4
Expectation of flight [ 63 , 24 ]
“Your family expects that neighbors like you will leave before long.”
Suppressive: a separate literature predicts less
Table 1: The eight registered candidate mechanisms. Each rule enters the simulation as one sentence appended to every household’s profile, and nothing else in the world changes between conditions.
Figure 5: How each rule changes relocation in the same simulated block. (a) Horizontal marks show each rule’s mean paired difference across the twelve configurations and vertical bars its 90% interval; solid intervals lie entirely in the registered direction. Effects are signed by the predicted direction, so a positive value means a wider gap for an amplifying rule and a narrower gap for a suppressive rule. Numbers above the intervals are control power (CP), which combines effect size and consistency. (b) The white-minus-Black departure-rate gap, computed from all departures up to each period and averaged across configurations. (c) Cumulative departures, averaged across configurations. Dashed lines show the baseline and shaded bands show one standard error around its mean. The trajectories describe how the block changes; the paired differences in (a) measure the added rule’s effect.
Departure rate, % per period
Effect on the gap
Rule
White
Black
Gap
ΔYr
CPr
baseline (no rule sentence)
5.8
3.4
+2.4
Amplifying
1
R1 minority-status aversion
11.2
5.2
+6.0
+3.6
+1.30
2
R3 out-group prejudice
12.7
5.9
+6.8
+4.3
+1.09
3
R2 own-group attraction
8.7
3.8
+4.9
+2.4
+0.72
Table 2: Rule effects on the departure-rate gap, ranked within each family by control power (Equation ( 3 )). The departure rate is a group’s departures over the decade divided by its household-periods, in percent, and the gap is the white rate minus the Black rate. ΔYr is the rule effect, the mean paired difference in the gap in points per period, signed by the registered direction. ↓ marks rules registered to narrow the gap. Effects are computed from unrounded rates.
Mechanism
Sample injected sentence
R1
Inequity aversion [ 73 ]
“You do not like ending a period with less than the others got.”
R2
Conditional cooperation [ 74 , 75 ]
“You put in about what you expect the others to put in.”
R3
Negative reciprocity [ 19 , 76 ]
“You are willing to spend to make a point, even when it costs you.”
R4
Money-maximizing ↓ [ 77 ]
“You take the option that leaves you the most credits.”
R5
Shadow of the future, removed ↓ [ 78 ]
“You will not meet these people again.”
Table 3: The registered rules for the public-goods world. Each rule enters as one sentence appended to every participant’s profile; the sentence shown is the registered anchor, and each rule has twenty-six wordings of it. Rules marked ↓ are registered as suppressive.
Rule
ΔYr
SE
CPr
Punish
Credits
Amplifying
1
R2 conditional cooperation
+12.0
1.3
+0.59
−3.6
+0.98
2
R1 inequity aversion
+0.4
1.7
+0.01
+4.6
+1.26
3
R3 negative reciprocity
−2.7
1.5
−0.11
+15.6
+1.45
Suppressive
1
R4 money-maximizing ↓
+78.6
1.7
+2.90
−4.9
−7.61
Table 4: The public-goods rules, N=268 configurations, ranked by control power (Equation ( 3 )). Every participant makes one contribution decision per period. In the baseline, 84.8% of them choose to contribute. ΔYr is the change from baseline in percentage points, signed by the predicted direction; positive values mean less contribution for suppressive rules. SE is the standard error of this effect. ↓ marks the rules registered as suppressive. Punish is the change in the number of punishment acts a run, against 6.7 in the baseline. Credits is the change in the average number of credits contributed.
Figure 6: How much the rule comparison changes with sample size. We repeatedly draw n configurations from the 268 available, with replacement and equal representation of the four admitted models. (a) Lines show mean control power and bands show its 90% interval across resamples. Narrower bands indicate more precise estimates. (b) Three curves show agreement with the full-sample analysis: selecting the same leading rule, preserving the order of the ten rule pairs that the full sample distinguishes, and reaching the same effect conclusion for all five rules. An effect conclusion records whether its signed interval lies entirely above zero, in the registered direction. The full sample is a reference for stability, not a known true ranking.
Figure 7: How sentence position and wording affect the measured rule effect. (a) Each rule’s effect at the registered end of the participant profile (filled) and with the same sentence moved to just after its opening (hollow), in percentage points. The hollow dot is the registered effect plus the mean position shift estimated on the 28 matched configurations, not a separate estimate. The pale bar is the 90% interval of the registered effect. Money-maximizing is not drawn: its effect is 78.6 points, and moving it changes the effect by only 0.2 points. A larger distance between the filled and hollow dots indicates greater sensitivity to sentence position. (b) Estimated uncertainty due to the number of wordings used to measure each rule’s effect (Section 3 ). It is estimated by drawing k of the twenty-six at random: the line is the mean over draws and the band the middle 80%. All five rules appear here. The dashed line is the target of a tenth of the baseline standard deviation; values below it meet the study’s wording-uncertainty target.
Mechanism
Sample injected sentence
Group polarization
R1
Value expression [ 20 ]
“You would rather say what you actually think than land somewhere in the middle.”
R2
Persuasive arguments [ 79 , 80 ]
“You find it easier to agree with an argument you have not heard before.”
R3
Conformity pressure ↓ [ 81 ]
“You would rather not be the one holding the group up.”
R4
Involvement [ 20 ]
“You care about this question.”
R5
Fact-or-opinion framing [ 20 ]
“This is a question of fact, not of opinion.”
Table 5: Candidate rules for the two additional worlds. Each row shows one of five registered wordings. The selected wording is added to every participant’s profile in the rule condition. Rules marked ↓ predict a decrease in the outcome; the other rules predict an increase.
Rule
ΔYr
CPr
Established
In the traces
Group polarization (signed shift, scale points; N=24 ; traces: speaking turns per run)
1
R3 conformity pressure ↓
+0.23
+0.39
yes
2.3
2
R2 persuasive arguments
+0.19
+0.30
no
2.3
3
R1 value expression
+0.09
+0.13
no
6.2
4
R5 fact-or-opinion framing
−0.03
−0.04
no
2.8
5
R4 involvement
−0.08
−0.15
no
3.8
Table 6: Rule effects in the two worlds, ranked within each world by control power. ΔYr is the rule effect in the metric’s own units, signed by the registered direction ( ↓ marks rules registered to lower the metric), and the next column reports whether the effect is established, that is, whether its signed 90% interval lies entirely above zero. The last column is read from the traces: in the polarization world, speaking turns per run, against 2.5 in the baseline; in the cascade world, the contribution in the first period, before any screen has been shown, against 5.7 in the baseline. Value expression is read on twenty-three configurations because one of its runs leaves no rating.
Figure 8: Which rules change collective outcomes across the four worlds? Each dot shows a rule’s mean change from its paired baseline. To place different outcomes on one scale, this change is divided by that world’s baseline standard deviation across configurations, s0 , giving Glass’s Δ . Positive values mean change in the registered direction, including a decrease for suppressive rules. Bars show 90% intervals: dark bars lie entirely in the registered direction, while light bars do not support an effect in that direction. Place attachment’s interval reaches zero. Rules are ordered by control power within each panel; the segregation rules are shown separately for amplifying and suppressive directions. The horizontal scale uses baseline-standardized effects, whereas the ordering uses control power, standardized by the variation in paired differences. These comparisons concern outcome shifts, not evidence that the proposed social process occurred.
Agent-based modeling simulates how interacting, heterogeneous entities and their environments produce patterns in social, economic, biological, and engineered systems.
College of Intelligence and Computing, Tianjin University, Tianjin, China · Tianjin Key Laboratory of Healthy Habitat and Smart Technology, Tianjin, China · Laboratory of Computation and Analytics of Complex Management Systems, Tianjin University, Tianjin, China