# Examples of linear regression models where one variable is continuous and one is categorical with more than two categories

I looking for examples where someone has graphed the results of a simple linear regression model where the dependent variable is continuous and the predictor variable is categorical with more than two categories.

For example, predicting mean temperatures from 3 different types of ovens.

I am finding plenty of graphed examples with two categories, but none with 3 or 4 categories. I would like to visually know what the model would look like on the data.

Thanks.

This overview of visuals from ggplot shows several options:

• histograms
• density plots
• (Tufte styled)
• box plots
• violin plots

If it is all just about presenting the results/output of a regression model (predicted means, error, other calculated statistics, etc), and not an actual image of the raw data, then a table will be sufficient.

A quick example (just one out of the many variations!) using R and the referred package:

ggplot(data = iris, aes(x=Petal.Length,
fill=Species,
color=Species,
facet=Species)
) +
geom_histogram(position="identity", alpha=0.5, bins=50) +
geom_density(alpha=0.5) +
scale_fill_manual(values=c("#009999", "#AAAAAA", "#999900")) +
scale_color_manual(values=c("#009999", "#AAAAAA", "#999900"))


• I am looking for a way to visually look at how well the model fits the data. Commented Jul 5, 2017 at 15:42
• I have added a visual example. The model would be just the three averages, setosa ~ 1.462, versicolor ~ 4.260, virginica ~ 5.552 and you may do some anova or other statistical stuff to place a (modelled) number on setosa being more different from the other two. Commented Jul 5, 2017 at 15:55
• The case of DependentContinuousVariable ~ IndependentFactorVariable is not so complex and the described graphs provide a good insight. In more complex models you could plot the residuals (which can be done in various way, but the idea/principle is the same every time). Commented Jul 5, 2017 at 15:58