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: RE: perform regression on minimum number of observations stata


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: RE: perform regression on minimum number of observations stata
Date   Mon, 29 Jul 2013 17:53:11 +0100

This is not difficult.

Evidently, you need to check that all the variables you want to
include in the regression are non-missing. So, extend the -count- to
include that.

count if industry == `i' & year == `y' & !missing(DV, IV_1, IV_2, IV_3)
Nick
[email protected]


On 29 July 2013 17:43, Nahla Betelmal <[email protected]> wrote:
> Thanks Nick and Gergorio, the loop works, but still the number of
> observations run by the regression  less than 15 in some cases. for
> example see this output
>
>
> year = 2011 and industry= 9
>    20
>
>       Source |       SS       df       MS
> Number of obs =      13
> -------------+------------------------------
>   F(  3,     9) =    5.14
>        Model |  .159024959     3   .05300832             Prob > F      =  0.0242
>     Residual |  .092789059     9  .010309895            R-squared     =  0.6315
> -------------+------------------------------
>    Adj R-squared =  0.5087
>        Total |  .251814017    12  .020984501           Root MSE      =  .10154
>
> ---------------------------------------------------------------------------------
> DV |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> ----------------+----------------------------------------------------------------
>  IV_1 |  -.6177928   .3150983    -1.96   0.082    -1.330595     .095009
> IV_2 |   .6304449   .2551211     2.47   0.036     .0533208    1.207569
>  IV_3 |  -.0369961   .0173076    -2.14   0.061    -.0761486    .0021564
>   _cons |  -.0884111   .0439023    -2.01   0.075    -.1877251    .0109029
> ---------------------------------------------------------------------------------
>
> Although the number of year-industry observations here is 20, only 13
> had enough data for the regression. Is there a way to make the number
> of observations regressed  at least 15.
>
> I totally understand if there is no way to do it, your help has been great.
>
> Thanks a million for the help and time.
>
> Nahla
>
>
> On 29 July 2013 17:12, Impavido, Gregorio <[email protected]> wrote:
>> Try changing
>>
>> count if industry == `i' & `year' == `y'
>>
>> with
>>
>> count if industry == `i' & year == `y'
>>
>> -----Original Message-----
>> From: [email protected] [mailto:[email protected]] On Behalf Of Nahla Betelmal
>> Sent: Monday, July 29, 2013 11:46 AM
>> To: [email protected]
>> Subject: Re: st: RE: perform regression on minimum number of observations stata
>>
>> Thanks Nick, but I got an error with the loop
>>
>> year = 1989 and industry= 1
>> ==1989 invalid name
>> r(198);
>>
>> I  added `  ' for industry in the line:  count if industry == `i' & `year' == `y'. I still get the same error but with alteration
>>
>> year = 1989 and industry= 1
>> ==1 invalid name
>> r(198);
>>
>>
>> Could it be that I do not have enough observations at year 1989 and industry 1
>>
>> Thanks again, I highly appreciate your time. Also thanks for the advice about the magic number and regression model.
>>
>> Nahla
>>
>>
>> On 29 July 2013 16:24, Nick Cox <[email protected]> wrote:
>>> Sorry for previous incomplete reply.
>>>
>>> Nick
>>> [email protected]
>>>
>>> On 29 July 2013 16:20, Nick Cox <[email protected]> wrote:
>>>
>>> Gregorio's loop can be modified something like this
>>>
>>> forval y=1989/2012 {
>>>        forval  i= 1/57 {
>>>         di "year = `y' and industry = `i'"
>>>         count if industry == `i' & `year' == `y'
>>>         if r(N) > 15 {
>>>         reg DV IV_1 IN_2 IN_3 if  Industry== `i' & year==`y'
>>>         }
>>> }
>>>
>>> Whatever magic numbers or rules of thumb you read about,
>>>
>>> 1. Don't take them too literally.
>>>
>>> 2. Increase the desirable number according to how many parameters you
>>> are estimating.
>>>
>>> 3. Use sensible models. I don't usually expect pure linear regressions
>>> to work well with firm-year data.
>>>
>>> Nick
>>> [email protected]
>>> *
>>> *   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/
>>
>> *
>> *   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/
*
*   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