Measuring R&D Output and Knowledge Capital Formation in Open Economies