metest
Tests and contrasts of marginal effects
metest tests linear and nonlinear combinations of the marginal effects reported by mecompare – or of any results posted by margins, post. Rows are referred to by the number in the # column of the mecompare table, so a difference between two effects is metest 2 - 1, a ratio is metest 2 / 1, and a test that several effects are equal is metest 1 = 2 = 3. To refer to an actual number for a mathematical expression, use a leading # – e.g. to divide the 5th marginal effect by 2 use metest 5 / #2.
Sums, differences, ratios, products, and functions such as abs(), exp(), ln(), and min() are all allowed, as are equality tests with =, including several at once. Results can be accumulated into one table with add.
Installation
metest is part of the mecompare package and is installed with it:
net install mecompare, from("https://tdmize.github.io/data") replacemetest requires Stata 16 or later.
Where to start
- Usage and examples runs every form of the command from the help file: single effects, differences, ratios and averages, scaling by a literal value, equality tests, accumulated tables, and use after commands other than
mecompare. - Tests across three or more models compares one effect across four nested models.
- The help file is on the site.
- The
mecomparepages usemetestthroughout, e.g. the effect sizes across predictors example and the interactions pages.
Basic use
sysuse nlsw88, clear(NLSW, 1988 extract)
drop if missing(union)(368 observations deleted)
.
quietly logit union i.collgrad i.south i.smsa c.age c.wage, vce(robust)
estimates store m.
mecompare i.collgrad i.south i.smsa, models(m)Predicting: Pr(union)
Marginal effects (N_m=1878)
| ME # Estimate Robust SE P>|z|
---------------------------------+---------------------------------------
collgrad |
College gra - Not colleg |
m | 1 0.056 0.025 0.026
---------------------------------+---------------------------------------
south |
South - Not south |
m | 2 -0.114 0.020 0.000
---------------------------------+---------------------------------------
smsa |
SMSA - Not SMSA |
m | 3 0.031 0.022 0.161
Is the college gap in union membership the same size as the regional gap? And is the college gap larger than the city/non-city gap?
metest 1 - 2 | estimate se pvalue
---------------------------------+--------------------------------
collgrad - south | 0.170 0.034 0.000
metest 1 - 3 | estimate se pvalue
---------------------------------+--------------------------------
collgrad - smsa | 0.025 0.034 0.465