Understanding Polynomial Models: Correctly Interpreting Random Coefficients in Regression Analysis

The issue with the code is that when using a random polynomial (such as poly), the resulting coefficients have a different interpretation than when using an orthogonal polynomial.

In the provided code, the line random = ~ poly(age, 2) uses an orthogonal polynomial, which is the default. However, in the corrected version raw = TRUE, we are specifying that we want to use raw polynomials instead of orthogonal ones.

When using raw polynomials, the coefficients have a different interpretation than when using orthogonal polynomials. In particular, the coefficients no longer represent the true effects of the random terms, but rather the deviations from the population mean.

To fix the issue, we need to add raw = TRUE when specifying the polynomial, like this:

random = ~ poly(age, 2, raw = TRUE) | id

Additionally, when adding the coefficients, we should use the correct interpretation of the random term. In this case, we want to add the first three coefficients (corresponding to age ^ 0, age ^ 1, and age ^ 2) separately:

(coef_1001[1, ]) <- coef_1001[1, ] + random_quadratic[1, 1]
(coef_1001[2, ]) <- coef_1001[2, ] + random_quadratic[1, 2]
(coef_1001[3, ]) <- coef_1001[3, ] + random_quadratic[1, 3]

With these changes, the code should produce the correct results.


Last modified on 2023-10-04