I just finished reading a terrific book that is about all this. It's called
The Modern Book of the Dead by Ptolemy Tomkins.
I really enjoyed it and most of it resonated with my own experience, which was a welcome thing.
I also agree with whomever said 'like attracts like' with ghosts. I went through a tough time during which I was experiencing a serious depression but didn't want to face it. During this time a ghost began to plague me (I really do "see dead people" but they have never bothered me or been a problem).
This ghost was a man who in life had been alcoholic and suicidal. Before he had the chance to end his own life, he fell down our back stairs and broke his neck.
He began to shove me on the stairs and bother me in other ways. I have never had a problem with a ghost, but I meditated, attempted to clear the house with sage and prayer. It got worse.
Finally I called on my guide. Boom, problem solved in a warm bath of light.
After that I addressed my depression directly and began to do a morning positive intent ritual that I still do to this day.
It was my depression that was drawing that ghost, but also, in time I came to see he was trying to help in his own messed up way.
All things eventually unfold for the greater good, but it's real ride.