##
## Attaching package: 'dplyr'
## The following object is masked from 'package:MASS':
##
## select
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
先做出Box-Cox轉換,看看應該選取哪個\(\lambda\)
boxcox<-boxcox(BIO~SAL+pH+K+Na+Zn,data=HW,lambda = seq(0, 2, length = 10))

box.df<-as.data.frame(boxcox)
\(\lambda\)大約落在0到0.5之間
r<-box.df %>% filter(y==max(y)) %>% select(x) %>% as.numeric()
r
## [1] 0.3636364
畫出原本資料的QQplot
y=HW$BIO
qqnorm(y)
qqline(y,col=2)

畫出轉換後資料的QQplot
yhat=y^r
qqnorm(yhat,new=T)
qqline(yhat,col=3)

比較兩者之間的R-sqare
c$adj.r.squared#原本模型的R-sqare
## [1] 0.6359478
d$adj.r.squared#後來模型的R-sqare
## [1] 0.5850521