Announcement

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

  • specifying values for margins command

    Dear All,

    I use the margins command with -eyex- to estimate some elasticities.
    margins, eyex(income) atmeans
    My objective is to caclulate the elasticities for different population groups. However, when I use the income in the regression to specify the population groups for which I want to estimate the elasticity, then the margins command take into account the means for this specific population group.

    In terms of comparability of elasticity, I think it's much better to estimate the margins at the means for the whole sample for all population groups (because otherwise the elasticity estimates are driven by the sample means of each population group and may be misleading). Is it possible using margins command (i.e. to specify all the values of the means for all variables for which I have controlled, in order to be the means of the whole sample)?

    Best wishes,

    Nikos

  • #2
    I don't understand the question. Your -margins- command doesn't specify any groups in the first place. Do you have some other -margins- command in mind? Perhaps you should show the regression command and the margins commands you are worried about.

    Comment


    • #3
      Thank you for your response Clyde.


      Below, I would like to estimate the elasticity with respect to income for the whole sample, and across different income quintiles. But, "atmeans" gives the means of the whole sample for the first elasticity, and the means of the observations of the first quintile for the second elasticity and so on.

      In terms of comparability, I thought that the values in which I should evaluate the elasticity should be the same (e.g. the means for the whole sample). Am I correct?


      quietly glm edu `independent' [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans
      quietly glm edu `independent' if income_quintile==1 [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans
      quietly glm edu `independent' if income_quintile==2 [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans
      quietly glm edu `independent' if income_quintile==3 [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans
      quietly glm edu `independent' if income_quintile==4 [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans
      quietly glm edu `independent' if income_quintile==5 [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans


      Similarly, I want to estimate the elasticity for different time period, and again the means are quite different.

      quietly glm edu `independent' [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans
      quietly glm edu `independent' if period==0 [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans
      quietly glm edu `independent' if period==1 [pweight = weightr], family(gamma) link(log) vce(robust)
      margins, eyex(income) atmeans

      Comment


      • #4
        Well, now that I understand what you want to do, I think it's misguided in the first place. But if I were to do it, I would calculate the means of each of the variables in local macro independent, store those means in local macros, and then use those macros to create a long -at()- option for -margins- that specifies each of those variables at its total-sample mean. That would do what you want.

        But, as I say, I wouldn't do it--it sounds like you are creating statistics that are comparable to each other at the extensive of being partially extraneous to what they purport to represent. I would just run the regression once, in the entire sample, including interactions between income quintile and the independent variables, and then run -margins income_quintile, atmeans-. So it would look something like this

        Code:
        glm edu i.income_quintile##(`independent') [pweight = weightr], family(gamma) link(log) vce(robust)
        margins income_quintile, eyex(`independent') atmeans
        Note that in order for the regression to properly represent the model you have, any continuous variables in the local macro `independent' would have to be prefixed with c. so that Stata doesn't try to convert them into indicator ("dummy") variables.

        Comment


        • #5
          Thank you. Really grateful for your detailed answer. Given that I am interested in income elasticity, I was thinking that such an interaction will include both income quintiles, and income as a continuous variable.

          One last question: Can I use this command to estimate the elasticities for each group, instead of running separate regressions for each income group?

          glm edu `independent' [pweight = weightr], family(gamma) link(log) vce(robust)
          margins, eyex(income) atmeans over(income_quintile) vce(unconditional)

          And do you think that for this case (estimating the income elasticity) it's better to estimate marginal effects at means, or average marginal effects?

          Again, thank you very much for your help on this.

          Best regards,

          Nikos

          Comment


          • #6
            Can I use this command to estimate the elasticities for each group, instead of running separate regressions for each income group?
            I don't understand why you're asking this. The code in #4 is a single regression and it does not contain any -if income_quintile ==...- clauses.

            margins, eyex(income) atmeans over(income_quintile) vce(unconditional)
            No! The -over()- option is wrong here: it gets you right back to the problem you first raised in #1! Use the code the way I wrote it in #4. If you want the -vce(unconditional)- option, fine. But otherwise don't tamper with it since you don't seem to fully understand the various options in -margins-.

            And do you think that for this case (estimating the income elasticity) it's better to estimate marginal effects at means, or average marginal effects?
            I have no idea. That really depends on what kind of inferences you want to make from the statistic. If you use -atmeans- then your inferences would apply only to a (probably hypothetical) person who takes on mean values of every variable in your model. Such people will be rare, if they even exist at all. if you use average marginal effects then they are generalizable to people drawn from a population whose variables are distributed similarly to your data set.

            Comment


            • #7
              Thank you Clyde. By saying
              Can I use this command to estimate the elasticities for each group, instead of running separate regressions for each income group?
              I refer to the following code (compared to the code in #3):
              Code:
              glm edu `independent' [pweight = weightr], family(gamma) link(log) vce(robust)
              margins, eyex(income) atmeans over(income_quintile) vce(unconditional)
              code

              So, you think option -over- is totally wrong, or it just estimates the elasticity at the means of variables in each income quintile?

              Comment


              • #8
                -over- would estimate elasticity at the means of variables in each income quintile.

                Comment


                • #9
                  Hi again,

                  your advice was really useful. Given that I want to calculate the income elasticity for different quintiles and across two different periods, I was thinking to estimate a model with a triple interaction, in order to check potential differences across quintiles and periods. So I would like to estimate income elasticity for different income quintiles before and after a specific year.

                  Code:
                  glm edu period##i.income_quintile##c.income `independent' [pweight = weightr], family(gamma) link(log) vce(robust)
                  margins period#i.income_quintile, eyex(income) atmeans
                  Otherwise, I could use two different interaction terms (and c.income from the second interaction is omitted):

                  Code:
                  glm edu period##c.income i.income_quintile##c.income `independent' [pweight = weightr], family(gamma) link(log) vce(robust)
                  margins period#i.income_quintile, eyex(income) atmeans

                  I would really appreciate if I had your advice on this.

                  Thank you in advance,

                  Nikos


                  Comment


                  • #10
                    The two models answer different questions. So it depends on which question you are trying to ask.

                    The three-way interaction model contemplates that each possible combination of period and income quintile separately modifies the effect of income on edu. In particular, the extent to which period modifies the effect of income on edu depends on income quintile.

                    In the model with two two-way interactions, there is an effect modification by period and another effect modification by quintile, but they are independent of each other: the effect modification by period is the same across all quintiles and the effect modification by quintile is the same in all periods.

                    You need to figure out which of these situations better describes what you are trying to find out.

                    Comment


                    • #11
                      Many thanks Clyde!

                      Comment

                      Working...
                      X