Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Impavido, Gregorio" <GImpavido@imf.org> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: how many d.f. in the vcv for the within estimator? |

Date |
Wed, 12 Dec 2012 08:49:13 -0500 |

Mark, thank you. I do not have your text at hand but so does Baltagi "Econometric Analysis of Panel Data" fourth edition page 16. I am not disputing the point. I was trying to understand the rationale. I would have thought that the Q transform is not simply a computational expedient but a way to improve efficiency re LSDV. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Schaffer, Mark E Sent: Tuesday, December 11, 2012 7:55 PM To: statalist@hsphsun2.harvard.edu Subject: st: RE: how many d.f. in the vcv for the within estimator? Gregorio, The classical VCV does indeed need to incorporate the dof adjustment associated with the N individual effects. See e.g. Hayashi's Econometrics p. 334 (the textbook I have at hand - you can find it in other texts as well). HTH, Mark > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner- > statalist@hsphsun2.harvard.edu] On Behalf Of Impavido, Gregorio > Sent: 12 December 2012 00:41 > To: statalist@hsphsun2.harvard.edu > Subject: st: how many d.f. in the vcv for the within estimator? > > Dear all, > > I am trying to replicate the result of -xtreg, fe- in mata. Given that the > individual effects are not estimated after the within transform, shouldn't the > degrees of freedom used for the estimate of the variance of the residuals be > (N*T-k-1) instead of N*(T-1)-k (where N=number of panels, > T=periods,k=number of regressors)? I have added the intercept = the meant > of the dep variable as in STATA manual. > > I paste the code used below which reproduces the results after if force df_r= > N*(T-1)-k. Any suggestion would be welcome. > > With kind regards > Gregorio > ================== > * this do file reproduces the results of -xtreg, fe- using mata > * it works only with balanced panels > * For corrections and suggestions, Gregorio Impavido (gimpavido@imf.org) > ********************************************************** > ********************* > ************************************ START > ************************************ > ********************************************************** > ********************* > use "http://www.stata-press.com/data/r9/grunfeld.dta ", clear rename > invest I rename mvalue F rename kstock C sort company time > gen touse=(I!=. & F!=. & C!=.) // ignore eventual missing obs > > * example of panel within estimator > mata: > mata clear // clear the workspace > > T = 20 // Number of observations per groups > N = 10 // Number of groups > > Z = st_data(.,("F","C"),"touse") // (NTxk) matrix of regressors > Y = st_data(.,("I"),"touse") // (NTx1) vector of dep var > i = J(rows(Z),1,1) // (NTx1) vector of ones, declare a > X = Z,i > it = J(T,1,1) // (Tx1) vector of ones, declare a > in = J(N,1,1) // (Tx1) vector of ones, declare a > B = pinv(T)*I(N)#(it*it') // (NTxNT) between-individual operator > Bbar = pinv(N)*(in*in')#I(T) // (NTxNT) between-individual operator > Q = I(N*T)-B // (NTxNT) Q within transform > * Qbar = I(N*T)-Bbar // (NTxNT) Qbar within period operator > Ybar = B*Bbar*Y // (NTx1) vector of mean dep var > Zbar = B*Bbar*Z // (NTxk) matrix of mean regressor var > Ytilda = Q*Y + Ybar // added overall mean > Ztilda = Q*Z + Zbar // added overall mean > Xtilda = Ztilda,i // (NTxk+1) add column of 1s (intercept) > b_fe = pinv(Xtilda'Xtilda)*Xtilda'*Ytilda // (k+1x1) vector of beta hat > k = cols(Z) // (1x1) No of regressors > u = (Ytilda-Xtilda*b_fe) // (NTx1) uhat, fitted residuals > df_r = (N*(T-1)-k) // (1x1) residual d.f. (shouldn't be NT-k-1??) > rss = (u'*u) // (1x1) unrestricted residual sum of squares > mse = rss/df_r // (1x1) mean squared error > vcv = mse*pinv(Xtilda'Xtilda) // (NTxk+1) VCOV matrix > se = sqrt(diagonal(vcv)) // (k+1x1) vector of s.e. of the beta hat > t = b_fe:/se // (k+1x1) vector of t statistics > pt = 2*ttail(df_r,abs(t)) // (k+1x1) vector of pvalues > crit = invttail(df_r,0.025) // (k+1x1) bhat~T(df_r)(b,V(b)) > cil = b_fe-crit*se // (k+1x1) vector of low CI > cih = b_fe+crit*se // (k+1x1) vector of high CI > > rss, df_r, mse > b_fe, se, t, pt, cil, cih > > end > xtset company time > xtreg I F C, fe // to cross check > ********************************************************** > ********************* > ************************************* END > ************************************* > ********************************************************** > ********************* > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ ----- Sunday Times Scottish University of the Year 2011-2013 Top in the UK for student experience Fourth university in the UK and top in Scotland (National Student Survey 2012) We invite research leaders and ambitious early career researchers to join us in leading and driving research in key inter-disciplinary themes. Please see www.hw.ac.uk/researchleaders for further information and how to apply. Heriot-Watt University is a Scottish charity registered under charity number SC000278. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: RE: RE: how many d.f. in the vcv for the within estimator?***From:*"Schaffer, Mark E" <M.E.Schaffer@hw.ac.uk>

**References**:**st: how many d.f. in the vcv for the within estimator?***From:*"Impavido, Gregorio" <GImpavido@imf.org>

**st: RE: how many d.f. in the vcv for the within estimator?***From:*"Schaffer, Mark E" <M.E.Schaffer@hw.ac.uk>

- Prev by Date:
**Re: st: scaling by average** - Next by Date:
**Re: st: Statistics with negative data** - Previous by thread:
**st: RE: how many d.f. in the vcv for the within estimator?** - Next by thread:
**st: RE: RE: RE: how many d.f. in the vcv for the within estimator?** - Index(es):