\begin{Schunk}
\begin{Sinput}
 mymod5 <- lm(y ~ rcs(x, 5))
 predict5 <- predict(mymod5, newdata = data.frame(x = newx))
 plot(x, y, main = "5 Knots! Using lm(y~rcs(x,5))", pch = 16)
 lines(newx, predict5)
 summary(mymod5)
\end{Sinput}
\begin{Soutput}
Call:
lm(formula = y ~ rcs(x, 5))

Residuals:
    Min      1Q  Median      3Q     Max 
-2.8319 -0.6288 -0.0866  0.7363  3.2213 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)      1.1623     0.4637   2.507   0.0139 *  
rcs(x, 5)x       1.8992     0.2710   7.009 3.46e-10 ***
rcs(x, 5)x'    -39.8111     2.1626 -18.409  < 2e-16 ***
rcs(x, 5)x''   119.3189     5.5632  21.448  < 2e-16 ***
rcs(x, 5)x''' -161.6405     6.5280 -24.761  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 1.084 on 95 degrees of freedom
Multiple R-squared: 0.8859,	Adjusted R-squared: 0.8811 
F-statistic: 184.4 on 4 and 95 DF,  p-value: < 2.2e-16 
\end{Soutput}
\begin{Sinput}
 cbind(newx, predict5)
\end{Sinput}
\begin{Soutput}
          newx   predict5
1   0.00210552  1.1662979
2   0.06106475  1.2782739
3   0.33469796  1.7979610
4   0.37955814  1.8831600
5   0.48599136  2.0852991
6   0.77206219  2.6286064
7   0.85683699  2.7891235
8   1.20762161  3.4099905
9   1.29229855  3.5397490
10  1.33127940  3.5957022
11  1.39863356  3.6860760
12  1.47290081  3.7755080
13  1.52775669  3.8339833
14  1.54564680  3.8515644
15  1.67968159  3.9578609
16  1.91766875  4.0186784
17  1.99658999  3.9970325
18  2.01918815  3.9866068
19  2.03157764  3.9800672
20  2.04221337  3.9739824
21  2.06775416  3.9575707
22  2.07802581  3.9502455
23  2.14594866  3.8910609
24  2.18698444  3.8459900
25  2.20074307  3.8292613
26  2.27345405  3.7269650
27  2.49475581  3.2617947
28  2.54724884  3.1149706
29  2.54731530  3.1147754
30  2.64218166  2.8126050
31  2.66673836  2.7270922
32  2.67585596  2.6946184
33  2.71177845  2.5629727
34  2.72833601  2.5003597
35  2.79577002  2.2334298
36  2.89062389  1.8283182
37  3.00697577  1.2909532
38  3.01542637  1.2504220
39  3.03849314  1.1388605
40  3.17673893  0.4455909
41  3.40140350 -0.7395228
42  3.40869728 -0.7785814
43  3.49447253 -1.2381157
44  3.77712691 -2.7157259
45  3.86841773 -3.1651528
46  3.89853382 -3.3089513
47  4.05873046 -4.0280069
48  4.10339568 -4.2125667
49  4.49652642 -5.4340087
50  4.59236590 -5.5969036
51  5.01731817 -5.4984622
52  5.27829925 -4.8028598
53  5.30339800 -4.7153076
54  5.44745519 -4.1535784
55  5.53752308 -3.7568095
56  5.60305779 -3.4492552
57  5.64230267 -3.2583062
58  5.76476927 -2.6344913
59  5.86957035 -2.0736462
60  5.92946445 -1.7448758
61  5.96511357 -1.5470525
62  6.00197098 -1.3412138
63  6.11115183 -0.7266595
64  6.30979573  0.3880121
65  6.52050091  1.5190435
66  6.58730457  1.8574354
67  6.65814839  2.2021392
68  6.91535968  3.2965723
69  6.97856984  3.5195966
70  6.99052999  3.5594462
71  7.00783954  3.6157466
72  7.01309871  3.6325266
73  7.03756451  3.7085558
74  7.08983787  3.8597187
75  7.16150878  4.0424257
76  7.21419307  4.1590427
77  7.28683573  4.2959049
78  7.65025629  4.5919472
79  7.79771912  4.5431649
80  7.93278905  4.4218151
81  8.00569337  4.3277991
82  8.13740844  4.1105538
83  8.20199523  3.9829660
84  8.33812538  3.6719355
85  8.39256748  3.5325102
86  8.44498774  3.3906357
87  8.58134708  2.9887909
88  8.76610782  2.3767268
89  8.79149843  2.2872033
90  9.06042068  1.2724375
91  9.18289139  0.7771799
92  9.24301687  0.5282417
93  9.46087836 -0.3970060
94  9.48968545 -0.5212881
95  9.64241509 -1.1837811
96  9.79616788 -1.8522109
97  9.86411969 -2.1476269
98  9.96368176 -2.5804663
99  9.98436198 -2.6703722
100 9.99126597 -2.7003868
\end{Soutput}
\end{Schunk}
