> hills.lm Call: lm(formula = time ~ dist + climb, data = hills) Coefficients: (Intercept) dist climb -8.99204 6.21796 0.01105 > model.matrix(hills.lm) (Intercept) dist climb Greenmantle 1 2.5 650 Carnethy 1 6.0 2500 Craig Dunain 1 6.0 900 Ben Rha 1 7.5 800 Ben Lomond 1 8.0 3070 Goatfell 1 8.0 2866 Bens of Jura 1 16.0 7500 Cairnpapple 1 6.0 800 Scolty 1 5.0 800 Traprain 1 6.0 650 Lairig Ghru 1 28.0 2100 Dollar 1 5.0 2000 Lomonds 1 9.5 2200 Cairn Table 1 6.0 500 Eildon Two 1 4.5 1500 Cairngorm 1 10.0 3000 Seven Hills 1 14.0 2200 Knock Hill 1 3.0 350 Black Hill 1 4.5 1000 Creag Beag 1 5.5 600 Kildcon Hill 1 3.0 300 Meall Ant-Suidhe 1 3.5 1500 Half Ben Nevis 1 6.0 2200 Cow Hill 1 2.0 900 N Berwick Law 1 3.0 600 Creag Dubh 1 4.0 2000 Burnswark 1 6.0 800 Largo Law 1 5.0 950 Criffel 1 6.5 1750 Acmony 1 5.0 500 Ben Nevis 1 10.0 4400 Knockfarrel 1 6.0 600 Two Breweries 1 18.0 5200 Cockleroi 1 4.5 850 Moffat Chase 1 20.0 5000 attr(,"assign") [1] 0 1 2 > qr(model.matrix(hills.lm)) $qr (Intercept) dist climb Greenmantle -5.9160798 -44.539629224 -1.073954e+04 Carnethy 0.1690309 32.209803299 6.158923e+03 Craig Dunain 0.1690309 0.024883336 7.155677e+03 Ben Rha 0.1690309 -0.021686337 1.340319e-01 Ben Lomond 0.1690309 -0.037209561 -1.719681e-01 Goatfell 0.1690309 -0.037209561 -1.434592e-01 Bens of Jura 0.1690309 -0.285581149 -6.113673e-01 Cairnpapple 0.1690309 0.024883336 1.003401e-01 Scolty 0.1690309 0.055929785 7.787894e-02 Traprain 0.1690309 0.024883336 1.213025e-01 Lairig Ghru 0.1690309 -0.658138531 4.128126e-01 Dollar 0.1690309 0.055929785 -8.982007e-02 Lomonds 0.1690309 -0.083779234 -1.669450e-02 Cairn Table 0.1690309 0.024883336 1.422649e-01 Eildon Two 0.1690309 0.071453009 -3.117608e-02 Cairngorm 0.1690309 -0.099302458 -1.172632e-01 Seven Hills 0.1690309 -0.223488252 8.438091e-02 Knock Hill 0.1690309 0.118022682 9.584366e-02 Black Hill 0.1690309 0.071453009 3.869850e-02 Creag Beag 0.1690309 0.040406560 1.170594e-01 Kildcon Hill 0.1690309 0.118022682 1.028311e-01 Meall Ant-Suidhe 0.1690309 0.102499457 -5.363729e-02 Half Ben Nevis 0.1690309 0.024883336 -9.530870e-02 Cow Hill 0.1690309 0.149069130 -3.479584e-03 N Berwick Law 0.1690309 0.118022682 6.090637e-02 Creag Dubh 0.1690309 0.086976233 -1.122813e-01 Burnswark 0.1690309 0.024883336 1.003401e-01 Largo Law 0.1690309 0.055929785 5.691656e-02 Criffel 0.1690309 0.009360112 -2.119097e-02 Acmony 0.1690309 0.055929785 1.198037e-01 Ben Nevis 0.1690309 -0.099302458 -3.129121e-01 Knockfarrel 0.1690309 0.024883336 1.282900e-01 Two Breweries 0.1690309 -0.347674046 -2.450218e-01 Cockleroi 0.1690309 0.071453009 5.966088e-02 Moffat Chase 0.1690309 -0.409766943 -1.721496e-01 attr(,"assign") [1] 0 1 2 $rank [1] 3 $qraux [1] 1.169031 1.024883 1.086365 $pivot [1] 1 2 3 attr(,"class") [1] "qr" > qr.Q(hills.qr) [,1] [,2] [,3] [1,] -0.1690309 -0.1561192840 -0.028479162 [2,] -0.1690309 -0.0474567142 0.136530461 [3,] -0.1690309 -0.0474567142 -0.087068214 [4,] -0.1690309 -0.0008870414 -0.141125850 [5,] -0.1690309 0.0146361829 0.162743864 [6,] -0.1690309 0.0146361829 0.134235033 [7,] -0.1690309 0.2630077710 0.568058193 [8,] -0.1690309 -0.0474567142 -0.101043131 [9,] -0.1690309 -0.0785031627 -0.074321318 [10,] -0.1690309 -0.0474567142 -0.122005507 [11,] -0.1690309 0.6355651533 -0.507249090 [12,] -0.1690309 -0.0785031627 0.093377688 [13,] -0.1690309 0.0612058557 0.001079365 [14,] -0.1690309 -0.0474567142 -0.142967883 [15,] -0.1690309 -0.0940263869 0.036864008 [16,] -0.1690309 0.0767290799 0.099517796 [17,] -0.1690309 0.2009148740 -0.119168793 [18,] -0.1690309 -0.1405960597 -0.083764820 [19,] -0.1690309 -0.0940263869 -0.033010578 [20,] -0.1690309 -0.0629799384 -0.115632059 [21,] -0.1690309 -0.1405960597 -0.090752279 [22,] -0.1690309 -0.1250728355 0.063585821 [23,] -0.1690309 -0.0474567142 0.094605710 [24,] -0.1690309 -0.1716425083 0.019819037 [25,] -0.1690309 -0.1405960597 -0.048827527 [26,] -0.1690309 -0.1095496112 0.120099501 [27,] -0.1690309 -0.0474567142 -0.101043131 [28,] -0.1690309 -0.0785031627 -0.053358943 [29,] -0.1690309 -0.0319334899 0.018357676 [30,] -0.1690309 -0.0785031627 -0.116246070 [31,] -0.1690309 0.0767290799 0.295166637 [32,] -0.1690309 -0.0474567142 -0.128992966 [33,] -0.1690309 0.3251006681 0.193191472 [34,] -0.1690309 -0.0940263869 -0.053972953 [35,] -0.1690309 0.3871935651 0.111798012 > ar.R(hills.qr) Error: couldn't find function "ar.R" > qr.R(hills.qr) (Intercept) dist climb Greenmantle -5.91608 -44.53963 -10739.544 Carnethy 0.00000 32.20980 6158.923 Craig Dunain 0.00000 0.00000 7155.677 > hills.svd <- svd(model.matrix(hills.lm)) > attributes(hills.svd) $names [1] "d" "u" "v" > hills.svd$d [1] 14299.514515 28.023492 3.402744 > hills.svd$u [,1] [,2] [,3] [1,] 0.04545644 -0.014380407 0.22689786 [2,] 0.17483155 0.080398674 0.11150837 [3,] 0.06294026 -0.109332218 0.14996477 [4,] 0.05594740 -0.174589226 0.12197217 [5,] 0.21469329 0.076791868 0.05728011 [6,] 0.20042715 0.052601179 0.06218331 [7,] 0.52449416 0.317315531 -0.21130868 [8,] 0.05594706 -0.121190399 0.15236829 [9,] 0.05594683 -0.085591181 0.17263237 [10,] 0.04545725 -0.138977670 0.15597358 [11,] 0.14686382 -0.750216848 -0.32468728 [12,] 0.13986529 0.056706988 0.14379007 [13,] 0.15385275 -0.079773132 0.04779466 [14,] 0.03496744 -0.156764941 0.15957887 [15,] 0.10489915 0.015215693 0.16593974 [16,] 0.20979851 -0.002707295 0.01843442 [17,] 0.15385379 -0.239969613 -0.04339369 [18,] 0.02447694 -0.067754558 0.22397639 [19,] 0.06993312 -0.044075210 0.17795736 [20,] 0.04196053 -0.127107152 0.16730738 [21,] 0.02098033 -0.073683649 0.22517816 [22,] 0.10489892 0.050814911 0.18620382 [23,] 0.15385194 0.044824132 0.11871894 [24,] 0.06293934 0.033064654 0.23102109 [25,] 0.04195995 -0.038109106 0.21796758 [26,] 0.13986506 0.092306206 0.16405415 [27,] 0.05594706 -0.121190399 0.15236829 [28,] 0.06643663 -0.067803910 0.16902708 [29,] 0.12238263 -0.026337291 0.11940276 [30,] 0.03496721 -0.121165723 0.17984295 [31,] 0.30770339 0.163307236 -0.01521493 [32,] 0.04196065 -0.144906761 0.15717534 [33,] 0.36365089 -0.026621063 -0.19655576 [34,] 0.05944331 -0.061862482 0.18156265 [35,] 0.34966494 -0.121535860 -0.23227687 > hills.svd$v [,1] [,2] [,3] [1,] 0.0003107284 -0.068952829 9.976199e-01 [2,] 0.0033095276 -0.997614387 -6.895348e-02 [3,] 0.9999944752 0.003323076 -8.178581e-05 > qqnorm(hills.lm$residuals) > plot(hills.lm$fitted,hills.lm$residuals) > hat(hills.lm) Error in as.double.default(list(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, c(-8.99203895742595, : (list) object cannot be coerced to double > ?hat > hatvalues(hills.lm) Greenmantle Carnethy Craig Dunain Ben Rha 0.05375572 0.04946414 0.03840444 0.04848872 Ben Lomond Goatfell Bens of Jura Cairnpapple 0.05527121 0.04680469 0.42043463 0.04103328 Scolty Traprain Lairig Ghru Dollar 0.04025783 0.04570891 0.68981613 0.04345357 Lomonds Cairn Table Eildon Two Cairngorm 0.03231875 0.05126338 0.03877135 0.04436257 Seven Hills Knock Hill Black Hill Creag Beag 0.08313942 0.05535523 0.03850209 0.04590867 Kildcon Hill Meall Ant-Suidhe Half Ben Nevis Cow Hill 0.05657466 0.04825780 0.03977381 0.05842537 N Berwick Law Creag Dubh Burnswark Largo Law 0.05072281 0.05499644 0.04103328 0.03758135 Criffel Acmony Ben Nevis Knockfarrel 0.02992818 0.04824732 0.12158212 0.04746275 Two Breweries Cockleroi Moffat Chase 0.17158482 0.04032547 0.19098908 > plot(hills.lm) Hit to see next plot: Hit to see next plot: Hit to see next plot: Hit to see next plo