Description Usage Arguments Details Value Note Author(s) References See Also Examples
It performs the logistic transformation in Bottai et.al. (2009) (see references) for estimating quantiles for a bounded response. Once the response is transformed, it uses the lqr
function.
1 2 |
We will detail first the only three arguments that differ from lqr
function.
a |
lower bound for the response (default = 0) |
b |
upper bound for the response (default = 1) |
epsilon |
a small quantity ε>0 that ensures that the logistic transform is defined for all values of |
y |
the response vector of dimension n where n is the total of observations. |
x |
design matrix for the fixed effects of dimension N x d where d represents the number of fixed effects including the intercept, if considered. |
p |
An unique quantile or a set of quantiles related to the quantile regression. |
dist |
represents the distribution to be used for the error term. The values are |
nu |
It represents the degrees of freedom when |
gama |
It represents a scale factor for the contaminated normal distribution. When is not provided, we use the MLE. |
precision |
The convergence maximum error permitted. By default is 10^-6. |
CI |
Confidence to be used for the Confidence Interval when a grid of quantiles is provided. Default = 0.95. |
We follow the transformation in Bottai et.al. (2009) defined as
h(y)=logit(y)=log(\frac{y-a}{b-y})
that implies
Q_{y}(p)=\frac{b\,exp(Xβ) + a}{1 + exp(Xβ)}
where Q_{y}(p) represents the conditional quantile of the response. Once estimates for the regression coefficients β_p are obtained, inference on Q_{y}(p) can then be made through the inverse transform above. This equation (as function) is provided in the output. See example.
The interpretation of the regression coefficients is analogous to the interpretation of the coefficients of a logistic regression for binary outcomes.
For example, let x_1 be the gender (male = 0, female=1). Then exp(β_{0.5,1}) represents the odds ratio of median score in males vs females, where the odds are defined using the score instead of a probability, (y-a)/(b-y). When the covariate is continous, the respective β coeficient can be interpretated as the increment (or decrement) over the log(odd ratio) when the covariate increases one unit.
iter |
number of iterations. |
criteria |
attained criteria value. |
beta |
fixed effects estimates. |
sigma |
scale parameter estimate for the error term. |
nu |
Estimate of |
gamma |
Estimate of |
SE |
Standard Error estimates. |
table |
Table containing the inference for the fixed effects parameters. |
loglik |
Log-likelihood value. |
AIC |
Akaike information criterion. |
BIC |
Bayesian information criterion. |
HQ |
Hannan-Quinn information criterion. |
fitted.values |
vector containing the fitted values. |
residuals |
vector containing the residuals. |
When a grid of quantiles is provided, a graphical summary with point estimates and Confidence Intervals for model parameters is shown. Also, the result will be a list of the same dimension where each element corresponds to each quantile as detailed above.
Christian E. Galarza <cgalarza88@gmail.com>, Luis Benites <lsanchez@ime.usp.br> and Victor H. Lachos <hlachos@ime.unicamp.br>
Maintainer: Christian E. Galarza <cgalarza88@gmail.com>
Bottai, M., Cai, B., & McKeown, R. E. (2010). Logistic quantile regression for bounded outcomes. Statistics in Medicine, 29(2), 309-317.
Galarza, C.M., Lachos, V.H., Cabral, C.R.B. and Castro, L.M. (2016). Robust Quantile Regression using a Generalized Class of Skewed Distributions. Technical Report 7, Universidade Estadual de Campinas. http://www.ime.unicamp.br/sites/default/files/rp07-16.pdf
Log.best.lqr
,best.lqr
,dSKD
,QRLMM
,
QRNLMM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | ## Not run:
##Load the data
data(resistance)
attach(resistance)
#EXAMPLE 1.1
#Comparing the resistence to death of two types of tumor-cells.
#The response is a score in [0,4].
boxplot(score~type,ylab="score",xlab="type")
#Student't median logistic quantile regression
res = Log.lqr(y = score,x = cbind(1,type),a=0,b=4,dist="t")
# The odds ratio of median score in type B vs type A
exp(res$beta[2])
#Proving that exp(res$beta[2]) is approx median odd ratio
medA = median(score[type=="A"])
medB = median(score[type=="B"])
rateA = (medA - 0)/(4 - medA)
rateB = (medB - 0)/(4 - medB)
odd = rateB/rateA
round(c(exp(res$beta[2]),odd),3)
#EXAMPLE 1.2
############
#Comparing the resistence to death depending of dose.
#descriptive
plot(dose,score,ylim=c(0,4),col="dark gray");abline(h=c(0,4),lty=2)
dosecat<-cut(dose, 6, ordered = TRUE)
boxplot(score~dosecat,ylim=c(0,4))
abline(h=c(0,4),lty=2)
#Slash (Non logistic) quantile regression for quantiles 0.05, 0.50 and 0.95
xx1 = dose
xx2 = dose^2
xx3 = dose^3
res3 = lqr(y = score,x = cbind(1,xx1,xx2,xx3),p = c(0.05,0.50,0.95),dist="slash")
seqq=seq(min(dose),max(dose),length.out = 1000)
dd = matrix(data = NA,nrow = 1000,ncol =3)
for(i in 1:3)
{
dd[,i] = rep(res3[[i]]$beta[1],1000) + res3[[i]]$beta[2]*seqq +
res3[[i]]$beta[3]*seqq^2 + res3[[i]]$beta[4]*seqq^3
}
plot(dose,score,ylim=c(-1,5),col="gray");abline(h=c(0,4),lty=2)
lines(seqq,dd[,1],lwd=1,col=2)
lines(seqq,dd[,2],lwd=1,col=1)
lines(seqq,dd[,3],lwd=1,col=2)
#Using logistic quantile regression for obtaining predictions inside bounds
res4 = Log.lqr(y = score,x = cbind(1,xx1,xx2,xx3),a = 0,b = 4,p = c(0.05,0.50,0.95),dist="slash")
dd = matrix(data = NA,nrow = 1000,ncol =3)
for(i in 1:3)
{
dd[,i] = rep(res4[[i]]$beta[1],1000) + res4[[i]]$beta[2]*seqq +
res4[[i]]$beta[3]*seqq^2 + res4[[i]]$beta[4]*seqq^3
}
#Computing quantiles for the original response (Inverse trnasformation)
pred = function(predlog,a,b)
{
return((b*exp(predlog)+a)/(1+exp(predlog)))
}
for(i in 1:3)
{
dd[,i] = pred(dd[,i],a=0,b=4)
}
#No more prediction curves outof bounds
plot(dose,score,ylim=c(0,4),col="gray");abline(h=c(0,4),lty=2)
lines(seqq,dd[,1],lwd=1,col=2)
lines(seqq,dd[,2],lwd=1,col=1)
lines(seqq,dd[,3],lwd=1,col=2)
#EXAMPLE 1.3
############
#A full model using dose and type for a grid of quantiles
typeB = 1*(type=="B")
res5 = Log.lqr(y = score,x = cbind(1,xx1,xx2,xx3,typeB,typeB*xx1),a = 0,b = 4,
p = seq(from = 0.05,to = 0.95,by = 0.05),dist = "t")
ddA = ddB = matrix(data = NA,nrow = 1000,ncol = 5)
for(i in 1:5)
{
k = c(2,5,10,15,18)[i]
ddA[,i] = rep(res5[[k]]$beta[1],1000) + res5[[k]]$beta[2]*seqq + res5[[k]]$beta[3]*
seqq^2 + res5[[k]]$beta[4]*seqq^3
ddB[,i] = rep(res5[[k]]$beta[1],1000) + (res5[[k]]$beta[2] + res5[[k]]$beta[6])*
seqq + res5[[k]]$beta[3]*seqq^2 + res5[[k]]$beta[4]*seqq^3 + res5[[k]]$beta[5]
}
#Computing quantiles for the original response (Inverse transformation)
for(i in 1:5)
{
ddA[,i] = pred(ddA[,i],a=0,b=4)
ddB[,i] = pred(ddB[,i],a=0,b=4)
}
#Such a beautiful plot
par(mfrow=c(1,2))
plot(dose,score,ylim=c(0,4),col=c((type == "B")*8+(type == "A")*1),main="Type A")
abline(h=c(0,4),lty=2)
lines(seqq,ddA[,1],lwd=2,col=2)
lines(seqq,ddA[,2],lwd=1,col=4)
lines(seqq,ddA[,3],lwd=2,col=1)
lines(seqq,ddA[,4],lwd=1,col=4)
lines(seqq,ddA[,5],lwd=2,col=2)
legend(x = 0,y=4,legend = c("p=0.10","p=0.25","p=0.50","p=0.75","p=0.90")
,col=c(2,4,1,4,2),lwd=c(2,1,2,1,2),bty = "n",cex=0.65)
plot(dose,score,ylim=c(0,4),col=c((type == "B")*1 + (type == "A")*8),
main="Type B");abline(h=c(0,4),lty=2)
lines(seqq,ddB[,1],lwd=2,col=2)
lines(seqq,ddB[,2],lwd=1,col=4)
lines(seqq,ddB[,3],lwd=2,col=1)
lines(seqq,ddB[,4],lwd=1,col=4)
lines(seqq,ddB[,5],lwd=2,col=2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.