Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

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


From   "Impavido, Gregorio" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: RE: RE: RE: how many d.f. in the vcv for the within estimator?
Date   Fri, 14 Dec 2012 08:50:58 -0500

Mark. Thank you. Your hand-wavey approach made the trick: you should not get uneasy.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Schaffer, Mark E
Sent: Wednesday, December 12, 2012 10:50 AM
To: [email protected]
Subject: st: RE: RE: RE: how many d.f. in the vcv for the within estimator?

Gregorio,

One way to think about it is via the underlying asymptotics in a large-sample setting.

If you regard the number of individual effects N as fixed and
T->infnity, then you would be right to say that (ignoring the constant)
you could indeed use (N*T-k) = T*[N-k/T] as the degrees of freedom.  If it's T that is going off to infinity, then asymptotically there's no difference between this and the textbook N*(T-1)-k = T*[N-1/T-k/T].  In both cases the 1/T terms disappear as T gets large, and you're left with N*T.  Or, put another way, the ratio (N*T-k)/[N*(T-1)-k] goes to 1 as
T->infinity.

But if it's N that is going off to infinity, then the number of individual effects is also going off to infinity.  In that case the two expressions are not equivalent asymptotically, because N*(T-1)-k will always be lagging behind N*T-k, even asymptotically.  That is, the ratio (N*T-k)/[N*(T-1)-k] goes to T/(T-1) as N->infinity.  If T is small, this ratio will be very different from 1.  So you need to incorporate this in how the error variance is calculated.

I hope this makes sense.  I get uneasy when I make these hand-wavey asymptotic arguments....

HTH,
Mark

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Impavido, 
> Gregorio
> Sent: Wednesday, December 12, 2012 1:49 PM
> To: [email protected]
> Subject: st: RE: RE: how many d.f. in the vcv for the within 
> estimator?
> 
> 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: [email protected]
> [mailto:[email protected]] On Behalf Of Schaffer, 
> Mark E
> Sent: Tuesday, December 11, 2012 7:55 PM
> To: [email protected]
> 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: [email protected] [mailto:owner- 
> > [email protected]] On Behalf Of Impavido, Gregorio
> > Sent: 12 December 2012 00:41
> > To: [email protected]
> > 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
> ([email protected])
> > **********************************************************
> > *********************
> > ************************************ 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/
> 


-----
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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index