# How to translate orthogonal polynomial parameters back to the original metric

I am trying to work out how the parameters from a lmer model using orthogonal polynomials can be translated back to their original metric. Chapter 5.3.3 in Hedeker, Donald, and Robert D. Gibbons. Longitudinal data analysis. Vol. 451. John Wiley & Sons, 2006. provides an example of this can be done, (see here https://drive.google.com/file/d/0B85dnVgjSYw3RTA3MGthN1VXZms/view?usp=sharing) for mixed effects models but I am unsure how to implement this in R.

Any help would be appreciated.

Thanks

Some example data.

library(nlme)
library(lme4)
df <- Orthodont
mlm.ortho <- lmer(distance ~ poly(age, 2, raw = FALSE)  + (poly(age, 2, raw = FALSE) | Subject), data = df, REML = FALSE)
summary(mlm.ortho)


After discussing the problem with a statistician, we worked out that the following code can be used to translate coefficients that are orthogonal polynomials back into their raw values

#Construct our T matrix
agedf <- cbind(rep(1, 108), df$age ,df$age^2)
colnames(agedf) <- c('baseline', 't', 't2')
agemat <- as.matrix(agedf) #the t matrix

tmat <- t(agemat)%*%agemat  #1. Compute T'T
choltmat <- chol(tmat)      #2. Obtain the Cholesy factor S of T'T
sinver <- solve(choltmat)   #3. Obtain the inverse (S')-1

#multiply (S')-1 by the coefficents to obtain the translated scores
sinver%*%as.matrix(c(24.0231, 15.3413, 1.2028))

#compare to the results of the LMER model with raw = TRUE
summary(lmer(distance ~ poly(age, 2, raw = TRUE)  + (poly(age, 2, raw = TRUE) | Subject), data = df, REML = FALSE))

#example from Hedecker ch5
mat <- matrix(c(1,1,1,1,1,1,0,1,2,3,4,5,0,1,4,9,16,25), 6,3) # T matrix
tmat <- t(mat)%*%mat      #1. Compute T'T
choltmat <- chol(tmat)    #2. Obtain the Cholesy factor S of T'T
sinver <- solve(choltmat) #3. Obtain the inverse (S')-1
sinver%*%matrix(c(43.24, -9.94, 0.31)) #obtain the translated scores