Industry and Year Fixed Effects I hope someone can help me as I am stuck with this problem for quite some time. 
I have panel of S&P500 companies from 2010 - 2014 and I want to run a regression including industry and year fixed effects.
I am a beginner in panel data analysis and also Stata, and I cant find the answer anywhere. I am so confused as I am not sure whether industry and year fixed effects are equivalent to cross-section and period fixed effects. 
 A: Let's say you have some category variable $c_i$ (eg. c may be the industry company $i$ is in). An important mathematical point to keep in mind is that running a fixed effects regression with fixed effects for $c$ is equivalent to running a regular regression with indicator variables for each possible value of $c$.
A basic strategy might be to:


*

*use xtset industryvar in Stata to indicate you want fixed effects for each unique value of industryvar.

*Generate dummy variables for every year.

*Call xtreg with the fe option to indicate fixed effects, including the dummy variables for year as right hand side variables.


More explicitly, you might do something like:
xtset industry
xtreg y x1 x2 i.year, fe

This assumes year is a variable which holds the year, industry is a variable that holds the industry etc...
A: In this context, a fixed effect regression (or within estimator) is a method for modelling with panel or longitudinal data. This estimator differences out the average of the observational unit's variables from each variable:
For individuals $i \in 1\dots N$, observed in periods $1\dots T$, and covariates $X_k$, and dependent variable $Y$, the fixed effect estimator performs the following transformation:

$\breve{Y}_{it} = Y_{it} - \bar{Y}_i$ and
  $\breve{X}_{kit} = X_{kit} - \bar{X}_{ki}$ for $k = 1\dots K$

The regression is performed on the transformed variables. In stata, this is implemented using the xtreg command with the fe option.
This command will probably not work in your situation, since it is designed for differencing out averages for each observational unit. It is likely that you will have multiple companies that operate in a particular industry and you want to difference out the industry average. This is a simple case of a hierarchical linear model.
In this situation, you want to use the i. operator in Stata:
reg y i.industry i.year

You could also use the areg command to get identical results:
areg y i.year, absorb(industry)

The areg command can be useful when the number of levels of the absorbed variable (the number of industries in this example) is high.
If it is true that there are multiple firms within the same industry as I suspect to be the case, then it is a common practice, which is good sense and asymptotically supported, to cluster your standard errors at the industry level. In stata, this is typically accomplished with the vce(cluster varname) option. So, for example, your regress command would become
reg y i.industry i.year, vce(cluster industry)

On a similar note, a fairly recent development has been made in constructing two-way and multiway cluster robust standard errors (See, for example, the Cameron, Gelbach, and Miller's 2011 paper in the Journal of Business and Economic Statistics). If you are worried about shocks that affect the entire set of stocks in a given time period, this may be worth implementing. Doug Miller wrote an .ado file called cgm.ado that implements one method of multiway clustering.
