Why Rank Matters in a GLM
A GLM can fit poorly or fail for several reasons. One structural issue can be identified before interpreting the response: the columns of the design matrix may contain redundant information. When that happens, the model may still calculate fitted values, but it cannot uniquely assign an effect to every listed coefficient. In R, this often appears as one or more aliased coefficients reported as NA.
Rank deficiency is a property of the predictor specification and the observed design matrix. It is not, by itself, evidence of a particular response pattern. For example, complete separation in a logistic GLM is a different issue: the design can have full rank even when the response pattern prevents finite maximum-likelihood estimates.
For a specified GLM family and link, the mean satisfies \(g(\mu_i)=\eta_i\). If \(X\) is rank deficient, different coefficient vectors can produce exactly the same linear predictors for every observed row. The model therefore cannot distinguish the corresponding coefficient effects from these data. This is a question of identifiability, not whether the software can return some numerical fit.
Derivation: Why a Dependent Column Makes Coefficients Non-Unique
Suppose \(X\) is rank deficient. By the definition of rank deficiency, there is a nonzero vector \(c\) such that \(Xc=0\). For any coefficient vector \(\beta\) and any number \(t\),
Thus, moving from \(\beta\) to \(\beta+tc\) leaves every observed linear predictor unchanged. In a GLM, the fitted means are determined by those linear predictors through the inverse link, so the fitted means also remain unchanged. The likelihood, which depends on the observations through the model’s fitted distribution, cannot distinguish these coefficient vectors. The individual coefficients along this redundant direction are not uniquely identifiable.
This argument explains an important distinction: the fitted linear predictors on the observed rows may be unique even though the coefficient vector is not. Full column rank is the usual condition that makes the mapping from coefficients to observed linear predictors one-to-one. It does not guarantee that every other modeling or estimation issue is resolved.
Worked Example: Two Predictors Contain the Same Information
A hypothetical insurer models a claim indicator with a logistic GLM. For three policies, the recorded predictor \(x\) is \(0,1,2\), and a second predictor \(z\) was created as \(z=2x\). The proposed model is \(\operatorname{logit}(\mu_i)=\beta_0+\beta_1x_i+\beta_2z_i\). Diagnose the design matrix and state a repair.
Method: inspect the columns and find a null vector. The design matrix, including the intercept column, is
The third column is twice the second column, so there are three columns but only two independent columns. For a direct check, take \(c=(0,-2,1)^\mathsf{T}\):
Therefore \(\operatorname{rank}(X)=2<3\). The linear predictor is \(\beta_0+\beta_1x+2\beta_2x=\beta_0+(\beta_1+2\beta_2)x\). The observed data can inform the combined slope \(\beta_1+2\beta_2\), but not \(\beta_1\) and \(\beta_2\) separately.
A suitable repair is to remove one of the two predictors, retaining either \(x\) or \(z\) according to its meaning and scale. In R, the model matrix can be checked with X <- model.matrix(~ x + I(2*x), data=d), followed by qr(X)$rank; the rank is 2, not the three columns in the matrix. coef(fit) or summary(fit) may show an aliased coefficient as NA; which term is marked can depend on column ordering and the QR decomposition.
Common mistake avoided: treating the printed coefficient for one predictor as its independently estimated effect. With exact redundancy, the data identify only the combined slope, so assigning separate interpretations to the two terms is not justified.
Factor Coding Can Create Redundant Columns
Categorical predictors are represented by columns in the design matrix. With an intercept and standard treatment contrasts, a factor with \(K\) observed levels is represented by \(K-1\) indicator columns. One level is the reference category; the intercept represents its linear predictor, and the remaining columns represent differences from it on the link scale.
A common source of rank deficiency is including an intercept and all \(K\) level indicators. For each row, exactly one indicator equals 1, so the intercept column equals the sum of all \(K\) indicator columns. This is an exact dependency. The issue is not that factor variables are unsuitable for GLMs; it is that the chosen columns contain redundant information.
Worked Example: Full Factor Indicators in a Poisson GLM
A hypothetical portfolio has one observed count for each of three regions: 2 in North, 5 in Central, and 8 in South. Assume independent Poisson counts with a log link and unit exposure. A proposed model uses an intercept and separate indicators for all three regions. Show the dependency and give the usual treatment-coded parameterization.
Method: compare the columns and reparameterize. In the row order North, Central, South, the proposed matrix is
There are four columns, but the intercept column is the sum of the three indicator columns. Equivalently, \(Xc=0\) for \(c=(-1,1,1,1)^\mathsf{T}\). Hence the rank is 3, not 4. The predictors are not separately identifiable in this coding.
The observed Poisson maximum-likelihood means in this saturated three-group illustration are the counts \(2,5,8\). Their log means are \(\log(2),\log(5),\log(8)\). With North as the reference and treatment coding, the three parameters are uniquely expressed as
Rounded to four decimal places, these are \(0.6931\), \(0.9163\), and \(1.3863\). Checking the fitted means gives \(\exp(0.6931)\approx2\), \(\exp(0.6931+0.9163)\approx5\), and \(\exp(0.6931+1.3863)\approx8\); the small differences are from rounding.
Common mistake avoided: adding a separate coefficient for every factor level while keeping the intercept, then interpreting all coefficients as independently estimated. Under the stated parameterization, use a reference level and \(K-1\) indicators. A no-intercept parameterization can also be used when appropriate, but its coefficients have a different interpretation.
Unused Levels and R Diagnostics
A factor can retain levels that do not occur in the analysis data. Under treatment contrasts, an unobserved non-reference level produces a column of zeros in the model matrix. That column contributes no information and makes the matrix rank deficient. This can happen after filtering rows, splitting data, or preparing a factor with an explicit set of possible levels.
Worked Example: A Factor Level Has No Observations
A hypothetical logistic model uses a three-level channel factor, with levels A, B, and C, and uses A as the treatment reference. In the available data, channel A has 2 successes out of 10 and B has 5 successes out of 10; there are no observations for C. Diagnose the design and interpret what can be estimated.
Method: audit the realized model matrix. With the two observed rows, the intercept, B indicator, and C indicator give
The C column is all zero, so \(\operatorname{rank}(X)=2<3\). The data provide no information about a channel C effect. Under a grouped-binomial logistic model, the estimated probabilities for A and B are \(2/10=0.2\) and \(5/10=0.5\). Their fitted logits are
Thus the fitted intercept for A is approximately \(-1.3863\), and the B contrast is approximately \(0-(-1.3863)=1.3863\). There is no estimable C contrast from these observations. If C is not intended to be part of this analysis, remove unused levels with droplevels(d) before fitting. If C is important, obtain data for C rather than treating a software output as an estimate.
Common mistake avoided: interpreting an aliased coefficient for an empty level as an estimated zero effect. An all-zero column means the effect is unsupported by the observed design, not that the effect has been measured as zero.
Practical Diagnosis and Repair
For a fitted GLM in R, examine the matrix actually used by the model, rather than relying only on the printed formula. For example, X <- model.matrix(fit) constructs the design matrix, qr(X)$rank reports its QR rank, and ncol(X) gives its number of columns. If the rank is smaller, inspect the column names, contrasts, factor levels, and predictor construction. fit$rank and is.na(coef(fit)) can help identify rank and aliased coefficients in the fitted object.
Build the model matrix after all filtering and transformations. Compare its QR rank with its number of columns.
Look for duplicate or proportional predictors, indicators that sum to the intercept, zero columns from unused levels, and interactions unsupported by observed combinations.
Remove a redundant predictor, use an appropriate factor contrast, or collect the missing design information. Choose the repair based on the question being modeled.
Check that the revised matrix has the intended rank, that the coefficients are estimable, and that the resulting comparisons match the modeling objective.
Changing a factor’s reference level changes the coefficient representation and interpretation, but it does not create information that is absent from the data. Similarly, simply deleting a term to make R stop printing NA is not a sound repair unless the remaining model still expresses the intended effects. A sound specification removes redundancy while preserving the comparisons that matter.
Check Your Understanding
For each problem, diagnose the design or interpret the proposed repair. Answers are included for checking.
- A model matrix has an intercept and predictors \(x\) and \(w=3x\), with observed \(x\) values \(0,1,2\). What is its rank, and what slope combination is identified? (Answer: Rank 2; the identified slope is \(\beta_x+3\beta_w\).)
- A factor has four observed levels, and a model includes an intercept plus all four level indicators. How many independent columns are there, and how many indicators are used with standard treatment coding? (Answer: 4 independent columns; treatment coding uses 3 indicators plus the intercept.)
- A two-level factor A/B uses treatment coding with A as reference, but the analyzed data contain only A rows. What happens to the B-indicator column, and what can be concluded about a B effect? (Answer: The B column is all zero; a B effect is not estimable from these data.)
- A rank-deficient GLM reports one coefficient as NA but returns fitted probabilities for every observed row. Is that necessarily contradictory? Explain. (Answer: No. The coefficient vector may be non-unique while the fitted linear predictors and probabilities on observed rows are unique.)
- For a factor with three levels, a coefficient vector is altered by adding \(t(-1,1,1,1)^\mathsf{T}\) to an intercept-plus-three-indicator parameterization. What happens to each row’s linear predictor? (Answer: It is unchanged, because the design matrix multiplied by \((-1,1,1,1)^\mathsf{T}\) is zero.)