Description Usage Arguments Details Value Note Author(s) References See Also Examples
It fits a robust linear quantile regression model using a new family of zero-quantile distributions for the error term. This family of distribution includes skewed versions of the Normal, Student's t, Laplace, Slash and Contaminated Normal distribution. It provides estimates and full inference. It also provides envelopes plots for assessing the fit and confidences bands when several quantiles are provided simultaneously.
1 2 3 4 5 6 7 8 9 | lqr(y,x,p=0.5,dist="normal",nu="",gama="",precision=10^-6,envelope=FALSE,CI=0.95)
#lqr(y, x, p = 0.5, dist = "normal")
#lqr(y, x, p = 0.5, dist = "t")
#lqr(y, x, p = 0.5, dist = "laplace")
#lqr(y, x, p = 0.5, dist = "slash")
#lqr(y, x, p = 0.5, dist = "cont")
#lqr(y, x, p = c(0.25,0.50,0.75), dist = "normal")
|
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. |
envelope |
if |
CI |
Confidence to be used for the Confidence Interval when a grid of quantiles is provided. Default = 0.95. |
When a grid of quantiles is provided, a graphical summary with point estimates and Confidence Intervals for model parameters is shown.
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. |
If a grid of quantiles is provided, 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>
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
Wichitaksorn, N., Choy, S. T., & Gerlach, R. (2014). A generalized class of skew distributions and associated robust quantile regression models. Canadian Journal of Statistics, 42(4), 579-596.
best.lqr
,Log.lqr
,
Log.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 | ## Not run:
#Example 1
##Load the data
data(ais)
attach(ais)
##Setting
y<-BMI
x<-cbind(1,LBM,Sex)
## Fitting a median regression with Normal errors (by default)
modelF = lqr(y[Sex==1], x[Sex==1,1:2])
modelM = lqr(y[Sex==0], x[Sex==0,1:2])
plot(LBM,BMI,col=Sex+1,xlab="Lean Body Mass",ylab="Body4 Mass Index",main="Quantile Regression")
abline(a = modelF$beta[1],b = modelF$beta[2],lwd=2,col=2)
abline(a = modelM$beta[1],b = modelM$beta[2],lwd=2,col=4)
#COMPARING SOME MODELS for median regression
x<-cbind(1,LBM)
modelN = lqr(y,x,dist = "normal")
modelT = lqr(y,x,dist = "t")
modelL = lqr(y,x,dist = "laplace")
#Comparing AIC criterias
modelN$AIC;modelT$AIC;modelL$AIC
#This could be automatically done using best.lqr()
best.model = best.lqr(y, x, p = 0.75, criterion = "AIC")
#Let's use a grid of quantiles
modelfull = lqr(y,x,p = seq(from = 0.10,to = 0.90,by = 0.05),dist = "normal")
#Plotting quantiles 0.10,0.25,0.50,0.75 and 0.90
plot(LBM,BMI,xlab = "Lean Body Mass"
,ylab = "Body Mass Index", main = "Quantile Regression",pch=16)
abline(a = modelfull[[1]]$beta[1],b = modelfull[[1]]$beta[2],lwd=2,lty=1,col=2)
abline(a = modelfull[[17]]$beta[1],b = modelfull[[17]]$beta[2],lwd=2,lty=1,col=2)
abline(a = modelfull[[4]]$beta[1],b = modelfull[[4]]$beta[2],lwd=2,lty=1,col=3)
abline(a = modelfull[[14]]$beta[1],b = modelfull[[14]]$beta[2],lwd=2,lty=1,col=3)
abline(a = modelfull[[9]]$beta[1],b = modelfull[[9]]$beta[2],lwd=2,lty=1,col=4)
#Example 2
##Load the data
data(crabs,package = "MASS")
crabs$sex <- as.character(crabs$sex)
crabs$sex[crabs$sex=="M"]=0
crabs$sex[crabs$sex=="F"]=1
crabs$sex = as.numeric(crabs$sex)
attach(crabs)
head(crabs)
##Setting
y <- BD
x <- cbind(1,FL,sex)
plot(crabs)
## Fitting a median regression with Normal errors (by default)
modelF = lqr(y[sex==1], x[sex==1,1:2])
modelM = lqr(y[sex==0], x[sex==0,1:2])
plot(FL,BD,col=sex+1,xlab="Frontal lobe size",ylab="Body depth",main="Quantile Regression")
abline(a = modelF$beta[1],b = modelF$beta[2],lwd=2,col=2)
abline(a = modelM$beta[1],b = modelM$beta[2],lwd=2,col=4)
#COMPARING SOME MODELS for median regression
x<-cbind(1,FL)
modelN = lqr(y,x,dist = "normal")
modelT = lqr(y,x,dist = "t")
modelL = lqr(y,x,dist = "laplace")
modelS = lqr(y,x,dist = "slash")
modelC = lqr(y,x,dist = "cont" )
#Comparing AIC criterias
modelN$AIC;modelT$AIC;modelL$AIC;modelS$AIC;modelC$AIC
#Let's use a grid of quantiles
modelfull = lqr(y,x,p = seq(from = 0.10,to = 0.90,by = 0.05),dist = "t")
#Plotting quantiles 0.10,0.25,0.50,0.75 and 0.90
plot(FL,BD,xlab = "Frontal lobe size"
,ylab = "Body depth", main = "Quantile Regression",pch=16)
abline(a = modelfull[[1]]$beta[1],b = modelfull[[1]]$beta[2],lwd=2,lty=1,col=2)
abline(a = modelfull[[17]]$beta[1],b = modelfull[[17]]$beta[2],lwd=2,lty=1,col=2)
abline(a = modelfull[[4]]$beta[1],b = modelfull[[4]]$beta[2],lwd=2,lty=1,col=3)
abline(a = modelfull[[14]]$beta[1],b = modelfull[[14]]$beta[2],lwd=2,lty=1,col=3)
abline(a = modelfull[[9]]$beta[1],b = modelfull[[9]]$beta[2],lwd=2,lty=1,col=4)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.