Thanks. It's not an easy calculation whether to build afresh and disband - or upgrade. Building costs shields and upgrading costs gold. What's the exchange rate?
I don't use hard numbers to make decisions like that. If I'm hurting for gold I avoid upgrading. If I have some excess gold, I'll start upgrading.
If you have excess gold, you want to ask yourself if you are researching fast enough. If you have some gold in the bank after completing one research project, you may want to research the next project running a deficit to get it done faster.
If you have a completely developed city that has nothing better to do but make Wealth- well, there is almost always something better to do than Wealth- then that city instead should be pumping out new units instead of Wealth, to replace your obsolete units.
If you have some fringe cities that you are still using for production, but are lagging a little due to some corruption, disbanding obsolete units in those cities for the extra shields can make a significant difference.
If you have Leonardo's Workshop- which cuts upgrade costs in half- then upgrading is almost always going to be the most attractive option.
Golden Ages make your cities ultra-productive- its a good opportunity to build a lot of new units.
Finally, the problem is not so much in keeping obsolete units, as it is in keeping excess units (paying gpt for units that have no real purpose). Even if I intend to upgrade units, I might delay the upgrade to keep pumping my money into research. If I get hit by a surprise invasion, I can turn down the research slider for a turn to get money to do emergency upgrades for reinforcements and counterstrikes. Of course, by delaying the upgrade decision, the obsolete units are not providing as much deterrence to the AI (and sometimes, there are strategies in which you want to invite the AI to attack you first).