Gravity estimation based on sector-level trade data is generally misspecified because it ignores the role of product-level comparative advantage in shaping the effects of trade barriers on sector-level trade flows. Using a model that allows for arbitrary patterns of product-level comparative advantage, I show that sector-level trade flows follow a generalized gravity equation that contains an unobservable, bilateral component that is correlated with trade costs and omitted by standard sector-level gravity models. I propose and implement an estimator that uses product-level data to account for patterns of comparative advantage and find the bias in sector-level estimates to be significant. I also find that, when controlling for product-level comparative advantage, estimates are much more robust to distributional assumptions, suggesting that remaining biases due to heteroskedasticity and sample selection are less severe than previously thought.JEL Classification: F10, F14, C13, C21, C50