Announcement

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

  • #16
    By default, mcp wants to plot the predicted values for EVERY value of the continuous variable; but it also has a limit of 70 unique values. So, the default works fine for something like years of education, but doesn't work for things like Joe's age variable. And, of course, sometimes continuous variables have literally thousands of unique values in a data set.

    When you can't plot a prediction for every value, you have to go to plan B. Something like Joe's going in 2 year intervals is usually fine. Dividing a variable into 20 equally sized intervals may also be fine. But it may not work well if you have extreme outliers, e.g. if income ranges between $0 and $1 billion you probably don't want your plotting values to be $50 million, $100 million, $150 million, etc.

    This is not unique to mcp -- you'd have the same issues with picking and plotting points in margins and marginsplot. But, you mostly need to think about what points you want to plot values for if you can't afford the luxury of plotting points for every observed value. You could use some sort of formula (e.g. divide up into 20 intervals, or do it for every other year or every 5 years) but you could also just specify values yourself.

    Under most conditions, I would think 20 points would be plenty. But, if you have a bunch of spline functions, where the slope keeps on changing, maybe you need more points than that. If you weren't careful, I suppose you could totally miss a range of the variable values where the slope differed from values right before it and right after it.

    One last sidelight: Joe earlier gave the code

    Code:
    gen educrange=_n in 1/21    // Make a dummy set of education variables for mcp
    You could also do

    Code:
    range educrange 1 21 21
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

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

    Comment


    • #17
      Rich W -- you have been incredibly helpful -- with 3 coauthors to coordinate and a complete draft of the paper due to discussants tomorrow, I am going to prevail a bit more on your helpful nature. Tried your code just for me and got two errors.

      range vrange 0 200000 50
      (39202 missing values generated)

      . mkspline vr1 29835.05 vr2 40425.994 vr3 51286.80078125 vr4 77691.59375 vr5 119319.865625 vr6=totincfam

      . mcp totincfam (incp1-incp6), var1(vrange (vr1-vr6)) show
      too many macros

      I imagine the second is a consequence of the first. I'll try figuring it out myself and if I do so before I see any response, I'll cancel this request.

      Comment


      • #18
        On your mkspline command, I think you want to use vrange at the end, not totincfam. mcp can be a little confusing, but it would be even more confusing if you tried to write the margins command yourself.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

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

        Comment


        • #19
          Looks like you made that mistake because I made that mistake in telling you what I thought your code should be! Since I can't actually test the code with your data make sure the results seem plausible. Maybe run a model with the splines only and see if it looks right. If it actually winds up working right, Joe deserves a great deal of credit for noting that mcp could be used here. mcp isn't essential but it hopefully reduces the error rate that would come with trying to write the margins command yourself.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          Stata Version: 17.0 MP (2 processor)

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

          Comment


          • #20
            I find Nicola Orsini's -xblc- command very useful for visualizing splines!

            Comment


            • #21
              xblc does look very interesting. Two cautions though:

              The "at" values must be values that actually appear in the data set. That would mostly seem to be a minor nuisance.

              More critically, the help says "Covariates other than the one specified with the covname() option are fixed at zero." So, if, in addition to your spline variables, your model has x1, x2, x3, etc. their values are apparently fixed at zero in the calculations. This could make your chart very deceptive. In the example in their help file, they centered the value of age, so if you do that it is like using the -atmeans- option in margins. That may be fine, but just remember it is not the same as what mcp is doing (although if you wanted mcp to be doing things like that you could probably add the atmeans option or tell it to fix other covariates at zero).

              So, my initial reaction is that xblc seems simpler than mcp, but you would need to be careful that it is actually generating what you want. If you have to center a bunch of variables or spend time looking up specific values that actually occur in the data, the convenience will drop. Plus, you'll be plugging in means or zeros for other covariates, rather than using asobserved like mcp does,

              There is a whole Stata Journal article on xblc (available for free) at

              http://www.stata-journal.com/sjpdf.h...iclenum=st0215

              I will definitely be taking a look at it. Again, my initial bias is to prefer mcp for these sorts of things, but maybe once I understand xblc better I will feel differently.

              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              Stata Version: 17.0 MP (2 processor)

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

              Comment


              • #22
                Success. Thanks Richard for everything -- I don't fully understand or I would have caught the error myself. It looks plausible. It matches the numerical estimates. Thanks Joe for suggesting mcp. Pavel -- thanks for the suggestion. When things are leisurely, I will read the Stata Journal article (on order thru interlibrary loan) and check out xblc. A round of virtual beer, and real beer if I meet you all someday.
                Attached Files

                Comment

                Working...
                X