Interpreting accruals as working capital investment, we hypothesize based on q-theory that firms optimally adjust their accruals in response to discount rate changes. A higher discount rate means less profitable investments and lower accruals, and a lower discount rate means more profitable investments and higher accruals. Our evidence supports this optimal investment hypothesis: (1) adding an investment factor into standard factor regressions substantially reduces the magnitude of the accrual anomaly, often to insignificant levels; (2) accruals covary negatively with discount rate estimates from the dividend discounting model, and for the most part, with estimates from the residual income model; (3) accruals with low accounting reliability covary more with capital investment than accruals with high accounting reliability; and (iv) expected returns to accruals-based trading strategies are time-varying, suggesting that the deterioration of the accrual effect in recent years might be temporary and likely to mean-revert in the near future.