Doing the regression yourself
The smooth geom will add the regression line to the plot but doesn’t show the results of the regression like the predicted values or the residuals. When you want to see the results of the regression, you have to do the regression yourself using lm() or glm()
Linear regression using lm()
You can specify the model using the formula and the data arguments.
Linear regression using glm()
This function fits a generalized linear model (what you need when the data are not normal). This function has an additional argument: family, that allows to define:
- a transformation for the Y values: identity (no transformation), log, logit…
- the distribution of the data/residuals: gaussian (normal), gamma, poisson…