Biblical scholar Dale Allison in his book Resurrecting Jesus has a very interesting discussion of this phenomenon and he surveys the anthropological and psychological literature on the subject. He also reveals that he himself has experienced this. Here is part of his summary:
"In case after case, and from different regions of the globe, we have learned that up to half of all widows and widowers believe that they have run into their dead spouses, that is, have seen them and/or heard them and/or felt their presence. This is clearly a normal part of the mourning process: the bereaved frequently report contact with the dead. We have also now learned that such contact is not confused to surviving partners or those in mourning. Indeed, when asked, all parts of the general public report a high incidence -- surveys from Western Europe and North America vary anywhere from about 10-40 percent -- of apparent contact with the dead through dreams, voices, felt presences, as well as visions while wide awake. These experiences are, moreover, often experienced as quite vivid and real" (pp. 274-275).
Then after relating his own experience, he says: "I relate all this not so that others may believe that Barbara survived death and spoke to me, nor that readers might regard me as fantasy prone or a victim of mental dysfunction. The point is only that these things really happen, and in my case I know this from firsthand experience. I also know how overwhelmingly real such events can seem -- so real that I took them at the time to originate in something other than my own subjectivity and have difficulty thinking otherwise even now, years later" (p. 276). He goes on to withhold any judgment on an ontological external reality causing these experiences, but he very interestingly notes that these experiences resemble NT resurrection christophany stories in the NT. In particular, the dead person is not perceived as a ghost or transparent spirit but as a real three-dimensional solid person, but there are other parallels.