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 best.lqr
function.
1 2 | Log.best.lqr(y,x,p=0.5,a=0,b=1,epsilon = 0.001,
precision = 10^-6,criterion = "AIC")
|
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. |
precision |
The convergence maximum error permitted. By default is 10^-6. |
criterion |
Likelihood-based criterion to be used for choosen the best model. It could be |
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.
For the best model:
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.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 | ## 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)
#Median logistic quantile regression (Best fit distribution)
res = Log.best.lqr(y = score,x = cbind(1,type),a=0,b=4)
# 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) #better fitted
#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)
#(Non logistic) Best quantile regression for quantiles
# 0.05, 0.50 and 0.95
xx1 = dose
xx2 = dose^2
xx3 = dose^3
res31 = best.lqr(y = score,x = cbind(1,xx1,xx2,xx3),p = 0.05)
res32 = best.lqr(y = score,x = cbind(1,xx1,xx2,xx3),p = 0.50)
res33 = best.lqr(y = score,x = cbind(1,xx1,xx2,xx3),p = 0.95)
res3 = list(res31,res32,res33)
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
res41 = Log.best.lqr(y = score,x = cbind(1,xx1,xx2,xx3),a=0,b=4,p = 0.05)
res42 = Log.best.lqr(y = score,x = cbind(1,xx1,xx2,xx3),a=0,b=4,p = 0.50)
res43 = Log.best.lqr(y = score,x = cbind(1,xx1,xx2,xx3),a=0,b=4,p = 0.95)
res4 = list(res41,res42,res43)
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)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.