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: ttest error message


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: ttest error message
Date   Fri, 15 Mar 2013 19:56:22 +0000

You need the data selected to contain precisely 2 groups of the
variable named in -by()-.

"Precisely 2" means no less than 2, no more than 2.

That is because the -ttest- is designed to compare the means of your
variable, here -Return-, for 2 groups.

It can only find 1 such group.

You can check this by

tab `group_x' if inlist(group_`x',1,10) & Period==`z' & Sector==`j'

and for the combination that produces this error message, only one
distinct value of -`group_x'- will be shown.

Why I don't know: presumably a bug in your code.

Nick

On Fri, Mar 15, 2013 at 7:47 PM, Xixi Lin <[email protected]> wrote:
> Hi,
>
> I am using the following ttest code; however it shows the error
> message:1 group found, 2 required-----what does it mean?
>
> Here is my code:
> foreach x in x1 x2 x3 x4 x5 {
> foreach z of numlist 2/120 {
> foreach j of numlist 10 15 20 25 30 35 40 45 50 55 {
>     qui ttest Return if inlist(group_`x',1,10) & Period==`z' &
> Sector==`j', by(group_`x') unequal
>     display "`x'"   "Period "  "`z'"  "Sector " "`j'"  `r(p_l)'
> `r(p)'  `r(p_u)'
>  }
> }
> }
>
> Any help is appreciated!
>
*
*   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