Announcement

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

  • Reporting marginal effects from a logit regression with mfx, but getting the unsuitable predict() expression error

    Hello! I am attempting to report the marginal effects after running a logit regression using mfx. I have tried using this post and this post to resolve the issue, but am still stuck. The code I am currently running is:

    Code:
    mlogit g1ind scaledcash_beg scaledncfbut scaleddeltad scaleddeltae i.calendaryear i.ff48rec 
    mfx, predict(p outcome(1)) varlist(scaledcash_beg)
    The error I am getting is

    predict() expression p outcome(1) unsuitable for marginal-effect calculation

    I have tried running just logit instead of mlogit and replacing the predict() with p, p1, outcome(1), and outcome(2).

    Here is the dataex:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float g1ind double scaledcash_beg float scaledncfbut double(scaleddeltad scaleddeltae) float calendaryear double ff48rec
    0  .004087293858794919   .004408856    .01808884139825981                      0 1992 41
    0  .010615883101345387    .02770707 -.0025420449170483945  -.0029442191875067975 1993 41
    0  .006175527384561455   .002720678    .06839362345988372  -.0001807471429627743 1994 41
    0  .043277956832189574   .014800475   .012214277846685792  -.0004238241871914105 1995 41
    0  .052809442620486875    .04361024 -.0038326593301300565    -.00364478387277074 1996 41
    0   .07675301361665975    -.0411765 -.0033664804520310795   -.018453976969071317 1997 41
    0   .09763323665367535    .00361315    .09285967854013717   .0031005468443155385 1998 41
    0  .025683049515404316  -.022005755   .003061624704164734   -.011271193138858774 1999 41
    0  .011353783906527394  -.018066565 -.0006660886558496071   -.014491556913422236 2000 41
    0   .00167476835295102    .04423731 -.0006464254964250915  -.0002847511059409067 2001 41
    0   .04246010535652128   .011283156 -.0071567866406649396                      0 2004 41
    0  .057818218730790696    .05459334    -.0338436074282524                      0 2005 41
    0   .06874615899375879   -.08595077     .1920489463693102                      0 2006 41
    1   .12437233032869204   -.07092226   .010130575724418918                      0 2007 41
    1   .07803898905335446   -.03028298    .16792661897861905  -.0031452755769070455 2008 41
    0   .08255078890757044   .024628617  -.027119477830559256   .0004397911909604188 2009 41
    0   .08167266903857755     .0978331   .027559852516604224    .001667500295823409 2010 41
    0   .05287660172067138     -.023787   -.04218935912519437 -.00034509360830676307 2011 41
    0   .03371021296252275  -.009696846     .1877947581977629 -.00037682093433983254 2012 41
    0   .03084276067302074    .05893244   -.04212869702088627   -.006148512538183402 2013 41
    0   .03523796153306191    .05253349   -.04160232111937854   .0019186672282278064 2014 41
    0   .03610561056105611  -.017854545    -.0466006600660066    -.01240924092409241 2016 41
    0  .021635115456625754   -.01049735 -.0069343318771236395   -.013729977116704806 2017 41
    0  .006847948939565189    .04534468   .016488265407885117  -.0009972741174124062 2018 41
    0  .027284055879845216   .035330445  -.016396668197022363  -.0011805601101856106 2019 41
    0  .027089375164777222   -.04013574                     0  -.0019773266543633003 2020 41
    0   .21281823304206168    .06005419                     0  .00030066150182537555 2021 41
    0   .04101843125454263    .04472438  -.016829821461581445   -.017443053822529753 2022 41
    0 .0013498692314182065   .031216666   -.03546218960038247                      0 1992 20
    0  .002001143510577473    -.3658345     .3859109967600533                      0 1993 20
    0  .008016000750035158     -.316045     .3305936215760114                      0 1994 20
    0   .12181543802014007     .0826223   -.12385048286799719    .008140179391428536 1992 36
    0   .08507987140827872    .04763751   -.05534095912145604     .02390742725180884 1993 36
    0   .05828875859655639    .13991064 -.0010712219786184094    .014861419583366066 1994 36
    0   .14793656105460673    .04349931 -.0011951572229326767       .569704557134491 1995 36
    0   .39676883225777476  .0034105415  -.008146961401337255    .019458211262005413 1996 36
    0    .2383316097897277   -.04722394  -.006866857882447822    .012401709234941759 1997 36
    0    .1172633218092861  .0022064163 -.0002819600065363456    .021244191250054736 1998 36
    1   .22120780847417357     .1179792   -.13139912977755427     .03475815151158669 1999 36
    0    .1757912717806388  -.036354765  -.019431651110384335      .1657370365476473 2000 36
    0    .5757575757575758  -.016323576   -.00825044336494718   .0028529570514303337 2004 36
    0    .3512359078495904   .005858162                     0    .009523142637070233 2005 36
    1    .2901628664495114   .016025575                     0    .006254071661237785 2006 36
    0    .3336849944147946    .05334257                     0   .0029787762194365144 2007 36
    0   .39855611789222983   .069192156 -.0005209883894016076                      0 2010 36
    0  .026515408059600405    .06650149  -.062030138841855736 .000050795800880460546 1992 36
    0   .20768916373458435   -.05260847  -.006468351281231119  -.0076856096954188435 1993 36
    0   .14209828515604556   .017011281    -.0608656211293896   .0006803551802941226 1994 36
    0   .10848693612811022  -.035174116  -.050771373080728495   .0011176664590127887 1995 36
    0  .011689526184538652    .03801033  -.041030236907730666                      0 1993  9
    0   .02447761194029851     .1869331   -.25164148913968315                      0 1995  9
    0  .044444444444444446   -.12262652    .42671755725190846     .21713316369804922 1996  9
    0    .1546549511304176     .2533638    -.2303781222233192   .0005923585743903643 1997  9
    0    .0905634626632872   -.04863188   .016913628387599928    .012331838565022422 1998  9
    0  .025808612003226837    .01884797   .050460433187719755  -.0010350233641303517 1991 13
    0   .01161552824457264   .020789856    .03783685867959758   .0016916088398405932 1992 13
    0  .014981545447697754  -.019643493    .01728701940149143   .0005837664503771612 1993 13
    0  .019895936219583084   -.05624717    .15052858918436116   .0018761726078799247 1994 13
    0   .02618863515881672   .011373058  -.006957411390503075    .001862175385519265 1995 13
    0  .028905904201445058  -.007815426   .011145887315646301   .0022556402820810492 1996 13
    0  .025992530245008614   -.00772631  -.028119992109643353      .0943239969547136 1997 13
    0   .01740400654569165    .03654546   .009991042404560443      .3169611911386275 1998 13
    0  .015858102220618394     .0294785    .12957237913340436     .08691591047114429 1999 13
    0  .015216338322419169  -.034704834   -.09697086702532005     .42199719719443646 2000 13
    0   .04528652196456237    .02714219     .3887415511957949   .0034431690816456423 2001 13
    0  .006231778303670951   .024510873   -.03613669912401967   .0028117060696031143 2002 13
    0  .010393029982707308    .04109874  -.037882402726428926    .003941793459426607 2003 13
    0  .025167992691266097    .05808485   -.05267148305819683                      0 2004 13
    0   .05250513763061159    .10849767    -.1458198800104998    .005668111557697663 2005 13
    0    .4928042242650071   .031701665   -.18508750210816036    -.17782186951569653 2006 13
    0   .12204296842561625   -.02324097    .31574599429057665    .006336014770733327 2007 13
    0   .09749297721201274    .04391367   .032748299571881315   -.011000823406998695 1993  7
    0    .1339367338319496    .15285307   -.10804539938305598     .25907640162308676 1994  7
    0   .30216687014738386  -.007301998  -.004233196881558263   .0004767832491481738 1995  7
    0    .2688421423564696   -.07725912   -.19839549251753313   .0016814962635544302 1996  7
    0  .022328723487872782     -.254124     .3849414013213143  .00028958048062086055 1997  7
    0    .1638481783846328    .04899967 -.0004632304930354362   .0026104479593054356 2004  7
    0   .23109131403118038   -.07576837    .06164810690423162                      0 1998 41
    0  .030321846217530788   .024179516  -.006364483079788885                      0 1994 40
    0   .03987478189469362    .06101804  -.062455095966334806                      0 1995 40
    0   .04607281652689712    .11954328    -.1089179791368378                      0 1996 40
    0   .08835439332585257     .0803655   -.03161438259257452   -.026345318827145435 1997 40
    0   .11637580683719818   .027731834 -.0014821898159215873   -.042218503466411664 1998 40
    0   .09294713715643635  -.062606074    .07756804017396762   -.037932116755593416 1999 40
    0   .07347993763846722  -.029326957   .002871912693854107   .0027488307212603594 2000 40
    0   .14660111883370064    .04393011   -.04631293439566028     .02135955246651975 2006 40
    0   .17783496311545718    .04106616   -.07963630125235889     .02014067593069137 2007 40
    0   .18452856914395377 -.0045292126    .06524868063329602    -.08786639555870325 2015 40
    0     .143529897758959   .011298424    .08001652380460601    -.09294640090880925 2016 40
    0   .13646292467917462   -.02328117   .014159222998010687    -.03149744509888053 2017 40
    0   .10475523387034011  .0021393034  -.011421122266324227   -.016285314032220406 2018 40
    0   .08111587982832617  -.001536626 -.0037966325519973587   -.018108286563222185 2019 40
    0    .2342636564080198   -.00798412  -.046831785272536855  -.0003665551586743474 2022 40
    0 .0028582080278364607     .2249945   -.04871380638747359                      0 1994 21
    1   .12064777327935222  -.018595804  -.023134759976865243   .0031231925968768074 1996 21
    0   .15520052168242582    .23168804    .09172915987392674                      0 1997 21
    0   .10615285438005873   -.08582066   -.01654609268677029                      0 1998 21
    0     .068562197092084   -.04432475     .9570917486114969                      0 1999 21
    0  .029805352798053526    .07816825   -.15657649921282382     .07830613997423787 2001 21
    0  .007803687760410672   .035869762   -.04498054832991873                      0 2005 21
    end
    I know I can figure out how to manually calculate, but at this point I want to figure out what I'm doing wrong and how to get mfx to work. Appreciate any help!

  • #2
    -mfx- is outmoded and has been replaced by the -margins- command.

    Code:
    margins, predict(outcome(1)) dydx(scaledcash_beg)
    will do what you were trying to get with -mfx-.

    Comment


    • #3
      This worked, thanks very much Clyde! I must have gotten turned around somewhere because I was thinking mfx replaced margins. Appreciate the help

      Comment

      Working...
      X