Skip to content

Commit ece0de2

Browse files
committed
tidying
Signed-off-by: Nathaniel <[email protected]>
1 parent 792c3c6 commit ece0de2

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

examples/case_studies/bayesian_sem_workflow.ipynb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,7 +5209,7 @@
52095209
"id": "5ff64f19",
52105210
"metadata": {},
52115211
"source": [
5212-
"Note how we have not passed through any data into this model. This is deliberate. We want now to simulate data from the model with forward pass through the system. We have initialised two versions of the model: (1) with wide parameters and (2) with tight parameters on the data generating condition. We are going to sample from the tight parameters model to draw out indicator data that conforms with the parameter setting we do now. "
5212+
"Notice that we haven’t yet provided any observed data to the model — this is intentional. Our next step is to simulate data by performing a forward pass through the system. We initialize two versions of the model: (1) with tight priors and (2) with wide priors on the data-generating parameters. We’ll sample from the tightly parameterized model to generate indicator data consistent with our chosen parameter settings."
52135213
]
52145214
},
52155215
{
@@ -5896,11 +5896,15 @@
58965896
"id": "41e491be",
58975897
"metadata": {},
58985898
"source": [
5899-
"The posterior estimates can “recover” the true values within uncertainty, ensuring the model is faithful to the data generating process. Were the effort at parameter recover to fail, we would equally have learned something about our model. Parameter recovery exercises helps discover issues of mis-specification or unidentified parameters. Put another way, they tell us how informative our data is with respect to our data generating model. Verlyn Klinkenborg starts his justly famous book _Several short sentences about writing_ with the following advice: \n",
5899+
"The posterior estimates can “recover” the true values within uncertainty, ensuring the model is faithful to the data generating process. Were the effort at parameter recover to fail, we would equally have learned something about our model. Parameter recovery exercises helps discover issues of mis-specification or unidentified parameters. They tell us how informative our data is with respect to our data generating process, they clarify the degree to which the data constrains (or fails to constrain) the model’s parameters.\n",
5900+
"\n",
5901+
"Verlyn Klinkenborg begins his justly famous book _Several short sentences about writing_ with a reminder that applies equally to modelling: \n",
59005902
"\n",
59015903
"> \"Here, in short, is what i want to tell you. Know what each sentence says, What it doesn't say, And what it implies. Of these, the hardest is know what each sentence actually says\" - V. Klinkenborg\n",
59025904
"\n",
5903-
"This advice transfers exactly to the art of statistical modelling. To know what our model says, we need to say it aloud. We need to feel how it lands with an audience. We need to understand is implications and limitations. The Bayesian workflow explores the depths of meaning achieved by our statistical approximations. It traces out the effects of interlocking components and the layered interactions of structural regressions. In each articulation we're testing which flavours of reality resonate in the telling. What shape the posterior? How plausible the range of values? How faithful are our predictions to reality? On these questions we weigh each model just as the writer weighs each sentence for their effects. "
5905+
"This advice transfers exactly to the art of statistical modelling. To know what our model says, we need to say it aloud. We need to feel how it lands with an audience. We need to understand is implications and limitations. Simulation studies and parameter recovery exercises, speak our models aloud; their failures, like their successes are transparent and each iteration strengthens the quality of the work.\n",
5906+
"\n",
5907+
"The Bayesian workflow explores the depths of meaning achieved by our statistical approximations. It traces out the effects of interlocking components and the layered interactions of structural regressions. In each articulation we're testing which aspects resonate in the telling. What shape the posterior? How plausible the range of values? How faithful are our predictions to reality? On these questions we weigh each model just as the writer weighs each sentence for their effects. "
59045908
]
59055909
},
59065910
{
@@ -5952,7 +5956,7 @@
59525956
"id": "59c4d17a",
59535957
"metadata": {},
59545958
"source": [
5955-
"In an applied setting it's these kinds of implications that are crucially important to surface and understand. From a workflow point of view we want to ensure that our modelling drives clarity on these precise points and avoids adding noise generally. If we're assessing a particular hypothesis or aiming to estimate a concrete quantity, the model specification should be robust enough to support those inferences. This is where parameter recovery exercises can lend assurances and bolster confidence in the findings of empirical work. Here we've shown that our model specification will support inferences about about a class of particular causal contrasts i.e. how treatment changes the direct effects of one latent construct on another.\n",
5959+
"In applied work, these are precisely the implications we want to surface and understand. From a workflow perspective, our models should clarify these relationships rather than add noise. If we're assessing a particular hypothesis or aiming to estimate a concrete quantity, the model specification should be robust enough to support those inferences. This is where parameter recovery exercises can lend assurances and bolster confidence in the findings of empirical work. Here we've shown that our model specification will support inferences about about a class of particular causal contrasts i.e. how treatment changes the direct effects of one latent construct on another.\n",
59565960
"\n",
59575961
"Another way we might interrogate the implications of a model is to see how well it can predict \"downstream\" outcomes of the implied model. How does job-satisfaction relate to attrition risk and approaches to work?"
59585962
]
@@ -7038,9 +7042,9 @@
70387042
"source": [
70397043
"## Conclusion: Workflow and Craft in Statistical Modelling\n",
70407044
"\n",
7041-
"We have now seen how to articulate Structural Equation models and their variants in PyMC. The SEM workflow is, at heart, Bayesian in temperament. Hypothesise and construct. Construct then Estimate. Estimate and check. Check then refine. Refine then expand... Both disciplines reject the checklist mentality of “fit once, report, move on.” Instead, they cultivate a focused, deliberate practice. Each discipline forces an apprenticeship where skill is developed. Skill to handle how assumptions shape understanding and how the world resists impositions of false structure. Skill to find the right structures. Each iteration is a dialogue between theory and evidence. At each juncture we ask whether this model speaks true? Whether this structure reflects the facts to hand. \n",
7045+
"We have now seen how to articulate Structural Equation models and their variants in PyMC. The SEM workflow is, at heart, Bayesian in temperament. Hypothesise and construct. Construct then Estimate. Estimate and check. Check then refine. Refine then expand... Both disciplines reject the checklist mentality of “fit once, report, move on.” Instead, they cultivate a focused, deliberate practice. Each demands an apprenticeship in which skill is honed: skill to see how assumptions shape understanding, and how the world resists the imposition of false structures. Skill to find the right structures. Each iteration is a dialogue between theory and evidence. At each juncture we ask whether this model speaks true? Whether this structure reflects the facts to hand. \n",
70427046
"\n",
7043-
"In the end, the value of craft in statistical modeling lies not in improving benchmark metrics, but in the depth of understanding we cultivate through careful communication and justification. The Bayesian workflow reminds us that modeling is not the automation of insight but its deliberate construction. Our workflow is a process of listening, revising, and re-articulating until the model speaks clearly. Like any craft, its worth is measured not by throughput but by fidelity: how honestly our structure reflects the world it seeks to describe. Each diagnostic, each posterior check, each refinement of a latent path is a form of attention — a small act of resistance against the flattening logic of target metrics and checklists. These are the constructive thought processes that drive job-satisfaction. __To practice modeling as craft is to reclaim pride in knowing what our models say, what they do not say, and what they imply.__ To find, in that discipline and skilled attention, the satisfaction of meaningful work and useful science.\n"
7047+
"In the end, the value of craft in statistical modeling lies not in improving benchmark metrics, but in the depth of understanding we cultivate through careful communication and justification. The Bayesian workflow reminds us that modeling is not the automation of insight, but its deliberate construction. Our workflow is a process of listening, revising, and re-articulating until the model speaks clearly. Like any craft, its worth is measured not by throughput but by fidelity: how honestly our structure reflects the world it seeks to describe. Each diagnostic, each posterior check, each refinement of a latent path is a form of attention — a small act of resistance against the flattening logic of target metrics and checklists. These constructive habits and reflective practices are the source of fulfillment in the work. __To practice modeling as craft is to reclaim pride in knowing what our models say, what they do not say, and what they imply__ - and to find, in that discipline and skilled attention, the satisfaction of meaningful work and useful science.\n"
70447048
]
70457049
},
70467050
{

examples/case_studies/bayesian_sem_workflow.myst.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ sem_model_hierarchical_wide = make_hierarchical(priors_wide, grp_idx)
11921192
pm.model_to_graphviz(sem_model_hierarchical_tight)
11931193
```
11941194

1195-
Note how we have not passed through any data into this model. This is deliberate. We want now to simulate data from the model with forward pass through the system. We have initialised two versions of the model: (1) with wide parameters and (2) with tight parameters on the data generating condition. We are going to sample from the tight parameters model to draw out indicator data that conforms with the parameter setting we do now.
1195+
Notice that we haven’t yet provided any observed data to the model — this is intentional. Our next step is to simulate data by performing a forward pass through the system. We initialize two versions of the model: (1) with tight priors and (2) with wide priors on the data-generating parameters. We’ll sample from the tightly parameterized model to generate indicator data consistent with our chosen parameter settings.
11961196

11971197
```{code-cell} ipython3
11981198
# Generating data from model by fixing parameters
@@ -1255,11 +1255,15 @@ az.plot_posterior(
12551255
);
12561256
```
12571257

1258-
The posterior estimates can “recover” the true values within uncertainty, ensuring the model is faithful to the data generating process. Were the effort at parameter recover to fail, we would equally have learned something about our model. Parameter recovery exercises helps discover issues of mis-specification or unidentified parameters. Put another way, they tell us how informative our data is with respect to our data generating model. Verlyn Klinkenborg starts his justly famous book _Several short sentences about writing_ with the following advice:
1258+
The posterior estimates can “recover” the true values within uncertainty, ensuring the model is faithful to the data generating process. Were the effort at parameter recover to fail, we would equally have learned something about our model. Parameter recovery exercises helps discover issues of mis-specification or unidentified parameters. They tell us how informative our data is with respect to our data generating process, they clarify the degree to which the data constrains (or fails to constrain) the model’s parameters.
1259+
1260+
Verlyn Klinkenborg begins his justly famous book _Several short sentences about writing_ with a reminder that applies equally to modelling:
12591261

12601262
> "Here, in short, is what i want to tell you. Know what each sentence says, What it doesn't say, And what it implies. Of these, the hardest is know what each sentence actually says" - V. Klinkenborg
12611263
1262-
This advice transfers exactly to the art of statistical modelling. To know what our model says, we need to say it aloud. We need to feel how it lands with an audience. We need to understand is implications and limitations. The Bayesian workflow explores the depths of meaning achieved by our statistical approximations. It traces out the effects of interlocking components and the layered interactions of structural regressions. In each articulation we're testing which flavours of reality resonate in the telling. What shape the posterior? How plausible the range of values? How faithful are our predictions to reality? On these questions we weigh each model just as the writer weighs each sentence for their effects.
1264+
This advice transfers exactly to the art of statistical modelling. To know what our model says, we need to say it aloud. We need to feel how it lands with an audience. We need to understand is implications and limitations. Simulation studies and parameter recovery exercises, speak our models aloud; their failures, like their successes are transparent and each iteration strengthens the quality of the work.
1265+
1266+
The Bayesian workflow explores the depths of meaning achieved by our statistical approximations. It traces out the effects of interlocking components and the layered interactions of structural regressions. In each articulation we're testing which aspects resonate in the telling. What shape the posterior? How plausible the range of values? How faithful are our predictions to reality? On these questions we weigh each model just as the writer weighs each sentence for their effects.
12631267

12641268
+++
12651269

@@ -1279,7 +1283,7 @@ plt.suptitle(
12791283
);
12801284
```
12811285

1282-
In an applied setting it's these kinds of implications that are crucially important to surface and understand. From a workflow point of view we want to ensure that our modelling drives clarity on these precise points and avoids adding noise generally. If we're assessing a particular hypothesis or aiming to estimate a concrete quantity, the model specification should be robust enough to support those inferences. This is where parameter recovery exercises can lend assurances and bolster confidence in the findings of empirical work. Here we've shown that our model specification will support inferences about about a class of particular causal contrasts i.e. how treatment changes the direct effects of one latent construct on another.
1286+
In applied work, these are precisely the implications we want to surface and understand. From a workflow perspective, our models should clarify these relationships rather than add noise. If we're assessing a particular hypothesis or aiming to estimate a concrete quantity, the model specification should be robust enough to support those inferences. This is where parameter recovery exercises can lend assurances and bolster confidence in the findings of empirical work. Here we've shown that our model specification will support inferences about about a class of particular causal contrasts i.e. how treatment changes the direct effects of one latent construct on another.
12831287

12841288
Another way we might interrogate the implications of a model is to see how well it can predict "downstream" outcomes of the implied model. How does job-satisfaction relate to attrition risk and approaches to work?
12851289

@@ -1552,9 +1556,9 @@ This two-step of information compression and prediction serves to concisely quan
15521556

15531557
## Conclusion: Workflow and Craft in Statistical Modelling
15541558

1555-
We have now seen how to articulate Structural Equation models and their variants in PyMC. The SEM workflow is, at heart, Bayesian in temperament. Hypothesise and construct. Construct then Estimate. Estimate and check. Check then refine. Refine then expand... Both disciplines reject the checklist mentality of “fit once, report, move on.” Instead, they cultivate a focused, deliberate practice. Each discipline forces an apprenticeship where skill is developed. Skill to handle how assumptions shape understanding and how the world resists impositions of false structure. Skill to find the right structures. Each iteration is a dialogue between theory and evidence. At each juncture we ask whether this model speaks true? Whether this structure reflects the facts to hand.
1559+
We have now seen how to articulate Structural Equation models and their variants in PyMC. The SEM workflow is, at heart, Bayesian in temperament. Hypothesise and construct. Construct then Estimate. Estimate and check. Check then refine. Refine then expand... Both disciplines reject the checklist mentality of “fit once, report, move on.” Instead, they cultivate a focused, deliberate practice. Each demands an apprenticeship in which skill is honed: skill to see how assumptions shape understanding, and how the world resists the imposition of false structures. Skill to find the right structures. Each iteration is a dialogue between theory and evidence. At each juncture we ask whether this model speaks true? Whether this structure reflects the facts to hand.
15561560

1557-
In the end, the value of craft in statistical modeling lies not in improving benchmark metrics, but in the depth of understanding we cultivate through careful communication and justification. The Bayesian workflow reminds us that modeling is not the automation of insight but its deliberate construction. Our workflow is a process of listening, revising, and re-articulating until the model speaks clearly. Like any craft, its worth is measured not by throughput but by fidelity: how honestly our structure reflects the world it seeks to describe. Each diagnostic, each posterior check, each refinement of a latent path is a form of attention — a small act of resistance against the flattening logic of target metrics and checklists. These are the constructive thought processes that drive job-satisfaction. __To practice modeling as craft is to reclaim pride in knowing what our models say, what they do not say, and what they imply.__ To find, in that discipline and skilled attention, the satisfaction of meaningful work and useful science.
1561+
In the end, the value of craft in statistical modeling lies not in improving benchmark metrics, but in the depth of understanding we cultivate through careful communication and justification. The Bayesian workflow reminds us that modeling is not the automation of insight, but its deliberate construction. Our workflow is a process of listening, revising, and re-articulating until the model speaks clearly. Like any craft, its worth is measured not by throughput but by fidelity: how honestly our structure reflects the world it seeks to describe. Each diagnostic, each posterior check, each refinement of a latent path is a form of attention — a small act of resistance against the flattening logic of target metrics and checklists. These constructive habits and reflective practices are the source of fulfillment in the work. __To practice modeling as craft is to reclaim pride in knowing what our models say, what they do not say, and what they imply__ - and to find, in that discipline and skilled attention, the satisfaction of meaningful work and useful science.
15581562

15591563
+++
15601564

0 commit comments

Comments
 (0)