set.seed(1)
age <- 1:10
country <- sample(c('Slovenia', 'Italy', 'France'), 10, TRUE)
x <- model.matrix(~ age + country)[, -1]
x
w <- qrxcenter(x)
w
# Reproduce w$x
sweep(x, 2, w$xbar) %*% w$R
# Reproduce x from w$x
sweep(w$x %*% w$Ri, 2, w$xbar, FUN='+')
# See also https://hbiostat.org/r/examples/gtrans/gtrans#sec-splinebasis
Run the code above in your browser using DataLab