I need to fit a smoothed/cumulative distribution function to my data and afterwards be able to predict the x-value by a given y, this is what my code looks like atm but it doesn´t work as expected, because loess probably isn´t the right method (even goes below y<0) and the prediction doesn´t seem to work, too. Any help would be highly appreciated!
test<-data.frame("xvar"=c(0.01,0.86,2,6.3,20),"yvar"=c(0.14,0.16,5.16,89.77,100))
(testplot <- ggplot(test,aes(x=xvar,y=yvar)) +
geom_point(lwd=1) +
geom_line(col="red") +
geom_smooth(method = "loess") +
scale_x_continuous(trans='log10') +
xlab("X") +
ylab("Y") +
labs(title="Test"))
testf<-stats::loess(yvar~xvar, data = test)
predict(testf, 10)
Just eye-balling, but it looks like your data follows a logistic(ish) function. What about this:
EDIT:
I see that you want to then calculate X given a Y: