I have a linear regression across deciles of a variable (highly skewed) and I've plotted a line across the deciles to predict the outcome variability. The plot does give me a regression line across the deciles however I want to add median values of each decile on the X axis to better explain the distribution of my variable.
ggplotRegression <- function (fit) {
require(ggplot2)
ggplot(fit$model, aes_string(x = names(fit$model)[2], y = names(fit$model)[1])) +
geom_point() +
stat_smooth(method = "lm", col = "red") +
labs(title = paste("Adj R2 = ",signif(summary(fit)$adj.r.squared, 5),
"Intercept =",signif(fit$coef[[1]],5 ),
" Slope =",signif(fit$coef[[2]], 5),
" P =",signif(summary(fit)$coef[2,4], 5)))
}
ggplotRegression(lm(math_score ~ lead_decile, data=mkf1))