predicted values in Cox model where there is interaction I am confused regarding the connection between coefficients and the predicted values of the linear predictor in Cox model with two factors and their interaction
I ran the code below. 
I believe that with an interaction  the main effects for 4 levels celltype are those at the reference level of 2 level trt and as I show the effects of celltype at the non-reference level of trt can be found by adding the main effects (of celltype at the reference of trt) to the interaction effects.
I created a new data set with all combinations of trt and cell type and thought the estimated values of lp (linear predictor) would have a relation to the main and interaction effect estimates. But I can't see it.
I've pulled out the "terms" of "lp" to see what terms contribute to lp and am still confused eg why are the terms for trt +/- 0.37 when the trt main effect is 0.74 ?
Also I would expect the predicted "lp" term to be zero for trt=1 and celltype=squamous (ie the patient with reference levels of both factors" 
Sorry to ask such a basic (and lengthy) question - many thanks in advance
library(survival)

veteran$trt<-as.factor(veteran$trt)
class(veteran$trt)
class(veteran$celltype)

vetcox1<-coxph(Surv(time,status) ~         trt+celltype+trt:celltype,data=veteran)
coef(vetcox1)
coef(vetcox1)[2:4]+coef(vetcox1)[5:7]

veteran$trt<-relevel(veteran$trt,ref=2)
vetcox2<-coxph(Surv(time,status) ~ trt+celltype+trt:celltype,data=veteran)
coef(vetcox2)

       allpred<-expand.grid(celltype=c("smallcell","adeno","large","squamous"), trt=as.factor(1:2))
allpred
predict(vetcox1,type="lp",newdata=allpred)
coef(vetcox1)[2:4]+coef(vetcox1)[5:7]
coef(vetcox1)
coef(vetcox2)
predict(vetcox1,type="terms",newdata=allpred)
predict(vetcox2,type="terms",newdata=allpred)

 A: The output of predict() indeed seems weird, but in the end works as expected. We can test the behavior on a simpler model at first:
relevel(veteran$trt, ref=2)
lmod = lm(time ~ trt, data=veteran)
mean(veteran$time[veteran$trt==1]) # 115.1449

Even here, predict ignores the factor levels - the "constant" attribute is the mean, and it just adds +/- coefficients for each level, so the predictions are correct.
>predict(lmod, type="terms", newdata = allpred)
        trt
1 -6.482810
2 -6.482810
3 -6.482810
4 -6.482810
5  6.578145
6  6.578145
7  6.578145
8  6.578145
attr(,"constant")
[1] 121.6277

>predict(lmod, newdata = allpred)
 1        2        3        4        5        6        7        8 
115.1449 115.1449 115.1449 115.1449 128.2059 128.2059 128.2059 128.2059 

I believe that is also what's happening in the survival setup: the +/- coefficients aren't exactly equal (0.3717977 and -0.3772653), but I wouldn't be surprised by a rounding error of that size, given that there's a lot of exp()s going on behind scenes. 
(You can explore more by analyzing body(predict.lm), although I haven't gone there in more detail.)
