This preview shows pages 1–6. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
STA 414/2104 Jan 12, 2010 Polynomial regression I See R code from last week I lm10 = lm ( y ˜ x + I(xˆ2) + I(xˆ3) + . .. + I(xˆ10) ) I i.e. E ( y ) = β 0 + β 1 x + β 2 x 2 + ... + β 10 x 10 y = X β + ± I fm10 = lm ( y ˜ poly(x, 10) ) I E ( y ) = α 0 + α 1 P 1 ( x ) + ··· + α 10 P 10 ( x ) y = X * α + ± I P j ( x ) = a 0 j + a 1 j x + a 2 j x 2 + ··· + a jj x j I coefﬁcients a 0 j , a 1 j , etc. to be determined I so that columns of X * are orthogonal 2 / 23
STA 414/2104 Jan 12, 2010 ... polynomial regression >x [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 > model.matrix(lm10) (Intercept) x I(xˆ2) I(xˆ3) I(xˆ4) I(xˆ5) I(xˆ6) . .. 1 1 0.0 0.00 0.000 0.0000 0.00000 0.000000 2 1 0.1 0.01 0.001 0.0001 0.00001 0.000001 3 1 0.2 0.04 0.008 0.0016 0.00032 0.000064 4 1 0.3 0.09 0.027 0.0081 0.00243 0.000729 5 1 0.4 0.16 0.064 0.0256 0.01024 0.004096 6 1 0.5 0.25 0.125 0.0625 0.03125 0.015625 7 1 0.6 0.36 0.216 0.1296 0.07776 0.046656 8 1 0.7 0.49 0.343 0.2401 0.16807 0.117649 9 1 0.8 0.64 0.512 0.4096 0.32768 0.262144 10 1 0.9 0.81 0.729 0.6561 0.59049 0.531441 11 1 1.0 1.00 1.000 1.0000 1.00000 1.000000 > model.matrix(fm10) (Intercept) poly(x, degree)1 poly(x, degree)2 poly(x, degree)3 . .. 1 1 -4.767313e-01 0.51209156 -4.580286e-01 2 1 -3.813850e-01 0.20483662 9.160572e-02 3 1 -2.860388e-01 -0.03413944 3.358876e-01 4 1 -1.906925e-01 -0.20483662 3.511553e-01 5 1 -9.534626e-02 -0.30725493 2.137467e-01 6 1 -1.323195e-17 -0.34139437 6.621275e-17 7 1 9.534626e-02 -0.30725493 -2.137467e-01 8 1 1.906925e-01 -0.20483662 -3.511553e-01 9 1 2.860388e-01 -0.03413944 -3.358876e-01 10 1 3.813850e-01 0.20483662 -9.160572e-02 11 1 4.767313e-01 0.51209156 4.580286e-01 3 / 23

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
STA 414/2104 Jan 12, 2010 ... polynomial regression I same ˆ y = X ˆ β = X * ˆ α I > lm10\$fitted.values 1 2 3 4 5 0.023170726 0.600194667 0.953585931 0.613647096 0.015437840 6 7 8 9 10 0.000285572 -0.107110688 -1.329937671 -0.743709343 -0.625900416 11 0.249038261 > fm\$fitted.values 1 2 3 4 5 0.023170726 0.600194667 0.953585931 0.613647096 0.015437840 6 7 8 9 10 0.000285572 -0.107110688 -1.329937671 -0.743709343 -0.625900416 11 0.249038261 0.0 0.2 0.4 0.6 0.8 1.0 -1.0 0.0 1.0 x y 4 / 23
STA 414/2104 Jan 12, 2010 Bias-variance trade-off

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.