Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Statalist post regarding 'test' command - query


From   Jamie Fagg <j.fagg@qmul.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: Statalist post regarding 'test' command - query
Date   Mon, 07 May 2007 08:58:16 -0400

Dear Austin,

Firstly, thanks for your help with my question and sorry for
the delay in acknowledging your help.

I tried to run your .do file but unfortunately there seems to be a
problem in terms of generating the interaction dummy variables (that is
what the foreach loops are doing aren't they?). I am running Stata
Intercooled version 9 on XP if that is relevant, see below for output:

 webuse nlswork, clear
(National Longitudinal Survey.  Young Women 14-26 years of age in 1968)

 qui xi: logistic coll i.occ*i.race

 testparm _IoccX*

  ( 1)  _IoccXrac_2_2 = 0
  ( 2)  _IoccXrac_2_3 = 0
  ( 3)  _IoccXrac_3_2 = 0
  ( 4)  _IoccXrac_3_3 = 0
  ( 5)  _IoccXrac_4_2 = 0
  ( 6)  _IoccXrac_4_3 = 0
  ( 7)  _IoccXrac_5_2 = 0
  ( 8)  _IoccXrac_6_2 = 0
  ( 9)  _IoccXrac_6_3 = 0
  (10)  _IoccXrac_7_2 = 0
  (11)  _IoccXrac_8_2 = 0
  (12)  _IoccXrac_10_2 = 0
  (13)  _IoccXrac_10_3 = 0
  (14)  _IoccXrac_11_2 = 0
  (15)  _IoccXrac_13_2 = 0
  (16)  _IoccXrac_13_3 = 0

            chi2( 16) =  117.15
          Prob > chi2 =    0.0000

 foreach i of local o {
   2. qui g byte o_`i'=(occ==`i') if !mi(occ)
   3. foreach j of local r {
   4.  qui g byte o_`i'r_`j'=(occ==`i' & race==`j') if !mi(race,occ)
   5. }
   6. }

 foreach j of local r {
   2. qui g byte  r_`j'=(race==`j') if !mi(race)
   3. }

 qui logistic coll o_* r_*
variable o_* not found


With best wishes,

Jamie Fagg

PhD Student, Queen Mary, University of London


Jamie Fagg --
First note that
xi: logistic depvar i.x1 i.x2 i.x1*i.x2, robust cluster(i)
is the same as
xi: logistic depvar i.x1*i.x2, robust cluster(i)
and you can test the joint significance of interactions with
testparm _Ix1X*

That said, the -xi- command is a convenience command that is often
more of an annoyance.  If you ask -xi- to make a bunch of indicator
variables for you, then you have to figure out what those variables
will be called so you can -test- subsets of them.  Much easier in the
long run to learn to make the indicator variables for yourself.  If x1
and x2 each have a lot of categories, this can be tedious until you
learn how to use -levelsof- and -foreach-, at which point it is
trivial.  Also note that since you have several sets of variables that
sum to one, some will need to be dropped, and it may matter which are
included in the model for the outcome of the test.

A cheap illustration:

webuse nlswork, clear
xi: logistic coll i.occ*i.race
testparm _IoccX*
foreach i of local o {
g byte o_`i'=(occ==`i') if !mi(occ)
foreach j of local r {
  qui g byte o_`i'r_`j'=(occ==`i' & race==`j') if !mi(race,occ)
}
}
foreach j of local r {
qui g byte  r_`j'=(race==`j') if !mi(race)
}
qui logistic coll o_* r_*
testparm o_*r_*
drop o_1 r_1
qui logistic coll o_* r_*
testparm o_*r_*


On 4/11/07, Jamie Fagg <j.fagg@qmul.ac.uk> wrote:

     I want to compare two models:
     xi: logistic depvar i.x1 i.x2, robust cluster(i)
     xi: logistic depvar i.x1 i.x2 i.x1*i.x2, robust cluster(i)

     I gather from the list and manuals that I can't use lrtest to compare
     these models and that I should consider -test-. My first question is
     therefore, can -test- compare the fit of two models like this, in the
     way that lrtest can for models with no robust option specified.

     If so, my second question relates to the syntax because the manuals
seem
     to suggest that there are 4 different ways of writing the syntax and I
     can't decipher which is appropriate to carry out the operation as
     described above. If this has been covered in the list already (I'm
     afraid I couldn't find it if it has) could someone refer me to the note
     in question. And if it hasn't, any help would be much appreciated.

*

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index