help for gpreg                                          (Johannes F. Schmieder)

gpreg - Estimates regressions with two dimensional fixed effects.


gpreg varlist [if] [in] , ivar(varname) jvar(varname) [ ife(new varname) jfe(varname) maxiter(integer) tolerance(float) nodots Algorithm(integer) ]


Estimation of regressions with two dimensions of fixed effects, e.g. worker and firm fixed effects, student and teacher, or patient and doctor fixed effects. This program uses the Guimaraes & Portugal algorithm which has the advantage of being very memory efficient. It also calculates the correct standard errors under the assumption that the error term is homoskedastic and independently distributed. The indicators for the fixed effects dimensions are given as ivar(varname) and jvar(varname).


ife(new varname) jfe(varname): Specify two new variable names to generate the fixed effects associated with I and J variables.

nodots: Suppress dots indicating the progress of the iteration algorithm.

Algorithm(integer): Where integer is either 1, 2, 3 or 4. Choose between different implemenations of the algorithm:

1: The default. Mata implemenation, transforming all variables simultaneously.

2: Mata implementation. Transforming variables one by one. Slower but needs less memory.

3: Stata implementation. Similar to 2 but implemented in Stata, generally faster than 2.

4: Stata implementation. Similar to 2 but includes an algorithm to speed up convergence provided by Paulo Guimaraes.

tolerance(float) Specify the convergence criterion for the iteration method.

maxiter(integer) Specify a maximum number of iterations for the iteration method.


. sysuse nlsw88

. gpreg wage union, ivar(grade) jvar(industry)

. gpreg wage union, ivar(grade) jvar(industry) maxiter(500) dots minmem a(2)


Johannes F. Schmieder, Columbia University, USA

Email: johannesschmieder@gmail.com

Comments welcome!


The algorithm is based on the paper by Paulo Guimaraes and Pedro Portugal (see > reference below). The program makes use of Amine Quazad's a2group algorithm to compute the connec > ted groups. Paulo Guimaraes made many helpful suggestions during development and assisted i > n testing the program. Remaining errors are my own (however: use this program at your own risk).


If you use this program in your research please cite this program and the paper > Paulo Guimaraes, Pedro Portugal. "A Simple Feasible Alternative Procedure to Es > timate Models with High-Dimensional Fixed Effects", IZA DP No. 3935, 2009.

Also see

a2reg (if installed), a2group (if installed), felsdvreg (if installed).