0

I am using censored quantile regression for survival data. For a specific qunatile (say 0.8), I get the summary result. I can extract the intercept and beta coefficient but I can not extract standard error of the coefficients from the summary result. Can anyone please help me?

>library(survival)
>library(quantreg)
>set.seed(124)
>n=1000
>b0=5
>b1=1
>x<-runif(n,0,5)  
>w<-rnorm(n,0,1)
>realtimes<-exp(b0+b1*x+w)
>v<-rnorm(n,0,1)
>censtimes<-exp(6.5+0.75*x+v) 
>Time<-pmin(realtimes,censtimes)
>Status<-as.numeric(censtimes > realtimes) 
>Status1<-(censtimes > realtimes)
>data<-data.frame(x=x,Time=Time,Status=Status,realtimes=realtimes,censtimes=censtimes,Status1)
>fitcrq<-crq(Surv(log(Time),Status1,type="right")~x,taus=0.8,data =data, method = "Portnoy")
>summary(fitcrq,0.8)
UNI39
  • 21
  • 2

1 Answers1

0

Note: The easiest is to store the model into a variable and extract everything from there. Allow me to propose the following: Install broom and use tidy() on your model. You get a nice tibble (formatted table) which will make it easy and consistent to get whatever you need.

I could not run your code to the end, but I assume it returns an object similar to lm() functions. Please also note that I fixed Status as it lacked the c() function.

library(survival)
library(quantreg)
set.seed(124)
n=1000
b0=5
b1=1
x<-runif(n,0,5)  
w<-rnorm(n,0,1)
realtimes<-exp(b0+b1*x+w)
v<-rnorm(n,0,1)
censtimes<-exp(6.5+0.75*x+v) 
Time<-pmin(realtimes,censtimes)
Status<-as.numeric(c(censtimes,  realtimes) )
Status1<-c(censtimes,  realtimes)
data<-data.frame(x=x,Time=Time,Status=Status,realtimes=realtimes,censtimes=censtimes,Status1)

require(broom)
object_model <- summary(fitcrq,0.8)
broom::tidy(object_model)
# OTHERWISE:
object_model$coefficients[,2]

I hope you will be satisfied with this solution.

RYann
  • 567
  • 1
  • 7
  • Thank you so much for your help. Package broom works nicely to extract parameters from the model. – UNI39 Jul 13 '23 at 16:12