Study links diseases to intelligence