Description Usage Arguments Details Value Author(s) References Examples
observations used in quantile regression fitting
min_{b \in R^{p}}∑_{i=1}^{n}ρ_{τ}(y_i-x_{i}^{'}b)
where ρ_{τ}(r)=r[τ-I(r<0)]$ for $τ \in (0,1). This yields the modified linear program
min(τ e^{'}u+(1-τ)e^{'}v|y=Xb+u-v,(u,v) \in R_{+}^{2n})
Adding slack variables, s, satisfying the constrains a+s=e, we obtain the barrier function
B(a, s, u) = y^{'}a+μ ∑_{i=1}^{n}(loga_{i}+logs_{i})
which should be maximized subject to the constrains X^{'}a=(1-τ)X^{'}e and a+s=e. The Newton step δ_{a} solving
max{y^{'}δ_{a}+μ δ^{'}_{a}(A^{-1}-S^{-1})e- \frac{1}{2}μ δ_{a}^{'}(A^{-2}+S^{-2})δ_{a}}
subject to X{'}δ_{a}=0, satisfies
y+μ(A^{-1}-S^{-1})e-μ(A^{-2}+S^{-2})δ_{a}=Xb
for some b\in R^{p}, and δ_{a} such that X^{'}δ_{a}=0. Using the constraint, we can solve explicitly for the vector b,
b=(X^{'}WX)^{-1}X^{'}W[y+μ(A^{-1}-S^{-1})e]
where W=(A^{-2}+S^{-2})^{-1}. This is a form of the primal log barrier algorithm described above. Setting μ=0 in each step yields an affine scaling variant of the algorithm. The basic linear algebra of each iteration is essentially unchanged, only the form of the diagonal weighting matrix W has chagned.
1 | frame_fn_obs(object, tau)
|
object |
quantile regression model using interior point method for estimating |
tau |
quantile |
This function used to illustrate data used in fitting process of quantile regression based on interior point method. Koenker and Bassett(1978) introduced asymmetric weight on positive and negative residuals, and solves the slightly modified l1-problem.
Weighted observations in quantile regression fitting using interior point algorithm
Wenjing Wang wenjingwangr@gmail.com
Portnoy S, Koenker R. The Gaussian hare and the Laplacian tortoise: computability of squared-error versus absolute-error estimators. Statistical Science, 1997, 12(4): 279-300.
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 | library(ggplot2)
library(quantreg)
library(tidyr)
library(dplyr)
library(gridExtra)
data(ais)
tau <- c(0.1, 0.5, 0.9)
object <- rq(BMI ~ LBM + Ht, data = ais, tau = tau, method = 'fn')
fn <- frame_fn_obs(object, tau)
##For tau = 0.1, plot the observations used in quantile regression
##fitting based on interior point method
fn1 <- fn[ ,1]
case <- 1:length(fn1)
fn1 <- cbind(case, fn1)
m <- data.frame(y = ais$BMI, x1 = ais$LBM, x2 = ais$Ht, fn1)
p <- length(attr(object$coefficients, "dimnames")[[1]])
m_f <- m %>% gather(variable, value, -case, -fn1, -y)
mf_a <- m_f %>%
group_by(variable) %>%
arrange(variable, desc(fn1)) %>%
filter(row_number() %in% 1:p )
p1 <- ggplot(m_f, aes(x = value, y = y)) +
geom_point(alpha = 0.1) +
geom_point(data = mf_a, size = 3) +
facet_wrap(~variable, scale = "free_x")
## For tau = 0.5, plot the observations used in quantile regression
##fitting based on interior point method
fn2 <- fn[,2]
case <- 1: length(fn2)
fn2 <- cbind(case, fn2)
m <- data.frame(y = ais$BMI, x1 = ais$LBM, x2 = ais$Ht, fn2)
p <- length(attr(object$coefficients, "dimnames")[[1]])
m_f <- m %>% gather(variable, value, -case, -fn2, -y)
mf_a <- m_f %>%
group_by(variable) %>%
arrange(variable, desc(fn2)) %>%
filter(row_number() %in% 1:p )
p2 <- ggplot(m_f, aes(x = value, y = y)) +
geom_point(alpha = 0.1) +
geom_point(data = mf_a, size = 3) +
facet_wrap(~variable, scale = "free_x")
## For tau = 0.9
fn3 <- fn[,3]
case <- 1: length(fn3)
fn3 <- cbind(case, fn3)
m <- data.frame(y = ais$BMI, x1 = ais$LBM, x2 = ais$Ht, fn3)
p <- length(attr(object$coefficients, "dimnames")[[1]])
m_f <- m %>% gather(variable, value, -case, -fn3, -y)
mf_a <- m_f %>%
group_by(variable) %>%
arrange(variable, desc(fn3)) %>%
filter(row_number() %in% 1:p )
p3 <- ggplot(m_f, aes(x = value, y = y)) +
geom_point(alpha = 0.1) +
geom_point(data = mf_a, size = 3) +
facet_wrap(~variable, scale = "free_x")
grid.arrange(p1, p2, p3, ncol = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.