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]

Re: st: AW: RE: panel data regression - number of observations


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: AW: RE: panel data regression - number of observations
Date   Sat, 23 Jun 2012 16:57:04 +0100

You don't _have_ to run -xtreg- first. It's just an easy way of
identifying observations with non-missing values on all variables
through e(sample).

Missings are not it seems the main issue here: it's the observations
that aren't there that mean that some of your panels are incomplete.

But no doubt you can work out a protocol for identifying the
observations you want befiore you do any regressions. You might as
well then -drop- the others, at least temporarily.

I don't understand your last question.

By the way, -egen- is a command, not a function. Things like its
-count()- are called -egen- functions.

Nick

On Sat, Jun 23, 2012 at 4:40 PM, Braunfels, Philipp (Stud. SBE /
Alumni) <[email protected]> wrote:
> Hi Nick,
> thank you for your explanation. Can you maybe tell me why I first have to run the <xtreg> before using the egen function? The reason is, that I want to run several regressions with different x variables (y will be the same for all regressions). Since the only variable with potentially missing values is the y variable I would like to ask if I always need to firstly run the regression, secondly run the egen function and thirdly rerun the regression using "count==###", or if it is fine to run the xtreg once, then run the egen function and use the "count" variable for all subsequent regressions that are based on the syme y-variable?
>
> Furthermore, I was wondering whether "sample" is to be replaced by my time variable or if this expression is fixed (tried to look it up on the web and it seemed that it is a fixed expression?!).

> Von: [email protected] [[email protected]] im Auftrag von Nick Cox
> I'll pass on #2.
>
> The answer to #1 is No. This is easy enough to check. For example, from this code
>
> webuse grunfeld
> xtset
> d
> xtreg invest year
> drop if year < 1940 & company == 1
> xtreg invest year
>
> you will see that -xtreg- uses what it can, including incomplete panels.
>
> Indeed incompleteness is, roughly speaking, like beauty, in the mind of the beholder, and not something Stata generally knows or cares about.
>
> You can certainly insist on using what you regard as complete panels. Your syntax will work if and only if a variable called -time- has the value 124 for only those observations you want to include. You can do something like this
>
> xtreg y x1 x2 x3
>
> egen count = total(e(sample)), by(company)
>
> xtreg y x1 x2 x3 if count == 120
>
> or 124 if you prefer.
>
> Nick
> [email protected]
>
> Braunfels, Philipp
>
> I have a large panel dataset, covering 10 years of monthly data. One of my variables is stock return for which I have approximately 3000 companies. However, the return observations are not complete for all 3000 companies (some just have 2 or 5 years of data e.g.). In this respect I would have two questions:
>
> 1) if I run a panel-regression, does stata automatically exclude all companies for which the return data are not complete? (e.g. I regress years 1990-2000 and for 500 companies the data from 1990-1993 are missing. Are these companies completely excluded from the analysis?) If stata does not exclude observations (companies) with an insufficient number of values (returns over time) how can I account for this (maybe using sth. <xtreg y x1 x2 x3 if time==124, fe> - where 124 are monthly observations for the 10 years I cover?
>
> 2) The hausman test predicts that I should use FE. The output gives me three values for R-square (between, within, overall). But when I use the command <estimates table output, stats(r2)> I am given a different R-square than those reported in the <xtreg,fe> output. So where does the <estimates table output, stats(r2)> come from (I also run an <areg> regression and this R-square differs as well!)
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/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/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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