# What is represented by the y-axis in a loess smoothing curve?

I'm working on the Titanic data and I plotted local regression curves for a couple predictors.

library('vcdExtra')
data(Titanicp)

ggplot(Titanicp, aes(age, as.numeric(survived)-1, color=sex)) +
stat_smooth(method="loess", formula=y~x,
alpha=0.2, size=2, aes(fill=sex)) + facet_grid(~pclass)


I thought the y-axis was probability, but it exceeds 1. What is it?

• Your code is not reproducible - there is no object imp.train defined with that code.
– Ben
Commented Jan 22, 2019 at 1:01
• Let's underline that once you've specified age, class, sex you're often not playing with much data for each smoothed value, regardless of neighbouring values providing support. So uncertainty about the smooths should be no surprise, and as @peteR flags, the routine doesn't know about the bounds on the response. Commented Jan 22, 2019 at 9:01

## 2 Answers

R (ggplot) does not know that it is a probability and the loess curve might therefore leave the range [0,1].

The plot gives you the answer - it is the variable as.numeric(Survived) - 1. So, whatever your Survived variable is, this is converting it to a number, then subtracting one. The result of that operation is what is plotted on the vertical axis. Since you have used a loess fit, the curves are showing a smoothed estimate of this variable.

• That's the question. Survived is a 1/0 factor variable, so it showing the percent who survived by age and gender. Which poses the question, how do you get > 100% survival? Commented Jan 22, 2019 at 0:48