plant lover, cookie monster, shoe fiend
20978 stories
·
20 followers

The challenge of truly probabilistic programming

1 Share

Many years ago, Jouni and I wrote an unpublished paper called Fully Bayesian Computing:

A fully Bayesian computing environment calls for the possibility of defining vector and array objects that may contain both random and deterministic quantities, and syntax rules that allow treating these objects much like any variables or numeric arrays. Working within the statistical package R, we introduce a new object-oriented framework based on a new random variable data type that is implicitly represented by simulations.

A few years later we published an updated version of the paper under the title, Manipulating and summarizing posterior simulations using random variable objects. Here’s the background:

In the Bayesian paradigm, unknown quantities have probability distributions and are thus random variables. Observed values are just realizations of random variables, and constants may be thought of as random variables with point mass distributions. In mathematical notation, we deal with objects that are random variables, but in practice these objects are approximated by vectors of numbers, that is, simulations. Consequently, when programming for manipulating simulations of unknown quantities, we must write code to manipulate arrays of numeric constants.

And here’s the challenge:

Arrays of simulations are cumbersome objects to work with. Functions that work with vectors will not in general work with matrices, so special versions of the functions need to be written to accommodate matrices of simulations as arguments. For example, a scalar-valued random variable becomes a vector of simulations, and a random vector becomes a matrix of simulations. . . . The usual approach now is to use loops and vector-matrix computations to manipulate the matrix of posterior simulations. This approach is general but awkward and far from transparent . . .

As part of this effort, Jouni wrote a package in R called “rv” that allows direct manipulation of random variable objects, so for example if alpha and beta are random variables, each a vector of length J, and gamma is a scalar, then you can compute something like delta = (alpha + gamma)/beta, which would be a vector of length J. Internally, alpha, beta, and delta would be stored as S x K arrays, and gamma would be stored as an array of length S, where S is the number of simulation draws in your simulation frame, but the user would be able to work with these without having to keep track of that indexing; it would all be implicit.

The rv package was just a demonstration, but then more recently Paul Bürkner, Jonah Gabry, Matthew Kay, and Aki Vehtari implemented the idea in the “posterior” package in R. They call it rvar: The Random Variable Datatype. I still haven’t integrated rvar() into my Bayesian workflow, but I’d like to do it.

The point I want to make here is that this random variable datatype moves us closer to what I’d call “truly probabilistic programming.”

Here’s what I mean by that.

Stan (and Bugs, PyMC, etc.) are called “probabilistic programming languages,” characterized by Wikipedia as “based on the declarative specification of probabilistic models, for which inference is performed automatically.” Fair enough. In Stan, the variables defined in the parameters block, transformed parameters block, model block, and generated parameters block represent random variables with a joint density that is specified by the Stan program.

But, although this is called a probabilistic program as the term is used, it doesn’t fully feel like probabilistic programming in the sense of allowing me to grab random variables and work with them directly. I can do all that within the Stan program in the generated quantities block, but at a certain remove. Stan and other probabilistic programming languages are set up to run in batch mode: you specify a model and then the inference engine runs and spits out posterior simulations (or some other distributional summary).

To me, a truly probabilistic programming environment would allow me to interactively work with random variables, and to work with them as random variables, not as arrays of simulation draws. I want to be able to multiply two matrices without having to loop through the simulations. Part of this is about clean code, but more generally it’s about workflow. Any mathematical or graphical operations we can do on numbers, we should be able to do with random variables, with the simulations all hiding under the hood. Kind of by analogy to how we can do floating-point math on the computer without (usually) having to worry about how all these digits are being stored.

This will require tools such as rvar() and also some experience with the workflow. The payoff is . . . you could call it “better postprocessing of Bayesian simulations,” but I think that would understate the potential benefits of being able to work directl with uncertainty without that extra array dimension getting in your face at every step.

Read the whole story
sarcozona
1 minute ago
reply
Epiphyte City
Share this story
Delete

Banking Needs To Be A Human Right

1 Share

This scourge continues to spread:

Poland just voted to EXPAND the government’s power to freeze your assets without a court ruling. Say the “wrong” thing online, and you could wake up to a FROZEN bank account. The bill lets the Interior Minister sanction anyone accused of supporting foreign interference or information manipulation aimed at Poland. Bank accounts, property, even crypto can be frozen instantly by administrative decision, and appealing to a court won’t automatically lift the freeze. It passed 240 to 202 last week.

In Britain and Germany multiple people have had their bank accounts frozen for supporting Palestine. When government isn’t directly involved banks often do the dirty work themselves, for example German banks debanking AfD politicians. The same happened to Farage in the UK. In Canada we had the government freezing accounts of the protestors against vaccines who parked their trucks in Ottawa. (I didn’t support the truckers, but at the time I said the accounts shouldn’t be frozen.)

As the economy moves more and more to electronic payments, being without a bank becomes more and more a sentence to homelessness. And even the small cash window is often closed In Germany, when the government de-banks you they also make it illegal to give the de-banked person any money so they can eat or pay rent.

This method of control makes organizing against the government almost impossible. It’s done to individuals and organizations. It needs to end. At the very least it cannot be something that is done by executive fiat but which requires a judge and jury and a trial. If the issue is avoiding someone transferring stolen money, then the amount that is frozen needs to be limited: enough must be left to pay bills, eat and so on and there has to be a mandatory maximum period the money can be frozen for.

Every individual should have a guaranteed bank account. The simplest way to do this is that when someone comes of age and gets whatever number the government uses to track citizens (like the social security number) then an account is opened by the central tax authority or a postal bank. A card is issued and the account is capable of all the normal things a bank account does. If you want retail outlets (not a bad idea) go back to postal banking. This account can never be taken away from someone, ever, even if they go to prison.

This needs to be a constitutional right, because increasingly you simply can’t survive without a bank account and governments cannot be trusted not to use petty powers to destroy their enemies of the day.

We’re about 2 weeks into our annual fundraiser. We’ve raised about $9,530 out of a $14,500 goal from 77 people. This blog is free for everyone to read, and we’ve got about ten thousand visitors a month. Of those about 6K are regulars.

The simplest truth of capitalism is that you get more of what you pay for. Money sends the message and resources required to do things. In most cases your power is tiny, one of millions, but this isn’t like that because the numbers and the need (to keep the blog and Ian running) are relatively small.

So if you value this blog, if it’s worth having around to you, please consider Subscribing or Donating.

Read the whole story
sarcozona
2 minutes ago
reply
Epiphyte City
Share this story
Delete

The babies missing from England’s heart surgery audit

1 Share

The surgical audit that helped make children’s heart surgery safer

Between 1984 and 1995, more babies died after heart surgery at the Bristol Royal Infirmary than should have, but it took far too long to realise because no systematic, comparable national data on outcomes was being collected. This isn’t just me saying it - the public inquiry which ran from 1998 to 2001 said so directly. One response was to start a new, mandatory, national database of every cardiac operation and interventional catheter performed on a child in the UK: the National Congenital Heart Disease Audit, which has underpinned quality assurance since the early 2000s.

It worked. Alongside surgical and intensive care advances, being able to see outcomes nationally and within hospitals as part of ongoing improvement programmes, has helped drive mortality down. Thirty day mortality after children’s heart surgery in the UK fell from 4.3% in 2000 to 2.6% in 2010, even though the complexity of operations rose. In the national audit’s 2025 report, the 30-day mortality for 2024/25 was just 1.3%. Painstaking national audit of this kind is something the NHS does very well.

But the audit misses a really important group of babies

But every audit has blind spots, and it’s important to understand them because otherwise we risk only focusing what we are measuring and forget about what we cannot see. A baby or child only enters the audit because a procedure happened. Babies diagnosed with a heart defect before or after birth who never had a procedure are not in there, and we have not been tracking what happens to them.

In April 2015, fifteen years after the national database of procedures began, Public Health England launched the National Congenital Anomaly and Rare Disease Registration Service (NCARDRS). NCARDRS registers congenital anomalies wherever in the pregnancy or the first years of life they are picked up: in babies born alive, in stillbirths, in miscarriages, and in terminations at any gestation. It covers more than a thousand different conditions, including congenital heart defects, and has the widest coverage of any congenital anomaly register in the world. It reached full national coverage in 2018.

We saw an opportunity to combine the two datasets to understand for the first time what happens to foetuses and babies diagnosed with congenital heart disease. We linked the two datasets together as well as death registrations from the Office for National Statistics, and followed every detected case of structural congenital heart disease in England with an estimated delivery date in 2018 to 2020, from diagnosis to the first birthday, 11,265 foetuses and babies. Our second peer-reviewed paper has just been published, and I think the findings are both surprising and important. The first paper followed all feotuses and babies. The second looked in detail at the 9,033 babies born alive.

What happens after antenatal diagnosis

64% of cases were detected antenatally, with over 90% detected antenatally for the most complex defects. Detection was lowest (<30%) for defects that are hard to see on a four chamber scan or that develop later in pregnancy.

Of the 11,265 cases, 1,766 (16%) ended in termination and 295 (2.6%) in miscarriage or stillbirth. Termination was associated with severity, from 51% of foetuses with the most severe defect undergoing termination to 6% for the least severe. Termination was twice as likely where there was at least one other health problem alongside the heart condition.

Families in the least deprived fifth of neighbourhoods were nearly twice as likely to end the pregnancy as those in the most deprived fifth: 20% vs 12%. Foetal loss had the opposite association: 3.6% in the most deprived fifth vs 1.7% in the least.

This means that babies born alive are more likely to be born to mothers living in deprived communities.

Subscribe now

What happens to babies born alive with congenital heart disease

Of 9,033 babies born alive with a structural heart defect, 4,546 (50%) had at least one cardiac intervention before their first birthday. Among the 4,028 babies with a defect classed as severe, 77% had a cardiac intervention before their first birthday.

The other half had no procedure in that first year. Some babies are too well to need one yet. Isolated ventricular septal defect (a hole between the two main chambers of the heart) is the largest group in the non-intervened group: 2,016 babies with no intervention in the first year of life. Many of these holes close on their own or don’t need to be closed straight away, allowing babies to grow stronger before having surgery.

On the other hand, some babies are too sick or too complex to have surgery in their first year, or are on a palliative care pathway chosen with their families. Of 105 babies with the three most severe defects who had no intervention in their first year of life, 95 sadly died before their first birthday.

The deaths we are just not tracking

What our research really showed was the importance of looking at the whole picture – because looking just at babies who received an intervention (especially if looking only at deaths within a month of surgery), simply misses too much information. Overall, 837 of the 9,033 babies born alive died before their first birthday (9%). Of those deaths, 599 (72%) were in babies with no cardiac intervention, and so would not have been picked up in the national audit based on interventions. Infant mortality was 13% in the non-intervened group against 5% among babies who were operated on.

We tested whether impaired access to care was a possible explanation for the difference between deaths with and without an intervention in the first year of life. If it might be, we would expect to see that babies who died without an operation would have been less likely to have an antenatal diagnosis and more likely to be born in a more deprived area compared to those who died after an operation. We saw neither association.

Medical complexity does seem to be a likely explanation for the difference. Comparing deaths in babies without an operation to deaths after one, 60% vs 49% had an additional non cardiac congenital condition, and 50% vs 29% were premature (a big risk factor). This pattern holds across the spectrum of severity for defects.

Deprivation was also important. Babies born in the poorest fifth of neighbourhoods were about 60% more likely to die before their first birthday than babies in the richest fifth, once differences in the defect itself, other conditions, prematurity, sex and whether it was found before birth were accounted for. This was true whether the baby had a procedure or not. The data do not allow us to understand why, but they do suggest that this should be an area of future research focus.

The surgical audit was started to monitor surgical outcomes and to try to ensure that any concerns about quality of surgical care can be picked up quickly. But that means only looking at deaths within a short time of surgery and missing babies that died later after surgery (which could be for a number of reasons) or those not operated on at all. I believe that these latter deaths are important to track for two reasons: firstly providing families with better information about what might happen on first diagnosis, and secondly, so that the NHS can learn to improve outcomes for these babies. This could be by improving decisions around which babies receive an operation, by improving support for children and families who do not receive an intervention, or by improving support once babies go home after surgery, particularly for those living in more deprived communities.

So what next

Routinely report on the non intervention pathway. These babies and their families are receiving care, including palliative care, and to our knowledge their outcomes are not being systematically reviewed anywhere.

Understand more about why babies had no operation. Futility, parental choice, and a defect that simply did not need fixing yet are categorically different things that show up the same way in the data – to separate them and, importantly, understand them, we need new prospective research studies working with clinicians and families.

Understand what’s behind more deaths in deprived areas. We see significant differences between most and least deprived areas for termination rates, foetal loss, and in infant death with and without surgery. Understanding why is crucial if we want to improve outcomes for babies born in more deprived areas.

Keep (and expand) the surgical audit. Counting what happens to operated babies was, and is, a good thing and has helped drive improvements in survival for these babies. As mortality rates have come down, we should add other outcomes to the audit (such as complications after surgery, which has already started), to support services to keep improving.

I don’t often write about my academic research on Substack, but I thought this work was a really good example of how clinical audits can support improved care but also how important it is to try to understand the whole picture – and how different perspectives on the same data can really provide new insights.

Thanks for reading Making sense... of evidence, data, and the stories they tell! Subscribe for free to receive new posts and support my work.

Read the whole story
sarcozona
6 minutes ago
reply
Epiphyte City
Share this story
Delete

UK ministers have no plans to publish explosive report on climate crisis

1 Share

Andy Burnham’s newly appointed climate adviser used report to warn of national security risk from collapsing ecosystems

The UK government still has no plans to publish an explosive report showing the national security risk from the collapse of ecosystems around the world – even after handing the key official behind the report a new advisory role.

Andy Burnham addressed the Cop31 climate summit in Turkey on Thursday and said the UK was determined to reach net zero by 2050 and work with its partners to build a clean energy future.

Continue reading...

Read the whole story
sarcozona
10 minutes ago
reply
Epiphyte City
Share this story
Delete

Doctors in Ukraine Try Treating Infections Like Biological Warfare Attacks - The New York Times

1 Share

The injuries to soldiers arriving at Ukrainian hospitals are horrific. Instead of bullet wounds, blast injuries from drones dominate the scene: Calf muscles are blown away, chunks of tissue are missing from thighs. Soil and debris thrown up from the blast are lodged deep in lacerations.

By the time they arrive at a hospital, which can take days, weeks or even months of travel under cover of darkness, 30 to 40 percent of soldiers are not just injured but have severe infections. And their infections often involve microbes that are untreatable — resistant to antibiotics. When the injured soldiers are admitted to civilian hospitals, they risk spreading the bacteria to other patients.

Now there is an effort to counter this scourge.

It started with a realization by Hailie Uren, a clinical pharmacologist and disaster medicine specialist who works in Ukraine. The situation, she reasoned, resembled nothing so much as a biological warfare attack. “If we don’t have antibiotics to treat these patients,” she said, “how different is that from when a patient is exposed to anthrax?”

Hospitals already have plans in place to treat victims of biological warfare, she noted. All the hospitals had to do was carry out those same urgent protocols on the battlefield. Ms. Uren proposed the idea directly to Ukraine’s surgeon general, and received support from the defense and health ministries.

The effort began in September, in a large tent outside a hospital in central Ukraine.

The objective, which Ms. Uren had developed with colleagues, would be to disinfect injured soldiers before they entered a hospital; remove their dirty clothes and bandages, wash them with an antiseptic and give them a shower.

Ms. Uren in a hospital tent during a medical training exercise at a military base in Poland in June.Credit...Maciek Nabrdalik for The New York Times

Thank you for your patience while we verify access. If you are in Reader mode please exit and log into your Times account, or subscribe for all of The Times.

Thank you for your patience while we verify access.

Already a subscriber? Log in.

Want all of The Times? Subscribe.

Read the whole story
sarcozona
21 minutes ago
reply
Epiphyte City
Share this story
Delete

Do you have a will? You should have a will!

1 Share

Patrick Rhone writes, in If You’re a G@d D%&m Adult, You Should Have A F*^K*&#g Will, about why we should all have an up to date will:

Look, it’s simple. If you are over the age of 18, you should have a will and all of the other important legal documents (medical directives, power of attorney, etc).

You should for sure have one if you have any assets over a thousand dollars. You absolutely should have one if you have kids.

I remain gobsmacked at the number of people who don’t.

I’m actually somewhat angry at those in their  60’s, 70’s, 80’s (i.e. My parents — too many other Boomers. It always seems to be the Boomers) who don’t.

Look, I understand. You think you always have tomorrow. You think you’ll put it on the list and get around to it. You think you’re in good health so why bother. You think it’s too complicated. You have a million other excuses…

And they’re all bullshit.

He’s right.

Catherine and I first had wills drafted after Olivia was born, and we kept them updated over the years as our circumstances changed.

As a result, when Catherine died in 2000, one of the things I didn’t need to sort out—and there were a lot of things to sort out—was that. Catherine’s wishes were clear. Our lawyer understood them. I understood them. It was a small relief when small reliefs had an outsized impact. 

Patrick goes on to relate some stories that, if you don’t have a will, I hope will spur you to action.

Since Catherine died, I’ve updated my will again. My lawyer is clear that it can be—should be—a living document, not a “set it and forget it.” But even a “set it and forget it” will is something.

 (While you’re at it, if you have people who depend on you for money and/or labour, you should have life insurance too. Realizing that I didn’t have to pay back a burgeoning line of credit when Catherine died, because we had it life insured, was another outsized relief.)

Read the whole story
sarcozona
10 hours ago
reply
Epiphyte City
Share this story
Delete
Next Page of Stories