Created
February 13, 2020 16:33
-
-
Save BenHeubl/652fba89132ee4b4a94e3c2ab2d46867 to your computer and use it in GitHub Desktop.
tut13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("relaimpo") | |
library(relaimpo) | |
#fit linear model: | |
Ozone_model <- lm(ozone_reading ~ . , data = Ozone) | |
#Get relative importance: | |
Relative_importance <- calc.relimp(lmMod, type = "lmg", rela = TRUE) | |
# Relative importance scaled to 100 and plot: | |
plot_RI <- as.data.frame(sort(relImportance$lmg, decreasing=TRUE)) | |
colnames(plot_RI)[1] = 'value' | |
plot_RI$ID <- seq.int(nrow(plot_RI)) | |
ggplot(plot_RI, aes(ID, value)) + | |
geom_point(col = 'blue') + | |
geom_text(label = rownames(plot_RI), nudge_y = 0.042) + | |
ylim(c(0,0.3)) + | |
coord_flip() + | |
theme_minimal() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment