\begin{Schunk}
\begin{Sinput}
 mymod7 <- lm(y ~ rcs(x,7), data=dat)
 predict7 <- mymod7$fitted.values
 mymod8 <- lm(y ~ rcs(x,8), data=dat)
 predict8 <- mymod8$fitted.values
 mymod9 <- lm(y ~ rcs(x,9), data=dat)
 predict9 <- mymod9$fitted.values
 plot(x,y,main="5- 9 Knots!", pch=16)
 lines(dat$x, predict5, col=1, lty=1)
 lines(dat$x, predict6, col=2, lty=2)
 lines(dat$x, predict7, col=3, lty=3)
 lines(dat$x, predict8, col=4, lty=4)
 lines(dat$x, predict9, col=5, lty=5)
 legend("top",legend=paste("knots",5:9),col=1:5,lty=1:5)
\end{Sinput}
\end{Schunk}
