我想使用lattice
R包为随机森林模型将qq-line添加到普通qq-plot中。我知道可以在ggplot
和plotly
中进行此操作,但是这次我对lattice
感兴趣。
data("cars")
library(randomForest)
library(lattice)
rf_model <- randomForest(speed ~ dist, data = cars)
residuals <- predict(rf_model, cars) - cars$speed
qqmath( ~ residuals, main = "Normal Q-Q plot",
xlab = "Theorethical quantiles",
ylab = "Residuals")