One study found that lonely people also engage in more imaginary conversations than those who don't consider themselves lonely. Perhaps ending up talking to oneself out loud is somehow related?
https://psychnewsdaily.com/lonely-people-have-a-unique-brain...