Centering when using splines in R I am having trouble understanding why centering seems to only work with simple linear models and not with splines for example. I am using centering to report the estimated group differences at different $x$, but also statistical values (ignoring multiple comparisons for the moment).
set.seed(1)

# simulate data
N <- 10
x <- rep(seq(0.2,1,0.2),N)
group <- factor(rep(c('I','II'),each=length(x)/N))
y <- -x^2 + 2*x*as.numeric(group) + rnorm(length(x),mean=0,sd=0.1)
d <- data.frame(group,x,y)

# fit a linear model with x-group interaction
l <- lm(y~x*group,data=d)
d$lmfit <- fitted(l)
coef(l)['groupII'] # group difference at x==0
#     groupII 
#  -0.1097071 

library(ggplot2)
ggplot(d,aes(x,y,colour=group)) + geom_point() + geom_line(aes(x,lmfit,colour=group))

The plot confirms the reported small group difference groupII of 0.05 at $x=0$ if we were to extrapolate back to 0.
Now let us centre the data at $x=1$ and estimate the group difference there.
# center data at x==1 and refit
l <- lm(y~I(x-1)*group,data=d)
coef(l)['groupII'] # group difference at x==1
#   groupII 
#  2.08525 

In agreement with the plot the difference is about 2.
Now let us fit a spline model.    
# fit data with splines
library(splines)
l <- lm(y~ns(x,2)*group,data=d)
d$lmsplinefit <- fitted(l)
    coef(l)['groupII'] # group difference at x==0.2
    #     groupII 
    #  0.2987893 
    # compare to: d$lmsplinefit[6] - d$lmsplinefit[1]

ggplot(d,aes(x,y,colour=group)) + geom_point() + geom_line(aes(x,lmsplinefit,colour=group))

Interestingly, the spline fit reports the group difference at the first $x$, i.e. $x=0.2$.
If we try to centre at $x=1$ we get the same result, i.e. the difference at $x=0.2$.
l <- lm(y~ns(I(x-1),2)*group,data=d)
coef(l)['groupII']
# same result as un-centered data, i.e. 0.2987893

Why is that? And is there a way to show the group difference at a different $x$? Btw, centering $x$ manually before the model fit does not make a difference.
 A: The ns function (and other spline functions) does its own "centering" of the data.  Consider this example:
> library(splines)
> 
> s1 <- ns( 1:10, 3 )
> s2 <- ns( (1:10)-5, 3 )
> 
> all.equal(s1,s2)
[1] "Attributes: < Component 1: Mean relative difference: 0.9090909 >"
[2] "Attributes: < Component 7: Mean relative difference: 0.9090909 >"
> all.equal(as.vector(s1),as.vector(s2))
[1] TRUE

So the centering of the data leads to the same splines as the uncentered data (other than the knot information in the attributes).  So centering your variable before computing a spline has no effect.  If you want to compare the values at a point other than 0 then just use the predict function to get the actual predictions at the point of interest and compare (subtract).
A: I think the question why splines cannot be centered arose out of a misunderstanding of how splines function. It seems that splines don't model an intercept and thus centering is impossible. It would, however, be great if someone had another solution to estimating the group differences at different time points when modelling more complex dynamics.
