Demand shocks and firm-financed R&D expenditures