[R] coxph means not equal to means of model matrix

Bond, Stephen Stephen@Bond @end|ng |rom c|bc@com
Fri Sep 3 19:59:37 CEST 2021


I looked at the nocenter and it says (-1,0,1) values but it seems that any three-level factor is included in that (represented as 1,2,3 in R) .
Also, is the baseline curve now showing the reference level and not the fictional .428 sex? If I predict the risk for a new row, should I multiply the coefficient shown in the output by 1 for a sex=1? It used to be (1-.428)*coef.
Thanks for clarifying.
SB

From: Therneau, Terry M., Ph.D. <therneau using mayo.edu>
Sent: Friday, 3 September, 2021 12:37
To: Bond, Stephen <Stephen.Bond using cibc.com>
Cc: R-help <r-help using R-project.org>
Subject: Re: coxph means not equal to means of model matrix

[EXTERNAL]
________________________________
See ?coxph, in particular the new "nocenter" option.

Basically, the "mean" component is used to center later computations.  This can be critical for continuous variables, avoiding overflow in the exp function, but is not necessary for 0/1 covariates.   The fact that the default survival curve would be for a sex of .453, say, was off-putting to many.

Terry T.

On 9/3/21 11:01 AM, Bond, Stephen wrote:
Hi,

Please, help me understand what is happening with the means of a Cox model?
I have:
R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

getOption("contrasts")
        unordered           ordered
"contr.treatment"      "contr.poly"

According to the help  coxph.object has a component holding the means of the X (model.matrix). This does not hold any more.
```
library(survival)
test1 <- list(time=c(4,3,1,1,2,2,3),
                   status=c(1,1,1,0,1,1,0),
                   x=c(0,2,1,1,1,0,0),
                   sex=factor(c(0,0,0,0,1,1,1)))
m1 <- coxph(Surv(time, status) ~ x + sex, test1)
m1$means
##        x      sex1
## 0.7142857 0.0000000
colMeans(model.matrix(m1))
##         x      sex1
## 0.7142857 0.4285714

```
Will new observations be scored using the zero mean from the object?? Is this just a reporting change where $means shows the reference level and no longer the mean of the model matrix??

Thanks everybody



ATTENTION : This email originated outside your organization. Exercise caution before clicking links, opening attachments, or responding with personal information.
________________________________

	[[alternative HTML version deleted]]



More information about the R-help mailing list