I am using the -contrast- command to generate p-values for trend test in Stata. I've reviewed the documentation on contrast but cannot find information on what statistical test is being used behind the scenes and thus how to interpret the p-values associated with linear versus quadratic versus joint.
Background on my code: my model outcome is no_dm_dmg_v2
, and my exposure is mtdnaquint
, which is the quintiles of a biomarker and input as an indicator (i.
) with reference Q5 (b5).
logistic no_dm_dmg_v2 ib5.mtdnaquint_new mtdnacnage male black
Output
Logistic regression Number of obs = 9,124
LR chi2(7) = 407.12
Prob > chi2 = 0.0000
Log likelihood = -3550.0948 Pseudo R2 = 0.0542
------------------------------------------------------------------------------
no_dm_dmg_v2 | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mtdnaquint |
1 | .5521241 .0525977 -6.24 0.000 .4580866 .665466
2 | .6958681 .0682745 -3.70 0.000 .5741323 .843416
3 | .8617032 .0858859 -1.49 0.135 .7087915 1.047604
4 | .9143168 .0917151 -0.89 0.372 .7511257 1.112963
|
mtdnacnage | .952226 .0051524 -9.05 0.000 .9421808 .9623783
male | .8150846 .0503448 -3.31 0.001 .7221495 .9199798
black | .3192515 .0208311 -17.50 0.000 .2809261 .3628054
_cons | 193.5929 63.4069 16.08 0.000 101.8821 367.8586
------------------------------------------------------------------------------
contrast p.mtdnaquint_new, noeffects
Contrasts of marginal linear predictions
Margins : asbalanced
------------------------------------------------
| df chi2 P>chi2
-------------+----------------------------------
mtdnaquint |
(linear) | 1 46.41 0.0000
(quadratic) | 1 2.93 0.0372
(cubic) | 1 0.05 0.8261
(quartic) | 1 0.30 0.5814
Joint | 4 51.46 0.0000
------------------------------------------------
When I use the reference coding (r.
), I understand that the p-values for each level are that level compared to the reference, and are the same as the Wald p-values in the regression output (since I used i.mtdnaquint_new
).
contrast r.mtdnaquint_new, noeffects
Contrasts of marginal linear predictions
Margins : asbalanced
------------------------------------------------
| df chi2 P>chi2
-------------+----------------------------------
mtdnaquint |
(1 vs 5) | 1 38.88 0.0000
(2 vs 5) | 1 13.66 0.0002
(3 vs 5) | 1 2.23 0.1353
(4 vs 5) | 1 0.80 0.3718
Joint | 4 51.46 0.0000
------------------------------------------------
Is the joint p-value in the contrast r. output the same as doing a test that all of the beta's = 0? Is it testing a linear trend?
Best Answer
Here are examples showing this in Stata for OLS, but the intuition carries over to the logit index function coefficients.
Both of these are doing Wald tests. Let's do the second one first. You are testing that the linear index function inside the logit is the same for all groups each relative to the base value, so that is the same test that all the coefficients are zero (excluding the constant). The joint tests that all these differences are the same:
The polynomial contrast is more involved. Trend analysis partitions the sum of squares for the model into portions due to linear trend, quadratic trend, cubic trend, and so on. If there are $K$ groups, it is possible to look at up to $K - 1$ trends. Here's an example with $K=6$ on the same data as above.
Trend analysis is performed using coefficients of orthogonal polynomials. For 6 levels, they look like:
One way to perform trend analysis is to use the coefficients of orthogonal polynomials to weight the group sums to compute sums of squares for each of the trends. An alternative is to apply the coefficients of orthogonal polynomials directly to the observations and to analyze using regression. This creates a set of variables such that the "effects" of all the preceding variable have been removed from each variable: