R/rqfit.R

rqfit <-
function(x,y,qval=.5,alpha=.05,xout=FALSE,outfun=out,res=FALSE,method='br',...){
#
# Do a quantile regression fit
#
if(alpha!=.05)stop("This function only allows alpha=.05. Use qregci")
library(quantreg)
xx<-cbind(x,y)
p<-ncol(xx)-1
xx<-elimna(xx)
x<-xx[,1:p]
y<-xx[,ncol(xx)]
x=as.matrix(x)
if(xout){
flag<-outfun(x,...)$keep
x<-x[flag,]
y<-y[flag]
}
residuals<-NA
if(res)residuals<-rq(y~x)$residuals
temp<-summary(rq(y~x,tau=qval,alpha=alpha,method=method))
temp0<-temp[[4]]
if(is.matrix(temp[[3]]))temp0<-temp[[3]] #Newer R version
temp<-temp0
coef<-temp[,1]
ci<-temp[,2:3]
list(coef=coef,ci=ci,residuals=residuals)
}
musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.