1. Investigate and explain the analysis that is achieved in the following R script .
    由圖可以看到,分組之後的結果顯示歐洲與非洲及亞州的趨勢不同,如果我們將三者視為一體來看,很容易忽略每組之間的差異。

7.Replicate the plot below which describes the relationship between bmi (body mass index) in logarithmic unit and age (between 5 and 13 years) based on a sample of 7,482 Dutch boys from the data set boys7482{AGD}.

pkgs <- c("dplyr", "tidyr", "magrittr", "ggplot2", "AGD" , "quantreg")
lapply(pkgs, require, character.only = TRUE)
  [[1]]
  [1] TRUE
  
  [[2]]
  [1] TRUE
  
  [[3]]
  [1] TRUE
  
  [[4]]
  [1] TRUE
  
  [[5]]
  [1] TRUE
  
  [[6]]
  [1] TRUE
dta<-boys7482

qs <- 1:9/10

m0 <- rq(bmi ~ age, data = dta, tau = qs)

#
ggplot(dta, aes(age, log(bmi))) + 
  geom_point(alpha=.5) + 
  geom_quantile(quantiles = qs)+
  labs(x = "Age", y = "BMI") +
  xlim(5,13)+
  ylim(2.5,3.3)+
  theme_bw()