I am trying to plot only a few regression lines and not any of the points. (No fitted
, because I have over 7 thousand points.) I know how to do this with linear regressions, but not with polynomial regression. My data is here. With a few linear regressions:
plot_data=read.csv("plot_data.csv") #read data
#linear regressions
Off_linear=lm(Z_Salary~OBPM,data=plot_data)
Def_linear=lm(Z_Salary~DBPM,data=plot_data)
Tot_linear=lm(Z_Salary~BPM,data=plot_data)
#try to plot. This works. Not sure how to add legend
termplot(Def_linear, ylab='Z_Salary',xlab='BPM',ylim=c(-2, 2))
abline(Off_linear)
abline(Tot_linear,col='blue')
However I cannot do this if I try to create polynomial regressions. I want the same kind of plot with these regressions, but termplot
does work with independent variables together and does them separately.
Off_exp=lm(Z_Salary~OBPM+I(OBPM^2),data=plot_data)
Def_exp=lm(Z_Salary~DBPM+I(DBPM^2),data=plot_data)
Tot_exp=lm(Z_Salary~BPM+I(BPM^2),data=plot_data)