2

I'm plotting a dataset with a trendline, but using ols vs lowess gives me significantly different line shapes. I'm sure this is an expected and perfectly normal result, but I'm afraid I don't understand the significance of the difference. Could someone explain what's going on? Here's my code using ols:

fig = px.scatter(df_small, y="Ratio",
                 trendline="ols", 
                 trendline_color_override="red")
fig.show()

And here's the plot it produced: enter image description here

Using lowess gave me this plot: enter image description here For context, my dataset represents the ratio of daily Covid deaths:new infections in the Province of Ontario over the previous 18 months.

dlanced
  • 123
  • 1
  • 5

1 Answers1

2

I was curious so I looked it up:

For the record I did a small test with R and ggplot2 which seems to have a better implementation:

library(ggplot2)
library(plyr)

t<-seq(0,12,.1) noise<-rnorm(121,0,.25) v<-cos(t)+noise d<-data.frame(x=t,y=v) ggplot(d,aes(x,y))+geom_point()+ geom_smooth(method="loess")

noisy curve with loess regression in ggplot2

Erwan
  • 26,519
  • 3
  • 16
  • 39