A longitudinal exploration of mental health resilience, cognitive impairment and loneliness