Maybe I was lucky, but I never felt in danger in major US cities walking literally everywhere. While in D.F. I had some anxiety outside of central roads.
It's hard to give some objective analysis, but I don't personally feel safe walking alone at night in large areas of NYC, Baltimore, Chicago, Atlanta, Detroit, St Louis, Miami, etc.
Most of the Bronx, about half of Queens, about 1/3 of Brooklyn. Manhattan is mostly gentrified these days, with only a handful of exceptions. Staten Island is odd b/c it is barely walkable to begin with, so it's neither safe nor dangerous to walk.
Everything is relative to what you're used to I guess. I'm from a Canadian suburb, where a 16 years old girl who got attacked in a dark alley at 3:30 am while alone made the news for 3 months because that was the worse thing that had happened in decades.
Now I'm in Boston, in a heavily gentrified area, and I'm scared shitless after 11 pm. People all tell me it's a super safe area, but I know a few people who got mugged a few blocks away in various occasions.
Maybe it's just bad luck. Maybe compared to other areas, a few people getting their backpack stolen is nothing. But feelings are not always rationals. I don't feel safe here.
Homelessness is not a root cause for things; it is one symptom of fundamental problems that people have. Other symptoms include aggressiveness and unpredictability. These other symptoms may also be at least a partial reason why the people are homeless.
Not all nor even a majority of homeless people developed countries are aggressive or unpredictable, but the risk is higher. Around here most of them are quite tame and humble, at least most of the time, and I'd much rather use the word "weak" than "bad", though.
But yes, homeless people can be scary. Being a stranger in SF, I was somewhat alarmed when driving in the city and finding myself in a central neighbourhood where I wouldn't want to stop at the red light.