Often times, an anal gland problem, degenerative myelopathy (nerve problems to the end of the spinal cord), severe arthritis, or even a tumor/cancer back in the perineal region can result in this. I'd recommend seeking a veterinarian for a full examination, including a rectal exam and possible ultrasound or x-rays of that area to find out what's going on. I highly doubt it's a "behavioral" issue at this point. Is your dog aware of when she's doing it? Is she posturing when she's doing it? (Or is she just lying there and it's on her bed)? These are important questions to let your vet know. Best of luck with her!
Thank you very much. We shall take her to the vet.