Owning a pet is linked to having better cognitive health in advanced age, study finds