To test whether the fixed effects (FE) or random effects (RE) model is more appropriate for a panel data regression (using xtreg here), do the following:
xtreg y x1 x2 x3, fe
estimates store FE
xtreg y x1 x2 x3, re
estimates store RE
hausman FE RE
If p < 0.05, use the FE model.
This is taken from the discussion here. Note the discussion and the use of xtoverid in some situations.
Another test for FE vs RE using xtgls and lrtest is discussed here and described here.
Edit: I have a follow up post on this here.
Reference: Hausman test (fe vs. re), use robust SE or not? [Statalist],
Stata 12 help for hausman [Stata]