```-------------------------------------------------------------------------------
help: xtregfem                                                   dialog: xtregf
> em
-------------------------------------------------------------------------------

+-------+
----+ Title +------------------------------------------------------------

xtregfem: Fixed-Effects Panel Data: Ridge and Weighted Regression

+-------------------+

Syntax
Description
Options
Ridge Options
Weight Options
Weighted Variable Type Options
Other Options
Model Selection Diagnostic Criteria
Heteroscedasticity Tests
Saved Results
References

*** Examples

Author

+--------+
----+ Syntax +-----------------------------------------------------------

xtregfem depvar indepvars [if] [in] , id(var) it(var)

[ ridge(orr|grr1|grr2|grr3) kr(#)

lmhet diag mfx(lin|log) predict(new_var) resid(new_var)

weights(yh|yh2|abse|e2|le2|x|xi|x2|xi2) wvar(varname) iter(#)

noconstant coll dn tolog level(#) ]

+-------------+
----+ Description +------------------------------------------------------

xtregfem estimates Fixed-Effects Panel Data with Ridge and Weighted
Regression, and calculate Panel Heteroscedasticity, Model Selection
Diagnostic Criteria, and Marginal Effects and Elasticities

R2, R2 Adjusted, and F-Test, are obtained from 4 ways:

1- (Buse 1973) R2.
2- Raw Moments R2.
3- squared correlation between predicted (Yh) and observed dependent
variable (Y).
4- Ratio of variance between predicted (Yh) and observed dependent
variable (Y).

- F-Test=R2/(1-R2)*(N-K-1)/(K).

+---------+
----+ Options +----------------------------------------------------------

*  id(var)       Cross Sections ID variable name
*  it(var)       Time Series ID variable name

+---------------+
----+ Ridge Options +----------------------------------------------------

kr(#) Ridge k value, must be in the range (0 < k < 1).

IF kr(0) in ridge(orr, grr1, grr2, grr3), the model will be normal panel
regression.

ridge(orr) : Ordinary Ridge Regression    [Judge,et al(1988,p.878) eq.21.4.2]
> .
ridge(grr1): Generalized Ridge Regression [Judge,et al(1988,p.881) eq.21.4.12
> ].
ridge(grr2): Iterative Generalized Ridge  [Judge,et al(1988,p.881) eq.21.4.12
> ].

xtregfem estimates Ordinary Ridge regression as a multicollinearity
remediation method.
General form of Ridge Coefficients and Covariance Matrix are:

Br = inv[X'X + kI] X'Y

Cov=Sig^2 * inv[X'X + kI] (X'X) inv[X'X + kI]

where:
Br = Ridge Coefficients Vector (k x 1).
Cov = Ridge Covariance Matrix (k x k).
Y = Dependent Variable Vector (N x 1).
X = Independent Variables Matrix (N x k).
k = Ridge Value (0 < k < 1).
I = Diagonal Matrix of Cross Product Matrix (Xs'Xs).
Xs = Standardized Variables Matrix in Deviation from Mean.
Sig2 = (Y-X*Br)'(Y-X*Br)/DF

+----------------+
----+ Weight Options +---------------------------------------------------

wvar(varname)     Weighted Variable Name

xtregfem not like official Stata command xtreg in weight option,
xtregfem can use large types of weighted regression options.
wvar( ) must be combined with: weights(x, xi, x2, xi2)"

+--------------------------------+
----+ Weighted Variable Type Options +-----------------------------------

weights(yh)       Yh - Predicted Value
weights(yh2)      Yh^2 - Predicted Value Squared
weights(abse)     abs(E) - Absolute Value of Residual
weights(e2)       E^2 - Residual Squared
weights(le2)      log(E^2) - Log Residual Squared
weights(x)        (x) Variable
weights(xi)       (1/x) Inverse Variable
weights(x2)       (x^2) Squared Variable
weights(xi2)      (1/x^2) Inverse Squared Variable

+---------------+
----+ Other Options +----------------------------------------------------

coll             keep collinear variables; default is removing collinear vari
> ables.

noconstant       Exclude Constant Term from Equation

xtregfem not like official Stata command xtreg in constant t
> erm option,
xtregfem can exclude constant term.
weights option also can be used here.

dn               Use (N) divisor instead of (N-K) for Degrees of Freedom (DF)

iter(#)          number of iterations; Default is iter(100)

level(#)         confidence intervals level. Default is level(95)

mfx(lin, log)    functional form: Linear model (lin), or Log-Log model (log),
to compute Marginal Effects and Elasticities
- In Linear model: marginal effects are the coefficients (Bm),
and elasticities are (Es = Bm X/Y).
- In Log-Log model: elasticities are the coefficients (Es),
and the marginal effects are (Bm = Es Y/X).
- mfx(log) and tolog options must be combined, to transform linear variables
>  to log form.

tolog            Convert dependent and independent variables
to LOG Form in the memory for Log-Log regression.
tolog Transforms depvar and indepvars
to Log Form without lost the original data variables

predict(new_variable)      Predicted values variable

resid(new_variable)        Residuals values variable
computed as Ue=Y-Yh ; that is known as combined residual: [Ue =
> U_i + E_it]
overall error component is computed as: [E_it]
see: xtreg postestimation##predict

+-------------------------------------+
----+ Model Selection Diagnostic Criteria +------------------------------

diag Model Selection Diagnostic Criteria:
- Log Likelihood Function                   LLF
- Akaike Information Criterion              (1974) AIC
- Akaike Information Criterion              (1973) Log AIC
- Schwarz Criterion                         (1978) SC
- Schwarz Criterion                         (1978) Log SC
- Amemiya Prediction Criterion              (1969) FPE
- Hannan-Quinn Criterion                    (1979) HQ
- Rice Criterion                            (1984) Rice
- Shibata Criterion                         (1981) Shibata
- Craven-Wahba Generalized Cross Validation (1979) GCV

+------------------------------------------+
----+ Groupwise Panel Heteroscedasticity Tests +-------------------------
lmhet Groupwise Panel Heteroscedasticity Tests:
* Ho: Panel Homoscedasticity - Ha: Panel Groupwise Heteroscedasticity
- Lagrange Multiplier LM Test
- Likelihood Ratio LR Test
- Wald Test

+---------------+
----+ Saved Results +----------------------------------------------------

xtregfem saves the following results in e():

*** Model Selection Diagnostic Criteria:
e(N)            number of observations
e(r2bu)         R-squared (Buse 1973)
e(r2raw)        Raw Moments R2
e(f)            F-test
e(fp)           F-test P-Value
e(wald)         Wald-test
e(waldp)        Wald-test P-Value

e(r2h)          R2 Between Predicted (Yh) and Observed DepVar (Y)
e(fh)           F-test due to r2h
e(fhp)          F-test due to r2h P-Value

e(r2v)          R2 Variance Ratio Between Predicted (Yh) and Observed DepVar
>  (Y)
e(fv)           F-test due to r2v
e(fvp)          F-test due to r2v P-Value

e(sig)          Root MSE (Sigma)
e(llf)          Log Likelihood Function                   LLF
e(aic)          Akaike Information Criterion              (1974) AIC
e(laic)         Akaike Information Criterion              (1973) Log AIC
e(sc)           Schwarz Criterion                         (1978) SC
e(lsc)          Schwarz Criterion                         (1978) Log SC
e(fpe)          Amemiya Prediction Criterion              (1969) FPE
e(hq)           Hannan-Quinn Criterion                    (1979) HQ
e(rice)         Rice Criterion                            (1984) Rice
e(shibata)      Shibata Criterion                         (1981) Shibata
e(gcv)          Craven-Wahba Generalized Cross Validation (1979) GCV

*** Groupwise Heteroscedasticity Tests:
e(lmhglm)       Lagrange Multiplier LM Test
e(lmhglmp)      Lagrange Multiplier LM Test P-Value
e(lmhglr)       Likelihood Ratio LR Test
e(lmhglrp)      Likelihood Ratio LR Test P-Value
e(lmhgw)        Wald Test
e(lmhgwp)       Wald Test P-Value

Matrixes
e(b)            coefficient vector
e(V)            variance-covariance matrix of the estimators
e(mfxlin)       Marginal Effect and Elasticity in Lin Form
e(mfxlog)       Marginal Effect and Elasticity in Log Form

+------------+
----+ References +-------------------------------------------------------

Breusch, Trevor & Adrian Pagan (1980) "The Lagrange Multiplier Test and
its Applications to Model Specification in Econometrics", Review of
Economic Studies 47; 239-253.

Greene, William (2007) "Econometric Analysis", 6th ed., Macmillan
Publishing Company Inc., New York, USA..

Judge, Georege, R. Carter Hill, William . E. Griffiths, Helmut Lutkepohl,
& Tsoung-Chao Lee (1988) "Introduction To The Theory And Practice Of
Econometrics", 2nd ed., John Wiley & Sons, Inc., New York, USA.

Judge, Georege, W. E. Griffiths, R. Carter Hill, Helmut Lutkepohl, &
Tsoung-Chao Lee(1985) "The Theory and Practice of Econometrics", 2nd
ed., John Wiley & Sons, Inc., New York, USA.

+----------+
----+ Examples +---------------------------------------------------------

clear all

sysuse xtregfem.dta, clear

db xtregfem

xtset id t

xtregfem y x1 x2 , id(id) it(t) mfx(lin) predict(Yh) resid(Eu) diag lmh

xtregfem y x1 x2 , id(id) it(t) mfx(log) predict(Yh) resid(Eu) diag lmh tolog

xtregfem y x1 x2 , id(id) it(t) mfx(lin) ridge(orr) kr(0.5)

xtregfem y x1 x2 , id(id) it(t) mfx(lin) ridge(grr1)

xtregfem y x1 x2 , id(id) it(t) mfx(lin) ridge(grr2)

xtregfem y x1 x2 , id(id) it(t) mfx(lin) ridge(grr3)

xtregfem y x1 x2 , id(id) it(t) mfx(lin) ridge(grr1) weight(x) wvar(x1) diag
> lmh
-------------------------------------------------------------------------------

. clear all
. sysuse xtregfem.dta, clear
. xtregfem y x1 x2 , id(id) it(t) mfx(lin) ridge(grr1) weight(x) wvar(x1) diag
> lmh

==============================================================================
* Fixed-Effects Panel Data: Ridge and Weighted Regression
==============================================================================
y = x1 + x2
------------------------------------------------------------------------------
* Weighted Regression Type: (X)     -   Variable: (x1) *
------------------------------------------------------------------------------
Ridge k Value     =   0.07455     |   Generalized Ridge Regression
------------------------------------------------------------------------------
Sample Size       =          49   |   Cross Sections Number   =           7
Wald Test         =     42.1545   |   P-Value > Chi2(2)       =      0.0000
F-Test            =     21.0773   |   P-Value > F(2 , 40)     =      0.0000
(Buse 1973) R2     =      0.7504   |   Raw Moments R2          =      0.9539
(Buse 1973) R2 Adj =      0.7004   |   Raw Moments R2 Adj      =      0.9447
Root MSE (Sigma)  =      8.6488   |   Log Likelihood Function =   -170.2694
------------------------------------------------------------------------------
- R2h= 0.5523   R2h Adj= 0.4628  F-Test =   28.38 P-Value > F(2 , 40)  0.0000
- R2v= 0.3040   R2v Adj= 0.1647  F-Test =   10.04 P-Value > F(2 , 40)  0.0003
------------------------------------------------------------------------------
y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
x1 |  -.2093654   .0834836    -2.51   0.016     -.378092   -.0406388
x2 |  -1.168243   .2892215    -4.04   0.000    -1.752782   -.5837048
_cons |   59.59259   4.031342    14.78   0.000     51.44495    67.74024
------------------------------------------------------------------------------

==============================================================================
* Panel Model Selection Diagnostic Criteria
==============================================================================

- Log Likelihood Function       LLF               =  -170.2694
- Akaike Final Prediction Error AIC               =   346.5387
- Schwartz Criterion            SC                =   352.2142
- Akaike Information Criterion  ln AIC            =     4.2343
- Schwarz Criterion             ln SC             =     4.3502
- Amemiya Prediction Criterion  FPE               =    79.3808
- Hannan-Quinn Criterion        HQ                =    72.1167
- Rice Criterion                Rice              =    69.5825
- Shibata Criterion             Shibata           =    68.5392
- Craven-Wahba Generalized Cross Validation-GCV   =    69.2865
------------------------------------------------------------------------------

==============================================================================
* Panel Groupwise Heteroscedasticity Tests
==============================================================================
Ho: Panel Homoscedasticity - Ha: Panel Groupwise Heteroscedasticity

- Lagrange Multiplier LM Test     =   7.3373     P-Value > Chi2(6)   0.2908
- Likelihood Ratio LR Test        =   7.1253     P-Value > Chi2(6)   0.3094
- Wald Test                       =  12.4812     P-Value > Chi2(7)   0.0858
------------------------------------------------------------------------------

* Linear: Marginal Effect - Elasticity *

+-----------------------------------------------------------------------------+
|     Variable | Marginal_Effect(B) |     Elasticity(Es) |               Mean |
|--------------+--------------------+--------------------+--------------------|
|           x1 |            -0.2094 |            -0.2291 |            38.4362 |
|           x2 |            -1.1682 |            -0.4781 |            14.3749 |
+-----------------------------------------------------------------------------+
Mean of Dependent Variable =     35.1288

+--------+
----+ Author +-----------------------------------------------------------

Professor (PhD Economics)
Agricultural Research Center - Agricultural Economics Research Institute - Eg
> ypt
WebPage at IDEAS:       http://ideas.repec.org/f/psh494.html
WebPage at EconPapers:  http://econpapers.repec.org/RAS/psh494.htm

+-------------------+
----+ XTREGFEM Citation +------------------------------------------------

XTREGFEM: "Fixed-Effects Panel Data: Ridge and Weighted Regression"

http://ideas.repec.org/c/boc/bocode/s457457.html

http://econpapers.repec.org/software/bocbocode/s457457.htm

* Econometric Regression Models:

* (1) (OLS) * Ordinary Least Squares Regression Models:
olsreg     OLS Econometric Ridge & Weighted Regression Models: Stata Module Too
> lkit
ridgereg   OLS Ridge Regression Models
gmmreg     OLS Generalized Method of Moments (GMM): Ridge & Weighted Regression
chowreg    OLS Structural Change Regressions and Chow Test
---------------------------------------------------------------------------
* (2) (2SLS-IV) * Two-Stage Least Squares & Instrumental Variables Regression M
> odels:
reg2       2SLS-IV Econometric Ridge & Weighted Regression Models: Stata Module
>  Toolkit
gmmreg2    2SLS-IV Generalized Method of Moments (GMM): Ridge & Weighted Regres
> sion
limlreg2   Limited-Information Maximum Likelihood (LIML) IV Regression
meloreg2   Minimum Expected Loss (MELO) IV Regression
ridgereg2  Ridge 2SLS-LIML-GMM-MELO-Fuller-kClass IV Regression
ridge2sls  Two-Stage Least Squares Ridge Regression
ridgegmm   Generalized Method of Moments (GMM) IV Ridge Regression
ridgeliml  Limited-Information Maximum Likelihood (LIML) IV Ridge Regression
ridgemelo  Minimum Expected Loss (MELO) IV Ridge Regression
---------------------------------------------------------------------------
* (3) * Panel Data Regression Models:
regxt      Panel Data Econometric Ridge & Weighted Regression Models: Stata Mod
> ule Toolkit
xtregdhp   Han-Philips (2010) Linear Dynamic Panel Data Regression
xtregam    Amemiya Random-Effects Panel Data: Ridge & Weighted Regression
xtregbem   Between-Effects Panel Data: Ridge & Weighted Regression
xtregbn    Balestra-Nerlove Random-Effects Panel Data: Ridge & Weighted Regress
> ion
xtregfem   Fixed-Effects Panel Data: Ridge & Weighted Regression
xtregmle   Trevor Breusch MLE Random-Effects Panel Data: Ridge & Weighted Regre
> ssion
xtregrem   Fuller-Battese GLS Random-Effects Panel Data: Ridge & Weighted Regre
> ssion
xtregsam   Swamy-Arora Random-Effects Panel Data: Ridge & Weighted Regression
xtregwem   Within-Effects Panel Data: Ridge & Weighted Regression
xtregwhm   Wallace-Hussain Random-Effects Panel Data: Ridge & Weighted Regressi
> on
xtreghet   MLE Random-Effects Multiplicative Heteroscedasticity Panel Data Regr
> ession
---------------------------------------------------------------------------
* (4) (MLE) * Maximum Likelihood Estimation Regression Models:
mlereg     MLE Econometric Regression Models: Stata Module Toolkit
mleregn    MLE Normal Regression
mleregln   MLE Log Normal Regression
mlereghn   MLE Half Normal Regression
mlerege    MLE Exponential Regression
mleregle   MLE Log Exponential Regression
mleregg    MLE Gamma Regression
mlereglg   MLE Log Gamma Regression
mlereggg   MLE Generalized Gamma Regression
mlereglgg  MLE Log Generalized Gamma Regression
mleregb    MLE Beta Regression
mleregev   MLE Extreme Value Regression
mleregw    MLE Weibull Regression
mlereglw   MLE Log Weibull Regression
mleregilg  MLE Inverse Log Gauss Regression
---------------------------------------------------------------------------
* (5) * Autocorrelation Regression Models:
autoreg    Autoregressive Least Squares Regression Models: Stata Module Toolkit
alsmle     Beach-Mackinnon AR(1) Autoregressive Maximum Likelihood Estimation R
> egression
automle    Beach-Mackinnon AR(1) Autoregressive Maximum Likelihood Estimation R
> egression
autopagan  Pagan AR(p) Conditional Autoregressive Least Squares Regression
autoyw     Yule-Walker AR(p) Unconditional Autoregressive Least Squares Regress
> ion
autopw     Prais-Winsten AR(p) Autoregressive Least Squares Regression
autoco     Cochrane-Orcutt AR(p) Autoregressive Least Squares Regression
autofair   Fair AR(1) Autoregressive Least Squares Regression
---------------------------------------------------------------------------
* (6) * Heteroscedasticity Regression Models:
hetdep     MLE Dependent Variable Heteroscedasticity
hetmult    MLE Multiplicative Heteroscedasticity Regression
hetstd     MLE Standard Deviation Heteroscedasticity Regression
hetvar     MLE Variance Deviation Heteroscedasticity Regression
glsreg     Generalized Least Squares Regression
---------------------------------------------------------------------------
* (7) * Non Normality Regression Models:
robgme     MLE Robust Generalized Multivariate Error t Distribution
bcchreg    Classical Box-Cox Multiplicative Heteroscedasticity Regression
bccreg     Classical Box-Cox Regression
bcereg     Extended Box-Cox Regression
---------------------------------------------------------------------------
* (8) (NLS) * Nonlinear Least Squares Regression Regression Models:
autonls    Non Linear Autoregressive Least Squares Regression
qregnls    Non Linear Quantile Regression
---------------------------------------------------------------------------
* (9) * Logit Regression Models:
logithetm  Logit Multiplicative Heteroscedasticity Regression
mnlogit    Multinomial Logit Regression
---------------------------------------------------------------------------
* (10) * Probit Regression Models:
probithetm Probit Multiplicative Heteroscedasticity Regression
mnprobit   Multinomial Probit Regression
---------------------------------------------------------------------------
* (11) * Tobit Regression Models:
tobithetm  Tobit Multiplicative Heteroscedasticity Regression
---------------------------------------------------------------------------

Panel Data Tests:

* (1) * Autocorrelation Tests:
lmaxt      Panel Data Autocorrelation Tests
lmabxt     Panel Data Autocorrelation Baltagi Test
lmabgxt    Panel Data Autocorrelation Breusch-Godfrey Test
lmabpxt    Panel Data Autocorrelation Box-Pierce Test
lmabpgxt   Panel Data Autocorrelation Breusch-Pagan-Godfrey Test
lmadurhxt  Panel Data Autocorrelation Dynamic Durbin h and Harvey LM Tests
lmadurmxt  Panel Data Autocorrelation Dynamic Durbin m Test
lmadwxt    Panel Data Autocorrelation Durbin-Watson Test
lmavonxt   Panel Data Von Neumann Ratio Autocorrelation Test
lmawxt     Panel Data Autocorrelation Wooldridge Test
lmazxt     Panel Data Autocorrelation Z Test
---------------------------------------------------------------------------
* (2) * Heteroscedasticity Tests:
lmhxt      Panel Data Heteroscedasticity Tests
lmhgwxt    Panel Data Groupwise Heteroscedasticity Tests
ghxt       Panel Groupwise Heteroscedasticity Tests
lmhlmxt    Panel Data Groupwise Heteroscedasticity Breusch-Pagan LM Test
lmhlrxt    Panel Data Groupwise Heteroscedasticity Greene LR Test
lmharchxt  Panel Data Heteroscedasticity Engle (ARCH) Test
lmhcwxt    Panel Data Heteroscedasticity Cook-Weisberg Test
lmhglxt    Panel Data Heteroscedasticity Glejser Test
lmhharvxt  Panel Data Heteroscedasticity Harvey Test
lmhhpxt    Panel Data Heteroscedasticity Hall-Pagan Test
lmhmssxt   Panel Data Heteroscedasticity Machado-Santos-Silva Test
lmhwaldxt  Panel Data Heteroscedasticity Wald Test
lmhwhitext Panel Data Heteroscedasticity White Test
---------------------------------------------------------------------------
* (3) * Non Normality Tests:
lmnxt      Panel Data Non Normality Tests
lmnadxt    Panel Data Non Normality Anderson-Darling Test
lmndhxt    Panel Data Non Normality Doornik-Hansen Test
lmndpxt    Panel Data Non Normality D'Agostino-Pearson Test
lmngryxt   Panel Data Non Normality Geary Runs Test
lmnjbxt    Panel Data Non Normality Jarque-Bera Test
lmnwhitext Panel Data Non Normality White Test
---------------------------------------------------------------------------
* (4) * Panel Data Error Component Tests:
lmecxt     Panel Data Error Component Tests
---------------------------------------------------------------------------
* (5) * Panel Data Diagonal Covariance Matrix Test:
lmcovxt    Panel Data Breusch-Pagan Diagonal Covariance Matrix LM Test
---------------------------------------------------------------------------
* (6) * Panel Data ModeL Selection Diagnostic Criteria:
diagxt     Panel Data ModeL Selection Diagnostic Criteria
---------------------------------------------------------------------------
* (7) * Panel Data Specification Tests:
lmhausxt   Panel Data Hausman Specification Test
resetxt    Panel Data REgression Specification Error Tests (RESET)
---------------------------------------------------------------------------
* (8) * Panel Data Identification Variables:
idt        Create Identification Variables in Panel Data
xtidt      Create Identification Variables in Panel Data
---------------------------------------------------------------------------

```