The most common cause of sag at the roof ridge is loss of triangulation due to failure of the bottom leg of the triangle which makes the peak of the roof sag and top of the walls spread outward in the area of failure.
Sagging roof ridge beam.
If the beam is not properly nailed it can also pull loose and this contributes to.
Ridge beam or ridge board sagging or damaged roofs may sag because a ridge beam or ridge board is cracked or damaged.
The beam is attached to both exterior walls and to the bottom of each sloping rafter to give the roof strength.
Rafter ties another cause.
Check the ceiling for sagging by attaching a string on one end of the beam and run it along the bottom edge of the beam.
This may have been caused by any number of factors.