Hi, I have a question about how to extract paramters from a fitted model. I can extract coefficients and std, but from some other statistics, I dont know how to extract. Can anyone help? Here it is an example:> coxout<-coxph(Surv(t,t.censor)~x)> coxoutCall: coxph(formula = Surv(t, t.censor) ~ x) coef exp(coef) se(coef) z p x 0.349 1.42 0.257 1.36 0.17 Likelihood ratio test=1.84 on 1 df, p=0.175 n= 200> coxout$coefx 0.3490500> coxout$pNULL Any convienent way to extract the LRT and the p value? thank you! [[alternative HTML version deleted]]
Henrique Dallazuanna
2008-Apr-29 19:23 UTC
[R] Help on extract paramters from fitted models
See the source code of function:
getS3method("print", "coxph")
is this block:
tmp <- cbind(coef, exp(coef), se, coef/se, signif(1 -
pchisq((coef/se)^2, 1), digits - 1))
On 4/29/08, Lisa <sangwl@gmail.com> wrote:>
> Hi, I have a question about how to extract paramters from a fitted model.
> I
> can extract coefficients and std, but from some other statistics, I dont
> know how to extract. Can anyone help?
>
> Here it is an example:
>
>
> > coxout<-coxph(Surv(t,t.censor)~x)
>
>
> > coxout
> Call:
> coxph(formula = Surv(t, t.censor) ~ x)
>
> coef exp(coef) se(coef) z p
> x 0.349 1.42 0.257 1.36 0.17
>
> Likelihood ratio test=1.84 on 1 df, p=0.175 n= 200
>
> > coxout$coef
> x
> 0.3490500
>
> > coxout$p
> NULL
>
> Any convienent way to extract the LRT and the p value? thank you!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]
Lisa wrote:> Hi, I have a question about how to extract paramters from a fitted model. I > can extract coefficients and std, but from some other statistics, I dont > know how to extract. Can anyone help? > > Here it is an example: > > >> coxout<-coxph(Surv(t,t.censor)~x) > > >> coxout > Call: > coxph(formula = Surv(t, t.censor) ~ x) > > coef exp(coef) se(coef) z p > x 0.349 1.42 0.257 1.36 0.17 > > Likelihood ratio test=1.84 on 1 df, p=0.175 n= 200 > >> coxout$coef > x > 0.3490500 > >> coxout$p > NULL > > Any convienent way to extract the LRT and the p value? thank you!Use the summary method for coxph objects: summary(coxout)$logtest["test"] summary(coxout)$logtest["pvalue"] Unfortunately, this is not documented in the built-in help for the survival package, but you can see the structure for the summary.coxph method by using: str(summary(coxout)) ?summary.coxph actually points to the structure details of a coxph object, rather than the summary.coxph object. HTH, Marc Schwartz