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

Therneau, Terry M., Ph.D. therne@u @end|ng |rom m@yo@edu
Fri Sep 3 21:10:00 CEST 2021



On 9/3/21 12:59 PM, Bond, Stephen wrote:
>
> 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) .
>
A factor is turned into a set of 0/1 dummy variable, so the nocenter applies.� I will add 
more clarification to the documentation.

> 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.
>
Yes, the "mean" component is the reference level for predict and survfit.� If I could go 
back in time it would be labeled as "reference" instead of "mean".�� Another opportunity 
for me to make the documentation clearer.

Good questions,
 � Terry T

> 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