JerryTheForester
JerryTheForester

Reputation: 476

Add qqline to normal qqplot for random forest model with lattice in r

I would like to use lattice R package to add qq-line to normal qq-plot for random forest model. I know there are ways to do this in ggplot and plotly, but I am interested in lattice this time.

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")

Upvotes: 1

Views: 404

Answers (0)

Related Questions