Announcement

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

  • Margins for multi equation regression with transformed predictions

    Hello everyone,

    Question:

    Using the -margins- command, is it possible to combine the selection of an equation (from a multi-equation regression) and the transformation of the dependent variable of this equation at the same time?

    Problem:

    I'm trying to estimate the marginal effects of my model after running a two-equation regression. The first equation estimates the cost frontier and the second equation estimates the inefficiency distribution, which is used in the cost frontier function. For that purpose I’m using the user-written -sfpanel- command.

    However, the coefficients of the inefficiency distribution cannot really be interpreted in a meaningful way, because the inefficiency is not bound between 0 and 1. A method to archive more meaningful results would be to transform the inefficiency (u) into efficiency (q) using the transformation formula: q = exp(-u).

    Now I want to estimate the marginal effects from my second equation (inefficiency) but let the marginal effects be in the metric of efficiency (q).

    I know that the -margins- command supports transforming the estimates using the -expression- option. If I’m correct, I could type:

    Code:
    margins, dydx(*) expression(exp((-1)*predict(xb))
    As far as I know, however, this would estimate the marginal effects of my first equation (cost frontier) rather than the second one (inefficiency/efficiency).

    I also know that I can specify the equation (called “Mu” here) to estimate the marginal effects from by typing:

    Code:
    margins , dydx(*) expression(equation(Mu))
    That would neglect the desired transformation into Efficiency though.

    So my question are:

    1. Is it possible to combine the transformation and the selection of the equation with the -margins- command?

    2. Is it correct what I typed for the transformation considering that the transformation from inefficiency (u) to efficiency is q = exp(-u).


    Thank you very much in advance.

    Best regards,
    Sebastian

  • #2
    I did a little experimenting with a public Stata test dataset, so that you can replicate my Problem. Thus, it might be better to understand what I’m trying to do.

    Here is the code:

    Code:
    ssc install sfpanel
    ssc install sfcross
    webuse xtfrontier1, clear
    
    ******* With -sfpanel- (multi-equation)
    
    sfpanel lnwidgets lnmachines, cost model(tfe) dist(tnormal) emean( workers )
    
    * 1. Margins without transformation
    margins, dydx(*) predict(equation(Mu)) // Problem: uses independent varibales of frontier equation (eq 1) not of inefficiency equation (eq 2), and since -lnmachine- from the frontier is not in the inefficiency regression there's no result
    cap noisily: margins, dydx(workers machines) predict(equation(Mu)) // explicitly demand -workers- to be used does not work
    
    * 2. Margins with transformation but for the wrong equation (equation 1 instead of 2)
    margins, dydx(*) expression(exp(-predict(xb))) // This is not quite what I'm trying to do because it refers to the wrong equation
    
    * 3. Margins with transformation and second equation // This might be actually what I'm trying to do
    margins, dydx(*) expression(exp(-predict(equation(Mu)))) // but the problem is the same as in (1.) - it uses the wrong independent variables
    
    
    ******* With normal regressions
    
    gen widgets = exp(lnwidgets)
    
    gen trans_widgets = exp(-widgets)
    sum trans_widgets widgets
    
    reg widgets machines
    reg trans_widgets machines
    
    reg widgets machines
    margins, dydx(*) expression(exp(-predict(xb)))
    * Marginal effect is -.0091653 but by using the transformed dependent variable directly the marginal effect is -.0409893
    * This raises the question if it is actually appropriate to do what I'm trying to accomplish.
    Last edited by Sebastian Geiger; 29 Jan 2019, 09:34.

    Comment

    Working...
    X