Announcement

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

  • interpretation of interaction of two logged variables in log-log model

    Dear Stata Listers,

    Could one advise on how to claculate the marginal effect of one logged variable conditional on another logged variable? Model is as follows: ln(y)=b0+ b1ln(X1) + b2ln(X2) +b3ln(X3) + b5ln(X4) +b6ln(X3)##ln(X4) . The last term is an interaciton between ln(X3) and ln(X4). Any advice on how to calculate the marginal effect of X3 on y given X4 would be appreciated.

    Thank you,
    Julia

  • #2
    The last term is not correctly written to be the interaction of two continuous variables. You need to designate them as continuous with the c. prefix.

    Also, in this model there is no such thing as the marginal effect of X3 on y given X4: your model is one that gives constant elasticity, but not constant marginal effects. So the marginal effect of x3 on y must be specified given both X3 itself and X4 (and, actually, also X1 and X2).

    If you specify the values of all the x variables, then it is easy enough to calculate the elasticity using the -margins- command, and then from that you can calculate the marginal effect from the equation marginal effect = (y/x3) * elasticity where y and x3 are replaced by their actual values with the specification of all four x variables..

    Code:
    regress lny lnx1 lnx2 c.lnx3##c.lnx4
    margins, dydx(lnx3) at(lnx4 = (insert lnx4 of interest here) x3 = (insert lnx3 of interest here) ...) // SPECIFY ALL FOUR X's
    Now, without specifying all four of the X variables, but only some of them, it is possible to get an average elasticity conditional on that partial specification. But I don't think there is then any way to transform that into a corresponding average marginal effect.

    Comment


    • #3
      Dear Clyde,

      Many thanks for your response. Yes, in the specification above I use prefix c. for the interactions, just wanted to show the functional form of the model, but used stata syntax ## for the easy way to denote the interaciton term. I appreciate your reply, but still feel a bit confused, and would be grateful if you could possibly clarify for me further. Starting from the beginning:

      I am estimating the log-log model looking at how two different types of innovation (R&D and embedded technology at a sectoral level) determine productivity gap.

      ln(y)=b0+b1ln(x1) +b2ln(x2) +b3ln(x3)+ b4ln(x4) +b5ln(x5) + b6[ln(x4)*ln(x5)]....

      The marginal effect of X4 depends on the level of X5 and is equal to [b4+b5*lnX5)].

      The 'margins, dydx' command in stata gives me a unit change effect of R&D conditional on the mean of ln(embedded technology) (instead of Ln of the mean of the level variable) which I believe is incorrect.

      While I could surely recalculate manually the elasticity coefficients of R&D on TFP gap conditional on different values of embedded technology, I am not sure how to recalculate in this case standard errors and confidence intervals, as these would change too. If you have any suggestions, or you could direct me to appropriate sources, it would be extremely helpful. Or if I am wrong about calculating elasticity coefficients as per above, please let me know. I am also attaching an extract from the output should this be of any further clarification for you.

      Best Wishes,
      Julia







      Attached Files

      Comment


      • #4
        The 'margins, dydx' command in stata gives me a unit change effect of R&D conditional on the mean of ln(embedded technology) (instead of Ln of the mean of the level variable) which I believe is incorrect.
        That depends on exactly how you wrote the -margins- command. You may or may not be correct in your interpretation of it, and as you do not show the command itself, there is no way to tell you. Perhaps the command is included in your pdf attachment, but I do not risk downloading attachments from strangers. Please post the -margins- command and the regression command (not your model, but the actual Stata command) and its output. Use code delimiters to make it all readable. If you are not familiar with code delimiters, read Forum FAQ #12, or watch David Benson's video on code delimiters and -dataex- https://youtu.be/bXfaRCAOPbI.

        Comment


        • #5
          Thanks. Yes, all the commands and output were attached with the previous message. Here is the syntax for the regression itself. Please note, our DV (gap) is in natural log.

          areg gap_TFP_firm_max $Spike_Covariates L1_Spike_adj4O_26 c.L1_LNown_rnd_perc_prod##c.L1_LNembedded_sector_E U_net i.year if sample_computing==1 [aweight= eurostat_enterprises_nomissing], absorb(fn) r

          here is the syntax for marginal effects for R&D & embedded technology:
          margins, dydx(L1_LNown_rnd_perc_prod L1_LNembedded_sector_EU_gross) level(95)

          I get the same results when specifying either of the two conditional terms at its averages:
          margins, dydx(L1_LNown_rnd_perc_prod) at(L1_LNembedded_sector_EU_gross)
          margins, dydx(L1_LNembedded_sector_EU_gross) at(L1_LNown_rnd_perc_prod)

          All in all, STATA takes the mean of Ln of R&D or Ln embedded technology instead of their means at levels which I believe is incorrect.

          Best,
          Julia

          Comment


          • #6
            Yes, the first -margins- command you have written gives you the marginal effect of L1_LNown_md_perc_prod conditional on L1_LNembedded_sector_EU_gross being at its mean value. Analogous interpretation applies to the second command.

            If you want the average marginal effect, rather than the marginal effect at the mean, then just omit the -at()- option from the -margins- command.

            Comment


            • #7
              Thank you Clyde. First of all, when I omit -at- at the end, this gives me the same effect as calculating it at the mean of LN_X. Second, I still struggle to interpret these marginal effects. It is hard to interpret the results as 1% change in X1 conditional on the mean of LN_X2 gives us Z-% change in Y. Sata does not understand that the model is log-log. The correct calculation of the marginal effect of X1 on Y conditional on X2, should be Beta1 of LN_X1+Beta2 of LN_X1xLN_X2 multiplied by LN of the mean of X2 rather than mean of LN_X2. As I said I don't have any problems with re-calculating the elasticities manually, but I struggle to reculculate SE and CIs for these elasticities. If you have any suggestions, please let me know.

              Comment


              • #8
                Oh, I see what you want. So you have to do something like this. Run your regression. Then

                Code:
                summ x2, meanonly
                local ln_mean_x2 = log(r(mean))
                margins, dydx(ln_x1) at(ln_x2 = `ln_mean_x2')

                Comment


                • #9
                  Dear Clyde, apologies for not responding sooner. I am currently travelling on academic business. Many thanks for your advice. I will be working on this next week once back in the office. I will let you know how it goes. Thank you, Julia

                  Comment


                  • #10
                    No problem. I sometimes "disappear" from Statalist for one or more days due to travel or the press of other business, too.

                    Comment


                    • #11
                      Dear Clyde, I am back from my travelling, and trying to replicate your code. I am ecountering the following problem once doing this:

                      . margins, dydx(L1_LNown_rnd_perc_prod) at(L1_LNembedded_sector_EU_gross = `ln_mean_L1_embedded_EU')
                      '' found where number expected
                      r(7);

                      Would you be able to advise me further of how to resolve it?

                      Thanks,
                      Julia

                      Comment

                      Working...
                      X