Re: [R] Coxph with factors

From: Kylie-Anne Richards <kar_at_itga.com.au>
Date: Sat 16 Jul 2005 - 18:07:01 EST

Thank you for your help.



> In any case, to specify f.pom You need it to be a factor with the same set
> of levels. You don't say what the lowest level of pom is, but if it is,
> say, -3.
>
> f.pom=factor(-3, levels=seq(-3,2.5, by=0.5))

For this particular model, f.pom starts at -5.5 going to 2 in 0.5 increments. I seem to have misunderstood your explanation, as R is still producing an error.

>final<-coxph(Surv(time.sec,done)~f.pom+vo+po,data=DATA)
>final.surv<-survfit((final),
>data.frame(po=0,vo=10000,f.pom=factor(-5.5,levels=seq(-5.5,2,by=0.5)),individual=T))
>summary(final.surv)
Error in x2 %*% coef : non-conformable arguments Execution halted



> I would first note that the survival function at zero covariates is not a
> very useful thing and is usually numerically unstable, and it's often more
> useful to get the survival function at some reasonable set of covariates.

Please correct me if I'm wrong, I was under the impression that the survival function at zero covariates gave the baseline distribution. I.e. if given the baseline prob.,S_0, at time t, one could calculate the survival prob for specified covariates by
S_0^exp(beta(vo)*specified(vo)+beta(po)*specified(po)+beta(f.pom at the level of interest)) for time t.

Since I was unable to get survfit to work with specified covariates, I was using the survival probs of the 'avg' covariates, S(t), to determine the baseline at time t, i.e.
S(t)^(1/exp(beta(vo)*mean(vo)+beta(po)*mean(po)+beta(f.pom-5.5)*mean(f.pom-5.5)+beta(f.pom-5.0)*mean(f.pom-5.0)+........). And then proceeding as mention in the above paragraph (clearly not an efficient way of doing things).

> On Fri, 15 Jul 2005, Kylie-Anne Richards wrote:
>>
>> FIRST Q: The default uses the mean of 'vo' and mean of 'po', but what is
>> it
>> using for the factors?? Is it the sum of the coef of the factors divided
>> by
>> the number of factors??
>
> It uses the mean of each factor variable. The $means component of the fit
> gives the values it uses.
>
>> SECOND Q: For a model with covariates I would normally specify:
>> final.surv<-survfit((final), data.frame(po=0,vo=0,pom=0,individual=T)) to
>> get the baseline survival prob.; what would I specify for a model with a
>> factor, i.e., 'f.pom' ??
>
> I would first note that the survival function at zero covariates is not a
> very useful thing and is usually numerically unstable, and it's often more
> useful to get the survival function at some reasonable set of covariates.
>
> In any case, to specify f.pom You need it to be a factor with the same set
> of levels. You don't say what the lowest level of pom is, but if it is,
> say, -3.
>
> f.pom=factor(-3, levels=seq(-3,2.5, by=0.5))
>
>
> =thomas
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 16 18:11:45 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:45 EST