R&D, innovation and output: evidence from OECD and nonOECD countries