Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How i can see only interesting for me models.

    For example i have 100 columns named var...
    I wrote code for them like this:
    Code:
    xtmixed Y X1 X2 time c.X1#c.time c.X2#c.time var128 c.var128#c.X1  c.var128#c.X2 c.var128#c.X1#c.time c.var128#c.X2#c.time || company: ,cov(un) variance mle  
    xtmrho
    test var128
    
    xtmixed Y X1 X2 time c.X1#c.time c.X2#c.time var129 c.var129#c.X1  c.var129#c.X2 c.var129#c.X1#c.time c.var129#c.X2#c.time || company: ,cov(un) variance mle  
    xtmrho
    test var129
    
    xtmixed Y X1 X2 time c.X1#c.time c.X2#c.time var135 c.var135#c.X1  c.var135#c.X2 c.var135#c.X1#c.time c.var135#c.X2#c.time || company: ,cov(un) variance mle  
    xtmrho
    test var135
    and like this 100+ more strings

    Click image for larger version

Name:	12133331.png
Views:	1
Size:	58.7 KB
ID:	1479205



    I want to see only that models, which p<0.050 , ICC>0.5 , Prob> chi2 ≠ 0

    Should i check it manually, or i can check all 100 models automatically?

  • #2
    First, your model is mis-specified and should not be used. You have a three way interaction between var128, X1 (also X2) and time, but you do not have a c.var128#c.time term. That is not a valid model. Any interaction must be accompanied by all included subinteractions (and all main effects). Since it is easy to leave one out, it is better to specify interaction models using the ## operator and let Stata fill in everything.

    Next, assuming you are using current Stata, the command has been renamed -mixed-. The older name -xtmixed- still works, but some day it may not, and you should get in the habit of using the current terminology. As well as having changed its name, StataCorp also changed the defaults, so you don't need to specify variance or mle options: those are now the defaults. Also, -xtmrho- is an outdated command, and the calculation of the ICC is now best done with -estat icc-. (In fact, -xtmrho- apparently does not produce any output after -mixed-.)

    When you say you only want to "see" models for which p<0.050 , ICC>0.5 , Prob> chi2 ≠ 0, your meaning is unclear. First there are many p's in the output you show, and there are several Prob > chi2's as well. I'll assume that the first is the overall p-value of the -mixed- model, and that the last refers to the result of the -test- command. I'll also assume that when you say you only want to "see" those models, you mean that you would like to suppress all of the output from the others.

    Code:
    foreach v of varlist var* {
        quietly {
            mixed Y c.`v'##(c.X1 c.X2)##c.time || company:, cov(un)
            local mixed_p = e(p)
            estat icc
            local icc = r(icc2)
            test `v'
            local test_p = r(p)
        }
        if `mixed_p' < 0.05 & `icc' > 0.5 & `test_p' != 0 {
            mixed
        }
    }
    By the way, the condition Prob chi2 != 0 after -test `v'- is an unusual one. First, it is unusual in an interaction model like this to even run -test `v'- by itself, because you are then testing only the effect of `v' conditional on time = 0, X1 = 0 and X2 = 0. If that's what you want, fine, but don't do this if what you are interested in is testing for a significant contribution of `v' in the model. Second testing for any p-value != 0 is odd, because a p-value of 0 is, in principle, an infinitely rare occurrence. Due to finite precision, we sometimes see it in these outputs because if the p-value is sufficiently low, Stata simply truncates it to 0. But that is a very extreme criterion to use and it is seldom met in practice. So I'm wondering if you meant to do something else. But I'm not sure what that might be.

    Note: Code not tested as you provide no example data. Beware of typos or other errors.

    Added: By "current" Stata, I mean here version 13 or later.
    Last edited by Clyde Schechter; 16 Jan 2019, 18:31.

    Comment


    • #3
      This mas production of models is potentially dangerous. If you use the .05 level and run 100 models, then just by chance you would expect 5 models to show up as statistically significant. You might want to consider using more stringent criteria, e.g. alpha = .01 or even .001.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://academicweb.nd.edu/~rwilliam/

      Comment


      • #4
        Thank you very much! I found 2 model.

        Which test should i use to show the significance of var439 in this model.

        Click image for larger version

Name:	01.png
Views:	2
Size:	66.5 KB
ID:	1479222

        Attached Files

        Comment


        • #5
          Code:
          test var439 var439#X1 var439#X2 var439#time var439#X1#time var439#X2#time
          It's an omnibus test of all of the terms in the model that include var439. That becomes a test of the significance of the effect of var439 in this interaction model.

          Comment

          Working...
          X