Symbolism, Imagery, Allegory
Most fiction takes one of two approaches to ghosts. There's the terror approach (think The Ring), in which evil spirits from beyond freak people out and generally try to kill and destroy the living. And then there's the more romantic or nostalgic approach that grew out of the Spiritualism movement in nineteenth-century England. This is the kind of ghost we see in movies like Ghost or The Sixth Sense, where the ghosts are reminders of loved ones and generally need the living to help them move on from our world to the afterlife.
So what about the ghosts in One Hundred Years of Solitude? Again, the novel breaks with expectations. The ghost of Prudencio Aguilar isn't out to hurt anyone (except maybe to guilt-trip them a little). At the same time, he has nowhere to move on to – quite the opposite, since he has spent years trying to track down the living Buendías that he knows. If anything, this ghost isn't about the past, but the future, hanging around so he can eventually take José Buendía back with him to the afterlife. So what do we do with a ghost who is so different from what we've come to expect our undead to be? Is this just another instance of magical realism?