It's the exact analogue of how serious student athletes throw away their whole undergrad education for a shot at a pro career, usually to end up injured and useless a couple years later.
For the athlete, it's literally all or nothing.
From the perspective of understanding the universe, that is nothing. Decent consolation prize though.
Nobody (who is any good) in the USA pays money for a STEM PhD. You get paid to do these degrees, albeit not a lot but a lot better than paying yourself!
I went to graduate school early 2000s. 6 years, average stipend < $15k and still had to pay student fees. Then a couple post docs for 5 more years at $40k.
There was significant opportunity cost, but now I've had 3 jobs that were all reasonably well paid that I only got because of the fanciness of my degree. I'm _not_ saying that's the right sorting for hiring managers to do, but it is what happened to me.
Net-net, I don't know if I'm even, behind, or ahead financially. I do know that graduate school was one of the best experiences of my life, my deepest friendships were formed in those years, and I miss pursuing my passion at that level constantly. So, I guess I'm in the position of not really caring if it lost me money.
I tend to treat opportunity cost like inflation adjustment: in most cases, failing to include it is an error, so I do it by default.
This isn't quite a complaint: adopting math and physics PhDs (first as a mentor and now as a TLM) that are seemingly unproductive has been a consistent secret weapon of mine: they're often written off as unproductive, but it's not difficult to turn someone that smart into a solid engineer with a few months of guidance, as long as they're willing to learn. In specific domains, a subset of their actual skills are a good fit (they tend to be great at math), but it just signifies an unfortunate and fairly significant misallocation of resources.