Announcement

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

  • how to compute marginal effects for a variable with its quadratic term

    Hi stata experts,

    I'm having a problem with the computation of the composite marginal effects of a variable with its quadratic term after mlogit

    Let's say the dept. variable is categorical with four options (0,1,2,3)

    I have Age and Age2 in the model and need to compute only 1 composite marginal effect of Age instead of two for Age and Age2 for each outcome (0,1,2,3) like the below figure.
    How do I accomplish that post estimation. The command mfx2 yields useful marginal effects of both Age and Age2 for each outcome but I want to compute the composite marginal effect of Age only (just 1). How do I do that?

    The below command works just fine to estimate the model
    mlogit loantype age age2 gender edu farmexp logincome logfarmsize..., base (0) vce(robust)

    The result after mfx2 shows

    Click image for larger version

Name:	mlogit result.png
Views:	1
Size:	70.4 KB
ID:	1516028

  • #2
    This is best solved by creating the square term with factor variables, and than use margins to create the marginal effects. So there is no need for any user-written/community contributed programs.

    Code:
    sysuse auto, clear
    replace price = price / 1000
    label var price "price in 1000s dollars"
    replace rep78 = 3 if rep78 < 3
    
    ologit rep78 c.price##c.price
    
    margins, dydx(*)
    Now the result could easily be misleading: by adding a square term the effect of that variable will differ from person to person, to the extend that the effect could easily change sign. To summarize that with a single number is problematic. Instead, I would present the results in a graph:

    Code:
    margins, at(price=(3/16))
    marginsplot
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment

    Working...
    X