Announcement

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

  • Extract a matrix (e.g. r(table) after adjust command

    Hello Statalister,

    I'm running regressions followed by the adjust command. Now I would like to have the adjusted means (and CI) in a matrix (e.g. r(table) ). so I can use these values and put them in other matrices etc.

    Code:
    regress ...
    adjust if e(sample), by(sex) ci
    
    matrix k=r(table) // This only generates a void [1,1] and not a matrix based on the adjust commands with means and CI
    Thank you for your kind help

    Dusan

  • #2
    If you are using the current version of Stata (13), then instead of using -adjust- you should move up to the -margins- command (and use factor variables: -help fvvarlist-). -margins- returns its results as r(table), and will give you what you seek.

    The older command -adjust- does not return anything in r().

    Comment


    • #3
      Ok, thanks a lot Clyde.

      Comment


      • #4
        I just have a small issue with the margins command.

        I actually want to fix for covariables :
        age (continuous)
        sex (factorial)
        center (factorial : 3 levels)

        in my model I also have the occupation, and I would like to have the adjusted means : by(occupation)

        Code:
        qreg al2score c.age i.sex i.center i.occupation
        
        margins i.sex i.center c.age if e(sample), by(occupation) // continuous??
        but the margins command returns the interactions between occupation and sex and occupation and center, which I don't want , I just want to fix for the covariables : mean age, center (~0.3), sex (~0.5), and to have adjusted means by occupation.

        Sorry for bothering

        Thanks for your help dusan

        P.S. There is also a problem with age because it's continuous and non-integer

        Comment


        • #5
          Depending on what you want to do with the variables age, sex, and center, you probably want one of the following:

          Code:
          margins occupation // OTHER VARIABLES RETAIN THEIR ORIGINAL VALUES
          
          OR
          
          margins occupation, atmeans // OTHER VARIABLES SET TO THEIR SAMPLE MEANS
          
          OR
          
          margins occupation, at(...fill in your own values for other variables here..  see -at()- option in -help margins-)

          Comment


          • #6
            Clyde,

            Code:
            margins occupation, atmeans
            was just what I needed.

            Thank you very much

            Cheers

            Dusan

            Comment

            Working...
            X