Using firm-level data from the German manufacturing sector, we estimate a dynamic, structural model of the firm's decision to invest in R&D and quantify the cost and long-run benefit of this investment. The model incorporates and quantifies linkages between the firm's R&D investment, product and process innovations, and future productivity and profits. The dynamic model provides a natural measure of the long-run payoff to R&D as the difference in expected firm value generated by the R&D investment. For the median productivity firm, investment in R&D raises firm value by 3.0 percent in a group of high-tech industries but only 0.2 percent in low-tech industries. Simulations of the model show that cost subsidies for R&D can significantly affect R&D investment rates and productivity changes in the high-tech industries