1

I've generated the following data in R:

library(quantreg)
library(survival)

set.seed(789)
N <- 2000
u <- runif(N)
x1 <- rbinom(N,1,.5)
x2 <- rbinom(N,1,.5)
x1x2<-x1*x2
lambda <- 1 + 1.5*x1 + 1.5*x2 + .5*x1x2
k <- 2
y <- lambda*((-log(1-u))^(1/k));max(y)
c <- runif(N,max=15)
event = as.numeric(y<=c)
mean(event);table(event)
cens <- 1-event
table(cens)mean(cens)
time <-as.matrix(ifelse(event==1,y,c))

St<-Surv(time,event,type="right")

To which I've fit the following censored quantile regression model:

q2 <- crq(St~x1 + x2 + x1x2,tau=.9,method="Portnoy")
summary(q2)

As one can see, I'm interested in the 0.9th quantile. But summary(q2) returns the 20th to 80th percentiles (by 20). How can I get only the 0.9th quantile (aka the 90th percentile)?? My problem is that, even though I request the 90th percentile in crq (i.e., "tau=0.9"), the summary function keeps returning the same set of (unwanted) percentiles (20th, 40th, 60th, 80th).

4

2 回答 2

2

进入...

?summary.crq

结果是...

## S3 method for class 'crq'
summary(object, taus = 1:4/5, alpha = .05, se="boot", covariance=TRUE,  ...)

所以你应该能够指定 tau。

summary(q2, tau = 1:9/10)

tau: [1] 0.9

Coefficients:
            Value    Lower Bd Upper Bd Std Error T Value  Pr(>|t|)
(Intercept)  1.55424  1.44255  1.66594  0.05699  27.27311  0.00000
x1           2.23893  2.03412  2.44375  0.10450  21.42528  0.00000
x2           2.15514  1.97319  2.33710  0.09284  23.21441  0.00000
x1x2         0.74453  0.35153  1.13753  0.20051   3.71309  0.00020

为 tau 指定单个值会导致错误。

于 2015-02-19T12:40:20.567 回答
0

分位数示例:

quantile(dataframe$columnname, na.rm=TRUE)

在这种情况下,您希望有 quantile(dataframe$columnname,probs=(0.009, 0.2, 0.8))

0.009 为您提供第 0.9 个分位数。

于 2015-01-19T22:31:21.770 回答