I am using geom_smooth to generate smoothed loess model for my set of data. I am using predict(loess( to attempt to generate the points of the smoothed model but the points predicted by the predict function do not correlate to the graphed smooth line (from p + geom_smooth)
p <- ggplot(data=tabelVals, aes(x=as.numeric(as.character(PEG)), y=as.numeric(as.character(MAB)), colour=Sample)) +
geom_point() +
geom_line()
p <- p + labs(x = "PEG-3350 (%)") + labs(y = "Mab (9mg/mL)")
p <- p + geom_point(data=c.peg.mab, aes(x=as.numeric(as.character(PEG)), y = as.numeric(as.character(MAB)), colour=Sample),size=5)
p <- p + geom_smooth(method= "loess", se= FALSE)
smooth_vals = predict(loess((as.numeric(as.character(MAB)))~(as.numeric(as.character(PEG))),tabelVals, se=FALSE))
I expect that by graphing smooth_vals I would get a line very similar to the geom_smooth line but the points are no where near their respective lines