All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
If your grandmother is not of sound mind in the sense that she never comes to her senses, then she is neither required to fast nor expiate for the days of fasting she misses. This is because having a sound mind is a requirement for religious accountability, as agreed upon by all Muslim jurists. The Prophet, sallallaahu ‘alayhi wa sallam, said: “The Pen (of recording the deeds of the slaves) is lifted from (does not record the deeds of) three types of people: a child until he reaches the age of puberty, a sleeping person until he wakes up, and an insane person until he recovers.” [Abu Daawood; An-Nasaa’i reported it with a sound chain of transmission]. This hadith indicates that anyone who does have a sound mind is not obligated to observe the precepts of the religion. In his book Ahkaam Al-Quran, Al-Jassaas comments on the verse that reads (what means): {... therefore whoever of you is present in the month, he shall fast therein...} [Quran 2:185] According to Al-Jassaas, what is meant by being present in the month is that the Muslim is capable of observing religious obligations; whoever is not capable of observing religious obligations is not required to fast.
However, if your grandmother returns to a sound state of mind for a period of time that is long enough for her to observe the fast, then she is required to feed a poor person for each day of fasting that she misses while being sound of mind. This is because Allah says (what means): {... And upon those who are able [to fast, but with hardship]—a ransom [as substitute] of feeding a poor person [each day]...} [Quran 2: 184] Ibn ‘Abbas said: “This verse provides an exception for elderly men and women who are unable to fast. Instead, they must feed a poor person for each day that they miss.” [Al-Bukhari] However, your grandmother does not have to give food in charity if she cannot afford it.
Allaah Knows best.