People seem to be getting stuck on the PhD opportunity cost piece for STEM. The matter of fact is that Americans don't do PhDs in STEM: if you look at the top schools and top departments, they are 70-90% international students. The PhD then is a phenomenal deal: by and large people are coming from places where FAANG jobs don't just fall on your lap at SF salaries. You get a free education in the US, and can jump straight into the job market as top-educated talent.
Also I think from NSF stats STEM PhDs are on a slow and upward trend, unlike the countries mentioned in the article.