Fit non-linear customised model
I have a data.frame
that have two cols, $x=mz$ and $y=res$. There are about ~2 million rows in the DF. When I plot the graph I get the below.
What I'd like to do is find a way to define two quadratics to fit to get the two curves badly sketched in orange. it would be nice to be able to do it in ggplot. I have tried to fit a stat_smooth but I haven't been able to come close to the result I want.
plot - ggplot(data=df, aes(mz, res)) + geom_point()
plot + stat_smooth(method = lm, formula = y ~ I(x^-2) - x)
Apologies if this is something really trivial and obvious, but I am not a data scientist and I am just trying to help a friend.
Topic ggplot2 linear-regression r
Category Data Science