Fama-Macbeth practitioner's step by step guide?

I've been reading the original Fama-Macbeth (1973) paper as well as questions here and elsewhere. I feel like I'm beginning to run in circles and would like to clarify/confirm how FM regression is done, step by step. My interest is purely that of a practitioner's: I would like to run Fama-Macbeth regressions on a specific country's stock market to test difference risk factors' relevance in explaining returns.

Assume you are running FM for N securities over 1990 - 2010 period.

1) Step 1: For 1990-2000, run time-series regressions for each security i where R(i) = B(i)*RiskFactor + e(i). Store B(i)'s for each security. You will run N regressions here.

2) Step 2: Go to 2000-2010 period, run cross-section regressions for each month where R(i) = Lambda(i) * B(i) + e(i). Bi's are already calculated in step 1. You get Lambda(i)'s and e(i)'s in this step. You will run T regressions here.

3) Step 3: Calculate Lambda(i) average and e(i) average (simple average of each month's). Do tests of significance on them. If your factor has explanatory power over returns, then Lambda(i) should be statistically significant whereas e(i) should not be statistically significant.

Would highly appreciate if you could point to any errors in the above summary

*Also, I am confused about the use of portfolios. In their original paper Fama-Macbeth create 20 portfolios by Beta sort. From what I understand, they use these portfolios in step 2 above (cross-section regressions). They also state that they allow securities to go in and out of portfolios, however, I do not understand how this is possible given they are doing cross sectional regressions and allowing for portfolio changes would cause a lot of problems.

If there are any practical step by step guides I would highly appreciate it too.

Thank you

For each stock run a time series regression:

$$r_{i,t} = \alpha + \beta F_t + \epsilon_t$$

Then for each month $$t$$, you run a cross-section regression:

$$r_{i,t} = \lambda_0 + \hat{\beta}_i {\lambda}_t + \alpha_{i,t}$$

Where: $$\hat{\beta}_i \equiv [\beta_{i, MktRf}, \beta_{i, SMB}, \beta_{i, HML}]'$$, is a vector of the coefficients estimated on the first step.

What you are looking for is to estimate the vector of $$\hat{\lambda}_t \equiv [\lambda_{t, MktRf}, \lambda_{y, SMB}, \lambda_{t, HML}]$$.

So after the second step you will have $$T$$ estimates for each $$\lambda$$ (price of risk).

Then you just need to average those $$\lambda$$'s:

$$\hat{\lambda} = \frac{1}{T} \sum^{T}_{t=1} \hat{\lambda}_t$$

And you can test their statistical significance using as a variance estimate the following:

$$Est.Asy.Var(\hat{\lambda}) = \frac{1}{T^2} \sum^{T}_{t=1} (\hat{\lambda}_t - \hat{\lambda} )(\hat{\lambda}_t - \hat{\lambda} )'$$

This assumes that the factor loadings, B(i), would have to be stable across those time periods. A lot of the research acknowledges that factor loadings do change over time.

A better approach might be to follow the example from Grinold, Richard and Ronald N. Kahn, “Multiple-Factor Models for Portfolio Risk”, Financial Analysts Journal, Vol. 46, No. 2 (Mar. - Apr., 1990), pp. 59 - 80. Available at https://www.jstor.org/stable/4479311. They generated the Risk factors for the subsequent period (2000-2010) in your case, and then used the B(i) from the earlier period (1990 - 2000), to test the error terms e(i). They tested the mean squared error of the prediction versus actual to see how well the model explained future returns.