Why Coding Choices Matter
A propensity model must represent how the probability of treatment varies across the measured pretreatment covariates. For a categorical covariate, the model needs a numerical representation of its categories. That representation affects how coefficients are interpreted and, if it imposes restrictions, which treatment probabilities the model can express.
The key distinction is between changing the coordinates used to describe the same model and changing the model’s assumptions. A different full-rank contrast for a nominal covariate can describe the same set of fitted probabilities. Treating ordinal categories as a single numerical score, by contrast, usually imposes a trend restriction and can change the probabilities the model is able to fit.
The model concerns treatment assignment conditional on covariates; it does not include the outcome as a predictor. For the usual logistic likelihood, the treatment observations are modeled as conditionally independent Bernoulli variables with probabilities specified by the model. The fitted probabilities are useful for propensity-score methods only insofar as the covariates and model support the intended adjustment. Coding alone does not establish causal identification: the causal assumptions required for propensity-score adjustment remain substantive assumptions about the treatment and covariates.
Nominal Covariates and Reference Categories
A nominal variable has categories without a meaningful order, such as insurance type or referral channel. Assigning the labels 1, 2, and 3 and treating them as a single quantitative predictor would imply an ordering and a particular numerical spacing that the category labels do not justify. The usual approach is indicator coding.
For a variable with \(K\) levels, choose one level as the reference. Create one indicator for each of the other \(K-1\) levels; an indicator equals 1 when the individual is in that level and 0 otherwise. In a model with other covariates \(Z\), the treatment linear predictor can be written as:
Here level 1 is the reference category. Holding \(Z\) fixed, \(\beta_k\) is the difference in log odds of treatment between category \(k\) and the reference. The corresponding conditional odds ratio is \(\exp(\beta_k)\). Neither the coefficient nor that odds ratio is a difference in treatment probabilities; probabilities depend on the full linear predictor.
Worked Example: Interpreting Nominal-Category Coefficients
Suppose a hypothetical model uses insurance type, with “none” as the reference, and includes no other covariates. The fitted model is \(\operatorname{logit}\{e(X)\}=-1.1+0.5I(\text{public})+1.0I(\text{private})\). Calculate the fitted score for each category and interpret the coefficients.
For “none,” both indicators are 0, so the linear predictor is \(-1.1\). Thus \(e=1/(1+\exp(1.1))\approx 0.2497\). For “public,” the predictor is \(-1.1+0.5=-0.6\), giving \(e=1/(1+\exp(0.6))\approx 0.3543\). For “private,” it is \(-1.1+1.0=-0.1\), giving \(e=1/(1+\exp(0.1))\approx 0.4750\).
The public-versus-none conditional odds ratio is \(\exp(0.5)\approx 1.649\), and the private-versus-none odds ratio is \(\exp(1.0)\approx 2.718\). These describe model-implied odds comparisons, not probability ratios. For example, the public score exceeds the none score by about \(0.1046\), not by \(0.5\); the coefficient is on the log-odds scale.
The reference category is a parameterization choice, not a claim that it is more important or a control group in the causal sense. Changing the reference changes the intercept and coefficient values but, when all category effects remain unrestricted, does not change the fitted probabilities. A reference level should be clearly identified so coefficient interpretations are unambiguous.
Ordinal Covariates: Indicators or Structured Trends?
An ordinal variable has ordered categories, such as low, moderate, and high severity. Ordering is information, but it does not by itself establish that adjacent categories should have equal effects on treatment log odds. One safe flexible representation uses indicators and treats the category effects as unrestricted. A more parsimonious representation assigns scores, such as 0, 1, and 2, and uses one coefficient for that score. The latter assumes a constant change in log odds for each one-step increase.
Structured contrasts can also express particular comparisons, such as adjacent-category differences or a linear trend and curvature component. If the contrast columns span all \(K-1\) category degrees of freedom, they are a re-expression of the unrestricted categorical effect. If fewer terms are used, or the model imposes a relationship among contrasts, the model is restricted.
Worked Example: Checking an Ordinal Linear-Trend Assumption
Consider hypothetical severity categories low, moderate, and high. An unrestricted indicator model, with low as the reference, has linear predictor \(-1.2+0.4I(\text{moderate})+0.9I(\text{high})\). Compare its scores with a model that assigns scores 0, 1, and 2 and uses a single slope of \(0.45\).
Under the indicator model, the linear predictors are \(-1.2\), \(-1.2+0.4=-0.8\), and \(-1.2+0.9=-0.3\). Applying \(e=1/(1+\exp(-\eta))\), the fitted scores are approximately \(0.2315\), \(0.3100\), and \(0.4256\), respectively.
In the one-score model, the predictors are \(-1.2+0.45(0)=-1.2\), \(-1.2+0.45(1)=-0.75\), and \(-1.2+0.45(2)=-0.3\). The scores are approximately \(0.2315\), \(0.3208\), and \(0.4256\). The models agree at the endpoints here, but differ in the moderate category.
The indicator model’s adjacent log-odds changes are \(0.4\) and \(0.9-0.4=0.5\). The one-score model requires both changes to equal \(0.45\). Its use may be reasonable when that trend restriction is scientifically defensible, but ordering alone does not justify it. The numerical coefficients here are stipulated hypothetical model values, not estimates from an observed data set.
When Alternative Contrasts Preserve the Model
For a nominal covariate, reference-indicator coding is not the only full-rank option. Effect coding and other full-rank contrasts can represent the same unrestricted category effects. To see why, collect the model’s design columns in a matrix \(D\). If a new set of columns is \(D^*=DM\), where \(M\) is an invertible matrix, then choosing coefficients \(\theta^*=M^{-1}\theta\) gives:
Thus every observation has the same linear predictor, and the logistic transformation gives the same fitted propensity score. The coefficients have different interpretations because they refer to different contrasts, but the model’s fitted values are unchanged. This equivalence requires the same model space: an invertible reparameterization of all category effects, not dropping a contrast or imposing a trend.
With effect coding, category effects are expressed relative to a sum-to-zero constraint rather than relative to one reference category. The intercept is then interpreted under that coding constraint. It is important to read the actual contrast definition rather than applying a reference-category interpretation automatically.
A full set of \(K\) indicators together with an intercept is redundant, because the indicators sum to 1 for every observation. This exact linear dependence prevents unique estimation of all coefficients. Use \(K-1\) indicators with an intercept, or use a correctly specified contrast coding that avoids redundancy.
Worked Example: Calculating Scores With Two Categorical Covariates
Suppose a hypothetical fitted propensity model is \(\operatorname{logit}\{e(X)\}=-1.4+0.6I(\text{public insurance})-0.3I(\text{private insurance})+0.8I(\text{high severity})\). “No insurance” and “low severity” are the reference levels. Calculate scores for a person with public insurance and high severity, and for a person with private insurance and low severity.
For public insurance and high severity, the indicators are 1 and 1 for those terms and 0 for private insurance. The predictor is \(-1.4+0.6+0.8=0\). Therefore \(e=1/(1+\exp(0))=0.5000\).
For private insurance and low severity, only the private indicator is 1. The predictor is \(-1.4-0.3=-1.7\), so \(e=1/(1+\exp(1.7))\approx 0.1545\). These scores are model-implied probabilities of treatment conditional on the specified categories. The calculation assumes the stated model, including its additive form; it does not establish that the model is adequate for a real application.
Checking the Coding and Its Consequences
Coding errors can silently alter the propensity model. Before interpreting fitted scores, verify that every observation belongs to the intended category, exactly one category is represented for each categorical variable, and the reference level has all its indicators set to zero. Check that the category labels and indicator definitions agree with the fitted model’s documentation.
Then inspect whether the chosen parameterization expresses the intended assumptions. For nominal variables, indicator coding avoids inventing a numerical order. For ordinal variables, compare the restricted trend specification with a more flexible categorical representation when the restriction is uncertain and the data support that comparison. This is a modeling decision, not a matter of choosing whichever coding yields more convenient coefficients.
In propensity analysis, treatment prediction is not the objective by itself. After estimating scores, examine whether covariates are balanced across treatment groups under the planned matching, weighting, or other adjustment procedure. A category can have an apparently modest coefficient while still showing important imbalance after adjustment; conversely, a large treatment-model coefficient does not by itself prove a balance failure. Review balance by category as well as in aggregate, so a contrast does not conceal imbalance in a particular level.
Also check observed category-by-treatment counts and the range of fitted probabilities. A category absent from one treatment group can make comparisons depend heavily on model structure and may signal limited empirical support. The detailed consequences of sparse cells and separation require separate treatment; here the practical point is to identify and report them rather than assume that a coding change resolves them. Alternative full-rank contrasts cannot create information that the data do not contain.
Common Mistakes and Limitations
- Using category numbers as if they were measurements. Coding nominal categories as 1, 2, and 3 imposes a numerical order and a linear log-odds pattern. Use indicators unless that structure is justified.
- Calling a coefficient a probability difference. A logistic coefficient is a conditional log-odds contrast. Transform the full linear predictor to obtain a fitted probability.
- Assuming every coding change alters the fitted scores. A full-rank change of contrasts can leave all fitted scores exactly unchanged. Restrictions, omitted terms, or redundant columns can change estimation or make coefficients unidentified.
- Assuming ordinal order implies equal steps. A one-score ordinal term imposes equal adjacent changes in log odds. The categories being ordered does not establish that assumption.
- Treating a reference category as substantively privileged. It is a comparison anchor for interpretation. A different reference changes coefficient coordinates, not the underlying unrestricted fitted model.
Even a correctly coded model can be inadequate if its covariate set or functional form fails to represent treatment assignment well enough for the intended adjustment. Conversely, a flexible model can be difficult to estimate when categories have little data. Coding is one necessary part of specification, not a substitute for checking model behavior and covariate balance or for assessing the assumptions behind causal interpretation.
Check Your Understanding
Answer each question, then compare with the solutions below.
- A nominal variable has four levels and the logistic model includes an intercept. How many indicators are needed using reference-category coding, and what does one indicator coefficient represent?
- For an ordinal variable with categories 0, 1, and 2, what restriction does a single linear score term impose on the category log odds?
- Why can replacing reference indicators with a different full-rank contrast leave all fitted propensity scores unchanged?
- A coefficient is \(0.7\) in a logistic propensity model. Is the treatment probability \(0.7\) higher for that category than for the reference? Explain.
Solutions. (1) Use three indicators. A coefficient is the conditional log-odds difference between its category and the reference, holding other model covariates fixed. (2) Each one-step increase must change the log odds by the same amount: the change from 0 to 1 equals the change from 1 to 2. (3) An invertible change of design-matrix coordinates can be offset by the corresponding coefficient transformation, leaving every linear predictor and hence every logistic fitted value unchanged. (4) No. The coefficient is a log-odds difference; the odds ratio is \(\exp(0.7)\), and the probability difference depends on the other terms and baseline linear predictor.