In this paper we study the uncertainty in the Q-theory of investment. A Q-type investment model is derived, which contains the information on uncertainty effects of random variables that affect the future profitability of a firm. Besides the usual capital accumulation constraint, the firm is also restricted by stochastic process for output and input prices. By using the method of dynamic programming, an explicit optimal investment function is derived.Testing the model at two different levels, sector and firm level, by using two groups of panel data, it is possible to find empirical implication in the Iran's economy so as to explain sectoral and firm investment behavior. It may also be concluded that the empirical weakness of standard Q-type investment models is due to ignoring uncertainty. At the firm level, there is a positive correlation between the price and exchange rate uncertainty and investment. But at the sector level, although it is the same for the exchange rate uncertainty, there is a negative impact of the price uncertainty on investment.