is the depression and anxiety in SPS and ME/CFS a function of the disease itself or simply the result of having a chronic illness?

is the depression and anxiety in SPS and ME/CFS a function of the disease itself or simply the result of having a chronic illness?