frame_br: Visualization of quantile regression model fitting: br...

Description Usage Arguments Details Value Author(s) Examples

View source: R/frame_br.R

Description

get the observation used in br algorithem

Usage

1
frame_br(object, tau)

Arguments

object

quantile regression model using br method

tau

quantiles can be a single quantile or a vector of quantiles

Details

This is a function that can be used to create point plot for the observations used in quantile regression fitting based on 'br'method.

Value

All observations and the observations used in quantile regression fitting using br algorithem

Author(s)

Wenjing Wang wenjingwangr@gmail.com

Examples

 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
library(ggplot2)
library(quantreg)
data(ais)
tau <- c(0.1, 0.5, 0.9)
object1 <- rq(BMI ~ LBM, tau, method = 'br', data = ais)
data_plot <- frame_br(object1, tau)$all_observation
choose <- frame_br(object1, tau)$fitting_point
ggplot(data_plot,
 aes(x=value, y=data_plot[,2])) +
 geom_point(alpha = 0.1) +
 ylab('y') +
 xlab('x') +
 facet_wrap(~variable, scales = "free_x", ncol = 2) +
 geom_point(data = choose, aes(x = x, y = y,
                                      group = tau_flag,
                                      colour = tau_flag,
                                      shape = obs))

object2 <- rq(BMI ~ Ht + LBM + Wt, tau, method = 'br',
            data = ais)
data_plot <- frame_br(object2, tau)$all_observation
choose <- frame_br(object2, tau)$fitting_point
ggplot(data_plot,
 aes(x=value, y=data_plot[,2])) +
 geom_point(alpha = 0.1) +
 ylab('y') +
 xlab('x') +
 facet_wrap(~variable, scales = "free_x", ncol = 2) +
 geom_point(data = choose, aes(x = x, y = y,
                                      group = tau_flag,
                                      colour = tau_flag,
                                      shape = obs))

quokar documentation built on May 2, 2019, 6:39 a.m.