totalme

Stata command for calculating holistic effect size measures for nominal and ordinal outcome models

totalme (Total Marginal Effect) is a companion package to Mize and Han's 2025 Sociological Science article "Inequality and total effect summary measures for nominal and ordinal variables."

totalme calculates total marginal effects (MEs) for independent variables in nominal and ordinal outcome models. For nominal independent variables, totalme calculates total ME inequalities.

Download totalme

To download the totalme command in Stata:

net install totalme, from("https://tdmize.github.io/data/totalme") replace

Help file

To read the help file (also available here):

help totalme

Citation

Please cite the use of the totalme command by citing the corresponding article:

Mize, Trenton D. and Bing Han. 2025. "Inequality and total effect summary measures for nominal and ordinal variables." Sociological Science. 12:115-157.

Basic syntax

totalme can be used for a single model or to compare total MEs across two models.

For a single model, first fit the model and then call totalme with a list of independent variables for which total marginal effects should be calculated.

mlogit ...


totalme varlist


To compare across two models, first fit each individual model and store the estimates for each using est store. E.g.,

ologit     dv iv1 iv2, vce(robust)

est store basemod

 

ologit     dv iv1 iv2 med1 med2, vce(robust)

est store medmod


Note that totalme in the two model case uses the robust variance estimator. Thus, to match its results we strongly recommend you include vce(robust) as an option on the individual models.

Then, use totalme listing the independent variables you want total MEs calculated for and compared across models. Specify the two stored models( ) to compare.

totalme varlist, models(basemod medmod)


If the two models are fit on separate samples—such as in the analysis of groups—the group option is required.

totalme varlist, models(grp1mod grp2mod) group

Examples

This section shows how totalme can be used in a variety of analyses. These examples are replications of those in Mize and Han 2025

Ex 5.2.c - Total MEs for a single model

This example uses a nominal model (a multinomial logit) with multiple independent variables. 

use "https://tdmize.github.io/data/data/cda_gss", clear

drop if missing(healthR, race4, age, woman, parent, married, faminc, degree)

drop if year < 2000  | year > 2021


mlogit healthR i.race4 c.age i.woman i.parent i.married c.faminc i.degree


For continuous independent variables, custom amounts of change can be specified in the amount( ) option.

totalme age married parent, amount(sd)


Model (mod1) is:

     mlogit healthR i.race4 c.age i.woman i.parent i.married c.faminc i.degree

Continuous/Binary IV(s): 

     age married parent


Total ME Estimates(N = 19292)


                         |   Estimate   Std. err.           z       P>|z| 

-------------------------+-----------------------------------------------

age                      |                                               

                    + SD |      0.054       0.003      15.986       0.000 

-------------------------+-----------------------------------------------

married                  |                                               

  Married vs Not Married |      0.031       0.007       4.737       0.000 

-------------------------+-----------------------------------------------

parent                   |                                               

   Parent vs No Children |      0.027       0.009       2.976       0.003 


All three independent variables have significant total effects. For example, the results for age suggest a standard deviation increase in age affects self-rated health by about 5.4 percentage points in total.


Ex 5.2.e - Comparing total MEs across models as with mediation/attenuation

This example fits two models on the same sample and compares the total ME estimate across models, as with tests of mediation/attenuation.

use "https://tdmize.github.io/data/data/cda_gss", clear

drop if missing(healthR, college, race4, age, woman, parent, married, faminc)

drop if year < 2000  | year > 2021


Each model should first be fit and the estimates stored. 

mlogit healthR i.college i.race4 c.age i.woman i.parent i.married, vce(robust)

est store basemod


mlogit healthR i.college i.race4 c.age i.woman i.parent i.married c.faminc, vce(robust)

est store medmod


With two models, specify the name of the stored models in the models( ) option of totalme.

totalme         college, models(basemod medmod)



Model 1 (basemod) is:

     mlogit healthR i.college i.race4 c.age i.woman i.parent i.married, vce(robust)

Model 2 (medmod) is:

     mlogit healthR i.college i.race4 c.age i.woman i.parent i.married c.faminc, vce(robust)

Continuous/Binary IV(s): 

     college


Total ME Estimates(N_basemod = 19292 , N_medmod = 19292)


                         |   Estimate   Std. err.           z       P>|z| 

-------------------------+-----------------------------------------------

college                  |                                               

       Model 1 (basemod) |      0.159       0.006      26.338       0.000 

        Model 2 (medmod) |      0.118       0.007      17.514       0.000 

       Cross-Model Diff. |      0.041       0.003      15.006       0.000 


The total ME for college is significantly attenuated after accounting for the mediator, family income.


Ex 5.3 - Total ME inequalities for nominal/ordinal independent variables

This example combines nominal/ordinal outcomes with ordinal/nominal independent variables. In this case, totalme calculates a total ME inequality for each ordinal/nominal independent variable.

use "https://tdmize.github.io/data/data/cda_gss", clear

drop if missing(healthR, race4, age, woman, parent, married, faminc, degree)

drop if year < 2000  | year > 2021


mlogit healthR i.race4 c.age i.woman i.parent i.married c.faminc i.degree


totalme race4 degree


Model (mod1) is:

     mlogit healthR i.race4 c.age i.woman i.parent i.married c.faminc i.degree

Nominal IV(s):

     race4 degree


Total ME Estimates(N = 19292)


                         |   Estimate   Std. err.           z       P>|z| 

-------------------------+-----------------------------------------------

race4                    |                                               

          total ME Ineq. |      0.047       0.007       6.937       0.000 

-------------------------+-----------------------------------------------

degree                   |                                               

          total ME Ineq. |      0.116       0.006      20.894       0.000 


The results suggest that racial-ethnic groups differ by a total of 4.7 percentage points in terms of their self-rated health ratings, and those with different educational degrees differ by a total 11.6 percentage points.


The total ME inequality reported above from totalme is a single summary measure across all outcome categories. To obtain individual ME inequality estimates for each outcome category, use the meinequality command.

meinequality    race4 degree


Model (mod1) is:

     mlogit healthR i.race4 c.age i.woman i.parent i.married c.faminc i.degree


ME Inequality Estimates (N = 19292)


                         |   Estimate   Std. err.           z       P>|z| 

-------------------------+-----------------------------------------------

race4 ME Ineq.           |                                               

                Pr(Poor) |      0.012       0.004       2.926       0.003 

                Pr(Fair) |      0.033       0.006       5.369       0.000 

                Pr(Good) |      0.010       0.008       1.225       0.221 

           Pr(Excellent) |      0.039       0.006       6.112       0.000 

-------------------------+-----------------------------------------------

degree ME Ineq.          |                                               

                Pr(Poor) |      0.034       0.003      12.102       0.000 

                Pr(Fair) |      0.079       0.005      15.755       0.000 

                Pr(Good) |      0.034       0.006       5.744       0.000 

           Pr(Excellent) |      0.085       0.006      15.223       0.000