19  geom_q

19.1 geom_qq

Package

ggplot2 (Wickham 2016)

Description

Draws quantitle-quantile plot.

Understandable aesthetics

required aesthetics

sample

optional aesthetics

group, x, y

See also

geom_qq_line

Example

worldbankdata |>
  ggplot(aes(sample = Cooking)) +
  geom_qq()
Warning: Removed 6047 rows containing non-finite outside the scale range
(`stat_qq()`).

19.2 geom_qq_line

Package

ggplot2 (Wickham 2016)

Description

Computes the slope and intercept of the line connecting the points at specified quartiles of the theoretical and sample distribution in the quantitle-quantile plot. This geom should be used along with geom_qq to plot to be meaningful.

Understandable aesthetics

required aesthetics

sample

optional aesthetics

group, x, y

See also

geom_qq_line

Example

a1 <- worldbankdata |>
  ggplot(aes(sample = Cooking)) +
  geom_qq_line()  + ggtitle("geom_qq_line only")
a2 <- worldbankdata |>
  ggplot(aes(sample = Cooking)) +
  geom_qq_line() + geom_qq() + ggtitle("geom_qq_line and geom_qq")
a1|a2

19.3 geom_qquantile

Package

ggplot2 (Wickham 2016)

Description

Fits and draw quantile regression lines. Quantile regression models the relationship between independent variables and the percentiles of the dependent variable

Understandable aesthetics

required aesthetics

x, y

optional aesthetics

alpha, colour, group, linetype, linewidth, weight, quantile, method

See also

geom_boxplot

Examples

Example 1

a1 <- worldbankdata |>
  ggplot(aes(y=Cooking, x = Electricity)) + 
  geom_quantile() + ggtitle("geom_quantile only")
a2 <- worldbankdata |>
  ggplot(aes(y=Cooking, x = Electricity)) + 
  geom_quantile() + 
  geom_point() +
  ggtitle("geom_quantile and geom_point")
a1|a2

Example 2

q <- seq(0.05, 0.95, by = 0.05)
a3 <- worldbankdata |>
  ggplot(aes(y=Cooking, x = Electricity)) + 
  geom_quantile(method = "rqss") + 
  ggtitle("geom_quantile with method rqss")
a4 <- worldbankdata |>
  ggplot(aes(y=Cooking, x = Electricity)) + 
  geom_quantile(method = "rqss") + 
  geom_point() +
  ggtitle("geom_quantile with \n method rqss and geom_point")
a3|a4

Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.