# Coefficients from a penalized Cox PH

I'm using the R package Penalized (0.9-42) on a Cox PH model. I'm using L2 (Ridge) on the grounds that I don't want to shrink my coefficients to 0. I don't understand why when I ask for:

fit <- penalized(Surv(ttocomplete2, event)~ x1 + x2 + as.factor(x3), lamda2=15.96))
print(coefficients(fit, "all"))


I get coefficients for the baseline/ref level of my categorical variables which, of course, I don't get when using coxph{survival} or cph{rms}.

Not entirely sure but it seems that penalized can only handle ordered factors:

library(penalized)
data(nki70) # Some example data from penalized package (also see help-file)

# Change class of variables to numeric to create similar data
nki70$x1 <- as.numeric(nki70$ER) # dichotomous, 1 or 2
nki70$x2 <- as.numeric(nki70$Age) # continuous
nki70$x3 <- as.numeric(nki70$Grade) # categorical, 1,2 or 3

# Fit L2 model with as.factor, indeed also gives coefficients for ref. level
pen2 <- penalized(Surv(time, event)~x1+x2+as.factor(x3), data = nki70, lambda2 = 10)
coefficients(pen2, "all")

# Gives:
#         x1             x2 as.factor(x3)1 as.factor(x3)2 as.factor(x3)3
#-0.22878408    -0.06065468     0.28389881     0.05984886    -0.34374767

# Fit L2 model with as.ordered, which does not give coefficients for ref. level
pen3 <- penalized(Surv(time, event)~x1+x2+as.ordered(x3), data = nki70, lambda2 = 10)
coefficients(pen3, "all")

# Gives:
#         x1                x2 as.ordered(x3)>=2 as.ordered(x3)>=3
#-0.22560366       -0.06036498       -0.26055093       -0.36240053


This seems to work, although I am not sure what exactly is going on here. I you want to know the details you might be better off asking this at stackoverflow or contact the package maintainer.