R warnings - simpleLoess, pseudoinverse etc

ggplot2

#1

I am getting lot of warning while plotting data using ggplot2.

Code below seems to work fine.

> library(tidyverse)
> ggplot(mpg) + geom_smooth(mapping = aes(x = displ, y = hwy, color = drv), se = FALSE)
`geom_smooth()` using method = 'loess'

The code that gives warnings:

> ggplot(mpg) + geom_smooth(mapping = aes(x = displ, y = hwy, color = class), se = FALSE)
`geom_smooth()` using method = 'loess'
Warning messages:
1: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  span too small.   fewer data values than degrees of freedom.
2: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  pseudoinverse used at 5.6935
3: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  neighborhood radius 0.5065
4: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  reciprocal condition number  0
5: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  There are other near singularities as well. 0.65044
6: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  pseudoinverse used at 4.008
7: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  neighborhood radius 0.708
8: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  reciprocal condition number  0
9: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  There are other near singularities as well. 0.25

I can see the problem is with choosing the color. I got one explanation from Stackoverflow: a proper smoothing requires a continuous variable than a discreet one : But in my case, both variables are discreet. drv = f,r,4 and class = SUV, compact etc. Then I should warnings for both.


#2

These are warning messages that occur when you apply the LOESS smoother to two classes. Loess is in the stats package that come with R. ggplot2 is delivering these warnings from loess to you. In fact, these warning messages come from the fortran code that implement the loess method.

I'm not an expert on LOESS, but here's an extract from Statistical Models for S, "Error Messages from the Bowels of Loess", suggesting these warnings come when there are few observations in this areas of plot.