- Of the 5 glm() models you ran, which appears to be the best model? Support your answer by providing the relevant information from your R output. You should also provide ΔAIC values for all 5 models in your answer.
- Of your 5 models, what was the model weight (Akaike weight) of the second best model? Show your calculation of this value.
- Provide the image of the graph showing the confidence and prediction limits for the role of latitude in explaining elevation of ponderosa pine.
- Provide the 95% confidence and prediction limits, as well as the predicted point value of elevation for ponderosa pine at 39.006 degrees N latitude?

Type | Long | lat | Elev | MeanTemp |

1 | -113.651 | 35.588 | 1617 | 124 |

1 | -121.161 | 39.046 | 364 | 153 |

1 | -123.936 | 43.062 | 283 | 108 |

1 | -106.672 | 37.661 | 2672 | 28 |

1 | -122.658 | 39.084 | 612 | 132 |

1 | -107.852 | 27.622 | 2041 | 139 |

1 | -121.052 | 40.799 | 1723 | 68 |

1 | -117.339 | 45.172 | 2548 | -3 |

1 | -120.181 | 45.029 | 982 | 79 |

1 | -115.187 | 47.257 | 1140 | 37 |

1 | -122.122 | 41.785 | 1516 | 63 |

1 | -115.696 | 49.33 | 1584 | 20 |

1 | -123.536 | 41.593 | 772 | 102 |

1 | -123.999 | 43.226 | 116 | 114 |

1 | -106.711 | 36.389 | 2393 | 48 |

1 | -99.564 | 23.495 | 1847 | 171 |

1 | -107.745 | 28.325 | 2266 | 124 |

1 | -123.402 | 40.228 | 829 | 106 |

1 | -104.913 | 36.63 | 2198 | 74 |

1 | -120.343 | 41.971 | 1434 | 81 |

1 | -117.795 | 50.18 | 427 | 72 |

1 | -115.609 | 45.115 | 1269 | 67 |

1 | -109.882 | 34.007 | 1947 | 105 |

1 | -106.161 | 26.232 | 2506 | 132 |

1 | -119.958 | 37.375 | 674 | 144 |

1 | -117.236 | 48.049 | 652 | 81 |

1 | -119.069 | 48.297 | 1221 | 50 |

1 | -111.466 | 34.737 | 2152 | 85 |

1 | -119.34 | 37.197 | 779 | 153 |

1 | -114.92 | 45.112 | 1558 | 46 |

1 | -106.701 | 26.377 | 2211 | 149 |

1 | -122.613 | 40.869 | 1237 | 90 |

1 | -116.028 | 45.291 | 1781 | 29 |

1 | -120.924 | 40.502 | 1788 | 61 |

1 | -116.525 | 47.543 | 770 | 77 |

1 | -117.976 | 48.801 | 552 | 76 |

1 | -120.345 | 49.392 | 1382 | 28 |

1 | -121.804 | 36.281 | 722 | 121 |

1 | -115.542 | 45.564 | 1960 | 11 |

1 | -115.397 | 46.354 | 944 | 58 |

1 | -117.572 | 48.48 | 1304 | 48 |

1 | -106.111 | 43.34 | 1655 | 70 |

1 | -121.21 | 46.953 | 1420 | 40 |

1 | -116.618 | 45.994 | 912 | 80 |

1 | -120.627 | 38.507 | 878 | 140 |

1 | -108.322 | 37.946 | 2439 | 55 |

1 | -104.181 | 41.443 | 1647 | 79 |

1 | -121.702 | 44.439 | 969 | 71 |

1 | -114.815 | 44.778 | 1557 | 44 |

1 | -102.736 | 28.778 | 1049 | 199 |

1 | -119.686 | 50.619 | 949 | 48 |

1 | -118.897 | 49.325 | 836 | 57 |

1 | -123.18 | 41.771 | 1251 | 74 |

1 | -121.455 | 42.867 | 1420 | 64 |

1 | -111.063 | 34.742 | 1917 | 100 |

1 | -108.408 | 29.488 | 2081 | 122 |

1 | -121.084 | 42.194 | 1469 | 67 |

1 | -117.666 | 45.834 | 1030 | 64 |

1 | -122.748 | 45.259 | 30 | 115 |

1 | -123.578 | 39.392 | 323 | 117 |

1 | -120.804 | 38.806 | 744 | 143 |

1 | -108.549 | 37.513 | 2109 | 80 |

1 | -119.373 | 44.853 | 949 | 82 |

1 | -108.572 | 38.885 | 2237 | 72 |

1 | -113.615 | 36.338 | 1797 | 113 |

1 | -120.771 | 41.073 | 1590 | 67 |

1 | -116.521 | 48.722 | 1170 | 48 |

1 | -105.17 | 35.426 | 1946 | 94 |

1 | -122.14 | 41.494 | 1870 | 49 |

1 | -106.188 | 36.596 | 2526 | 51 |

1 | -111.994 | 46.957 | 1326 | 57 |

1 | -100.641 | 25.081 | 1890 | 174 |

1 | -117.201 | 47.177 | 762 | 79 |

1 | -115.58 | 44.012 | 1879 | 26 |

1 | -122.941 | 41.626 | 816 | 102 |

1 | -99.645 | 23.206 | 2173 | 169 |

1 | -115.706 | 44.495 | 2064 | 11 |

1 | -106.937 | 26.584 | 2141 | 162 |

1 | -104.044 | 41.138 | 1594 | 78 |

1 | -115.862 | 49.239 | 1001 | 54 |

1 | -114.096 | 47.499 | 925 | 72 |

1 | -112.718 | 35.463 | 1898 | 98 |

1 | -117.125 | 47.096 | 767 | 79 |

1 | -103.954 | 45.603 | 946 | 67 |

1 | -117.745 | 47.649 | 738 | 81 |

1 | -117.2 | 49.143 | 1079 | 54 |

1 | -99.491 | 41.71 | 768 | 87 |

1 | -119.244 | 37.351 | 1670 | 95 |

1 | -99.938 | 23.309 | 1809 | 182 |

1 | -121.199 | 41.482 | 1435 | 79 |

1 | -111.676 | 37.829 | 2004 | 80 |

1 | -117.739 | 44.609 | 1630 | 38 |

1 | -121.303 | 43.047 | 1638 | 54 |

1 | -119.859 | 49.849 | 1148 | 35 |

1 | -101.066 | 24.882 | 1834 | 192 |

1 | -120.221 | 42.444 | 2131 | 39 |

1 | -120.117 | 49.451 | 1475 | 24 |

1 | -116.557 | 46.318 | 1090 | 65 |

1 | -104.748 | 35.913 | 1947 | 95 |

1 | -106.127 | 36.702 | 2797 | 34 |

2 | -113.443 | 46.317 | 1831 | 29 |

2 | -130.966 | 59.645 | 1380 | -43 |

2 | -127.277 | 55.627 | 867 | 11 |

2 | -136.021 | 61.028 | 1528 | -56 |

2 | -120.963 | 47.692 | 1403 | 28 |

2 | -116.068 | 45.572 | 1522 | 38 |

2 | -108 | 37.442 | 3606 | -13 |

2 | -121.522 | 54.609 | 1495 | -12 |

2 | -114.352 | 48.286 | 915 | 58 |

2 | -125.148 | 55.648 | 1357 | -8 |

2 | -133.434 | 61.245 | 1128 | -39 |

2 | -124.701 | 56.598 | 731 | 4 |

2 | -127.447 | 53.514 | 1027 | 30 |

2 | -122.346 | 54.873 | 764 | 24 |

2 | -127.025 | 51.578 | 1259 | 28 |

2 | -116.411 | 54.584 | 899 | 15 |

2 | -129.478 | 57.549 | 1255 | -10 |

2 | -124.023 | 61.174 | 509 | -37 |

2 | -119.937 | 48.693 | 2114 | -4 |

2 | -117.057 | 54.351 | 829 | 25 |

2 | -121.651 | 46.756 | 1169 | 66 |

2 | -127.907 | 56.182 | 991 | 0 |

2 | -117.699 | 52.702 | 2162 | -31 |

2 | -119.109 | 54.371 | 1294 | 10 |

2 | -117.345 | 53.132 | 1352 | 11 |

2 | -124.051 | 60.887 | 1504 | -71 |

2 | -106.673 | 35.687 | 1981 | 102 |

2 | -125.277 | 57.997 | 2319 | -59 |

2 | -132.625 | 62.129 | 916 | -49 |

2 | -121.264 | 51.29 | 1080 | 40 |

2 | -130.466 | 60.478 | 1280 | -52 |

2 | -115.356 | 52.038 | 1471 | 0 |

2 | -123.75 | 58.695 | 1042 | -31 |

2 | -134.895 | 61.774 | 1094 | -38 |

2 | -131.191 | 59.522 | 1175 | -36 |

2 | -129.426 | 56.157 | 1277 | 0 |

2 | -126.625 | 54.621 | 1186 | 4 |

2 | -120.641 | 52.917 | 1944 | -12 |

2 | -106.961 | 38.002 | 3423 | -1 |

2 | -121.838 | 53.834 | 787 | 29 |

2 | -107.751 | 39.022 | 3138 | 6 |

2 | -115.891 | 54.351 | 821 | 15 |

2 | -118.844 | 48.55 | 1160 | 47 |

2 | -123.023 | 56.912 | 1592 | -30 |

2 | -113.641 | 47.272 | 1732 | 30 |

2 | -112.447 | 46.504 | 1879 | 30 |

2 | -117.043 | 51.22 | 2186 | -23 |

2 | -127.803 | 61.03 | 1061 | -50 |

2 | -118.726 | 50.659 | 847 | 49 |

2 | -131.745 | 62.878 | 1067 | -65 |

2 | -110.544 | 40.951 | 3014 | 6 |

2 | -124.955 | 49.405 | 412 | 85 |

2 | -117.992 | 49.116 | 1136 | 40 |

2 | -131.114 | 60.937 | 1187 | -53 |

2 | -118.366 | 51.154 | 1442 | 12 |

2 | -128.479 | 57.483 | 1616 | -36 |

2 | -129.648 | 56.59 | 496 | 28 |

2 | -133.561 | 60.246 | 1219 | -34 |

2 | -116.101 | 54.385 | 912 | 14 |

2 | -129.479 | 59.618 | 998 | -33 |

2 | -127.177 | 51.431 | 877 | 50 |

2 | -123.976 | 53.942 | 753 | 26 |

2 | -129.898 | 62.563 | 1497 | -80 |

2 | -120.681 | 51.57 | 1379 | 23 |

2 | -118.048 | 50.701 | 1510 | 13 |

2 | -121.156 | 52.584 | 1171 | 24 |

2 | -124.138 | 51.62 | 1221 | 16 |

2 | -129.809 | 59.566 | 1103 | -29 |

2 | -131.846 | 58.423 | 990 | -8 |

2 | -125.074 | 59.61 | 1185 | -38 |

2 | -116.29 | 51.045 | 1318 | 13 |

2 | -118.726 | 53.739 | 1629 | -7 |

2 | -116.062 | 51.664 | 2687 | -48 |

2 | -126.426 | 59.989 | 659 | -30 |

2 | -110.964 | 44.545 | 2494 | -10 |

2 | -122.351 | 57.579 | 974 | -16 |

2 | -119.029 | 53.011 | 1563 | 7 |

2 | -129.293 | 62.336 | 1487 | -76 |

2 | -127.511 | 54.402 | 1453 | -1 |

2 | -125.238 | 59.521 | 765 | -20 |

2 | -121.932 | 52.426 | 966 | 36 |

2 | -113.712 | 47.207 | 2052 | 27 |

2 | -115.905 | 50.25 | 1001 | 34 |

2 | -125.309 | 60.536 | 954 | -43 |

2 | -115.191 | 48.552 | 1311 | 39 |

2 | -123.889 | 50.231 | 1769 | 23 |

2 | -123.774 | 56.736 | 1723 | -35 |

2 | -123.853 | 57.254 | 1697 | -35 |

2 | -124.195 | 54.034 | 690 | 28 |

2 | -128.288 | 55.875 | 1009 | 12 |

2 | -122.436 | 42.903 | 1056 | 81 |

2 | -120.928 | 54.554 | 1312 | 3 |

2 | -128.407 | 55.409 | 843 | 23 |

2 | -129.649 | 58.565 | 1795 | -44 |

2 | -123.821 | 52.67 | 1210 | 4 |

2 | -134.096 | 61.268 | 1277 | -43 |

2 | -110.755 | 38.085 | 2571 | 51 |

2 | -117.855 | 49.399 | 1679 | 31 |

2 | -133.822 | 59.665 | 700 | -3 |

2 | -129.267 | 60.392 | 681 | -32 |

3 | -125.168 | 52.762 | 1754 | -11 |

3 | -106.506 | 38.053 | 2786 | 21 |

3 | -122.107 | 50.78 | 1287 | 28 |

3 | -112.601 | 43.304 | 1410 | 68 |

3 | -105.497 | 38.638 | 2502 | 41 |

3 | -107.557 | 37.614 | 3618 | -12 |

3 | -106.342 | 34.606 | 2109 | 97 |

3 | -112.188 | 36.706 | 2387 | 63 |

3 | -123.413 | 48.569 | 65 | 94 |

3 | -124.622 | 52.869 | 1535 | -8 |

3 | -123.53 | 48.692 | 0 | 0 |

3 | -105.336 | 38.764 | 2511 | 40 |

3 | -106.45 | 37.015 | 3064 | 20 |

3 | -105.352 | 39.536 | 2639 | 31 |

3 | -117.144 | 49.578 | 915 | 51 |

3 | -117.126 | 49.965 | 2227 | -9 |

3 | -111.709 | 42.44 | 1554 | 66 |

3 | -108.321 | 37.509 | 2551 | 51 |

3 | -107.64 | 44.521 | 2071 | 31 |

3 | -103.729 | 35.631 | 1276 | 136 |

3 | -111.246 | 34.949 | 1928 | 99 |

3 | -111.926 | 36.328 | 2007 | 88 |

3 | -103.157 | 44.004 | 992 | 83 |

3 | -120.636 | 49.535 | 1436 | 25 |

3 | -116.455 | 50.256 | 2540 | -28 |

3 | -114.092 | 46.446 | 1015 | 72 |

3 | -102.644 | 42.708 | 1182 | 80 |

3 | -117.154 | 48.944 | 2095 | 5 |

3 | -111.758 | 34.992 | 1716 | 124 |

3 | -121.094 | 50.485 | 1562 | 20 |

3 | -118.748 | 50.813 | 1853 | -1 |

3 | -111.887 | 41.581 | 1544 | 74 |

3 | -115.545 | 48.435 | 875 | 61 |

3 | -113.766 | 47.481 | 1224 | 55 |

3 | -125.653 | 52.511 | 1492 | 6 |

3 | -118.231 | 50.964 | 561 | 57 |

3 | -107.534 | 44.339 | 1768 | 50 |

3 | -123.118 | 51.353 | 1734 | -2 |

3 | -106.617 | 36.217 | 2196 | 73 |

3 | -114.321 | 42.578 | 1173 | 92 |

3 | -107.18 | 38.464 | 2290 | 38 |

3 | -110.083 | 40.392 | 1733 | 71 |

3 | -122.353 | 52.905 | 994 | 30 |

3 | -117.375 | 50.201 | 2148 | -11 |

3 | -110.021 | 34.245 | 1951 | 99 |

3 | -111.597 | 40.396 | 2076 | 58 |

3 | -121.967 | 52.091 | 712 | 54 |

3 | -117.302 | 50.291 | 2247 | -15 |

3 | -112.372 | 43.919 | 1465 | 58 |

3 | -104.653 | 47.805 | 809 | 51 |

3 | -112.694 | 42.288 | 1757 | 58 |

3 | -125.221 | 54.397 | 1104 | 9 |

3 | -123.213 | 52.365 | 1198 | 11 |

3 | -108.826 | 36.245 | 1868 | 101 |

3 | -121.832 | 51.048 | 1468 | 10 |

3 | -105.747 | 44.726 | 1284 | 67 |

3 | -123.48 | 48.286 | 0 | 0 |

3 | -113.713 | 42.437 | 1292 | 87 |

3 | -119.027 | 49.79 | 1383 | 32 |

3 | -103.405 | 37.297 | 1713 | 105 |

3 | -106.154 | 40.801 | 2474 | 29 |

3 | -119.564 | 52.045 | 1399 | 13 |

3 | -114.5 | 47.093 | 1074 | 62 |

3 | -114.679 | 47.981 | 1432 | 41 |

3 | -118.977 | 51.114 | 654 | 49 |

3 | -117.787 | 50.094 | 1705 | 3 |

3 | -111.435 | 34.65 | 2108 | 90 |

3 | -123.379 | 50.998 | 2125 | -14 |

3 | -108.258 | 33.648 | 2392 | 68 |

3 | -108.362 | 34.214 | 2238 | 77 |

3 | -117.063 | 49.971 | 1890 | 2 |

3 | -125.756 | 52.521 | 1510 | 6 |

3 | -117.515 | 50.046 | 1223 | 33 |

3 | -106.382 | 36.312 | 2250 | 73 |

3 | -102.45 | 44.386 | 717 | 83 |

3 | -121.328 | 51.358 | 1080 | 40 |

3 | -108.354 | 37.12 | 2071 | 87 |

3 | -107.638 | 37.594 | 3437 | -9 |

3 | -119.022 | 49.689 | 1521 | 27 |

3 | -122.71 | 50.876 | 1353 | 21 |

3 | -120.386 | 52.039 | 1698 | 6 |

3 | -120.118 | 51.033 | 1189 | 29 |

3 | -117.534 | 50.169 | 1969 | -5 |

3 | -123.921 | 52.345 | 1053 | 11 |

3 | -106.489 | 36.048 | 2859 | 31 |

3 | -120.583 | 50.574 | 1494 | 17 |

3 | -120.657 | 50.057 | 1168 | 47 |

3 | -121.007 | 49.657 | 1099 | 42 |

3 | -111.388 | 44.182 | 1876 | 30 |

3 | -110.935 | 40.374 | 2552 | 23 |

3 | -107.307 | 36.626 | 2148 | 72 |

3 | -117.236 | 49.298 | 1044 | 45 |

3 | -101.846 | 33.525 | 976 | 155 |

3 | -107.915 | 33.524 | 2238 | 81 |

3 | -103.212 | 37.477 | 1532 | 110 |

3 | -121.123 | 49.963 | 1134 | 45 |

3 | -113.359 | 42.306 | 1370 | 83 |

3 | -117.312 | 51.506 | 969 | 35 |

3 | -107.412 | 44.75 | 2551 | 1 |

3 | -125.512 | 52.8 | 1113 | 20 |

4 | -106.905 | 35.895 | 2257 | 67 |

4 | -112.755 | 37.289 | 1981 | 88 |

4 | -105.117 | 38.626 | 2652 | 32 |

4 | -105.43 | 32.746 | 2069 | 109 |

4 | -105.745 | 33.432 | 2544 | 71 |

4 | -109.35 | 39.315 | 1963 | 80 |

4 | -111.134 | 37.221 | 1846 | 109 |

4 | -104.476 | 35.923 | 1796 | 108 |

4 | -111.912 | 34.796 | 1164 | 159 |

4 | -107.238 | 37.131 | 2375 | 42 |

4 | -107.765 | 34.377 | 2219 | 85 |

4 | -109.458 | 38.139 | 1881 | 93 |

4 | -109.02 | 35.109 | 2049 | 94 |

4 | -105.366 | 34.295 | 1863 | 113 |

4 | -109.379 | 34.059 | 2558 | 65 |

4 | -112.017 | 34.765 | 1021 | 165 |

4 | -108.533 | 40.517 | 2173 | 49 |

4 | -109.07 | 35.371 | 1943 | 99 |

4 | -110.398 | 39.308 | 1457 | 100 |

4 | -110.184 | 39.183 | 1653 | 90 |

4 | -109.324 | 37.648 | 1788 | 102 |

4 | -105.152 | 37.679 | 2338 | 60 |

4 | -102.985 | 36.803 | 1425 | 121 |

4 | -109.523 | 38.675 | 1597 | 110 |

4 | -110.668 | 33.611 | 1331 | 149 |

4 | -108.061 | 33.121 | 2266 | 85 |

4 | -112.123 | 35.591 | 1848 | 101 |

4 | -110.346 | 33.94 | 1738 | 112 |

4 | -105.819 | 32.713 | 2160 | 106 |

4 | -110.218 | 39.958 | 2076 | 59 |

4 | -105.256 | 37.363 | 2953 | 22 |

4 | -109.068 | 38.551 | 2563 | 50 |

4 | -108.526 | 38.193 | 1817 | 92 |

4 | -106.17 | 34.573 | 1932 | 106 |

4 | -107.485 | 35.274 | 2609 | 62 |

4 | -109.432 | 40.467 | 1615 | 74 |

4 | -107.676 | 37.248 | 2276 | 63 |

4 | -109.506 | 35.455 | 1935 | 105 |

4 | -112.352 | 35.25 | 1855 | 104 |

4 | -109.815 | 33.342 | 1984 | 104 |

4 | -108.806 | 32.668 | 1205 | 154 |

4 | -110.036 | 36.294 | 2247 | 87 |

4 | -111.91 | 35.316 | 2267 | 70 |

4 | -108.405 | 39.23 | 1946 | 83 |

4 | -109.476 | 37.802 | 2897 | 39 |

4 | -109.82 | 39.671 | 2027 | 68 |

4 | -112.73 | 37.572 | 2851 | 27 |

4 | -106.108 | 36.075 | 1757 | 108 |

4 | -111.367 | 38.39 | 2254 | 61 |

4 | -109.97 | 40.453 | 1841 | 68 |

4 | -111.244 | 34.823 | 2112 | 88 |

4 | -105.742 | 33.371 | 2570 | 75 |

4 | -110.972 | 36.6 | 1935 | 106 |

4 | -108.828 | 39.056 | 1977 | 88 |

4 | -109.229 | 35.823 | 2417 | 71 |

4 | -109.593 | 34.298 | 2131 | 89 |

4 | -106.115 | 36.237 | 1963 | 95 |

4 | -112.755 | 35.509 | 1937 | 95 |

4 | -107.894 | 35.566 | 2216 | 83 |

4 | -111.76 | 34.884 | 1405 | 145 |

4 | -109.12 | 35.81 | 2271 | 79 |

4 | -110.382 | 34.331 | 2010 | 94 |

4 | -105.596 | 38.421 | 2006 | 83 |

4 | -112.054 | 39.329 | 1630 | 89 |

4 | -106.802 | 39.906 | 2150 | 51 |

4 | -108.227 | 34.301 | 2237 | 81 |

4 | -112.766 | 36.018 | 1782 | 108 |

4 | -110.698 | 34.725 | 1770 | 108 |

4 | -109.586 | 39.465 | 2003 | 68 |

4 | -109.507 | 33.814 | 2746 | 58 |

4 | -107.669 | 37.067 | 2000 | 80 |

4 | -104.229 | 36.987 | 2068 | 88 |

4 | -108.796 | 35.578 | 2029 | 93 |

4 | -105.403 | 33.171 | 1993 | 108 |

4 | -104.164 | 36.57 | 2315 | 72 |

4 | -104.798 | 36.464 | 1872 | 94 |

4 | -112.28 | 36.342 | 2447 | 61 |

4 | -107.453 | 35.548 | 2017 | 95 |

4 | -110.09 | 37.458 | 1692 | 117 |

4 | -109.269 | 40.525 | 1736 | 73 |

4 | -112.708 | 37.61 | 2850 | 28 |

4 | -109.295 | 35.61 | 2274 | 81 |

4 | -111.576 | 37.38 | 1640 | 116 |

4 | -109.518 | 38.198 | 1738 | 94 |

4 | -112.293 | 37.295 | 1926 | 88 |

4 | -106.802 | 36.62 | 2176 | 63 |

4 | -111.93 | 35.003 | 1998 | 95 |

4 | -111.354 | 37.973 | 2364 | 70 |

4 | -109.199 | 37.498 | 1564 | 115 |

4 | -108.878 | 33.677 | 1947 | 92 |

4 | -106.503 | 35.292 | 1687 | 122 |

4 | -107.948 | 37.136 | 2016 | 83 |

4 | -111.58 | 37.866 | 2075 | 83 |

4 | -108.507 | 32.772 | 1575 | 129 |

4 | -112.187 | 34.939 | 1388 | 145 |

4 | -104.724 | 37.595 | 1906 | 99 |

4 | -109.124 | 37.554 | 1786 | 99 |

4 | -107.77 | 33.419 | 2275 | 84 |

4 | -105.441 | 35.293 | 1968 | 92 |

4 | -111.64 | 37.139 | 1570 | 121 |

5 | -111.909 | 33.345 | 361 | 213 |

5 | -111.007 | 33.048 | 734 | 198 |

5 | -113.309 | 32.294 | 247 | 225 |

5 | -111.559 | 29.555 | 450 | 216 |

5 | -114.199 | 33.334 | 449 | 216 |

5 | -113.282 | 34.125 | 703 | 181 |

5 | -112.086 | 30.908 | 682 | 194 |

5 | -112.092 | 31.332 | 681 | 196 |

5 | -113.905 | 33.161 | 321 | 226 |

5 | -112.181 | 33.981 | 568 | 202 |

5 | -113.528 | 32.574 | 145 | 231 |

5 | -113.304 | 32.703 | 191 | 230 |

5 | -110.66 | 33.355 | 974 | 179 |

5 | -111.63 | 32.606 | 488 | 210 |

5 | -113.684 | 33.121 | 452 | 222 |

5 | -111.323 | 31.749 | 1023 | 178 |

5 | -113.155 | 32.938 | 221 | 228 |

5 | -110.514 | 33.331 | 895 | 180 |

5 | -113.355 | 32.226 | 259 | 223 |

5 | -111.658 | 30.843 | 592 | 205 |

5 | -111.266 | 30.085 | 750 | 197 |

5 | -112.256 | 32.662 | 642 | 204 |

5 | -110.939 | 32.312 | 792 | 202 |

5 | -110.935 | 30.193 | 777 | 199 |

5 | -111.716 | 33.167 | 772 | 203 |

5 | -110.845 | 28.938 | 247 | 241 |

5 | -111.951 | 32.819 | 409 | 211 |

5 | -113.33 | 33.35 | 449 | 212 |

5 | -113.738 | 32.001 | 189 | 219 |

5 | -112.112 | 32.971 | 394 | 210 |

5 | -113.629 | 34.672 | 760 | 176 |

5 | -112.173 | 33.503 | 344 | 214 |

5 | -112.129 | 31.624 | 769 | 192 |

5 | -110.587 | 28.957 | 417 | 233 |

5 | -111.196 | 29.084 | 154 | 239 |

5 | -112.39 | 29.918 | 484 | 200 |

5 | -112.073 | 33.058 | 350 | 210 |

5 | -112.587 | 33.876 | 660 | 191 |

5 | -114.009 | 34.471 | 657 | 192 |

5 | -110.72 | 32.795 | 934 | 187 |

5 | -112.478 | 31.845 | 557 | 206 |

5 | -112.173 | 30.769 | 334 | 207 |

5 | -112.233 | 30.894 | 558 | 199 |

5 | -112.035 | 29.095 | 144 | 226 |

5 | -111.027 | 32.358 | 738 | 202 |

5 | -111.586 | 33.295 | 438 | 211 |

5 | -111.297 | 31.725 | 1095 | 174 |

5 | -110.489 | 27.747 | 1 | 251 |

5 | -113.364 | 32.685 | 181 | 231 |

5 | -110.528 | 28.795 | 440 | 234 |

5 | -111.742 | 31.001 | 711 | 197 |

5 | -110.507 | 28.645 | 462 | 234 |

5 | -110.611 | 33.177 | 1042 | 177 |

5 | -111.832 | 33.085 | 388 | 210 |

5 | -111.147 | 28.432 | 142 | 240 |

5 | -110.527 | 29.705 | 601 | 217 |

5 | -110.51 | 28.379 | 181 | 244 |

5 | -111.843 | 33.003 | 497 | 206 |

5 | -113.56 | 33.284 | 354 | 221 |

5 | -112.688 | 31.76 | 470 | 208 |

5 | -110.719 | 33.461 | 1280 | 159 |

5 | -112.033 | 30.272 | 434 | 203 |

5 | -111.73 | 32.205 | 686 | 200 |

5 | -112.208 | 33.935 | 733 | 197 |

5 | -111.061 | 30.033 | 683 | 203 |

5 | -113.393 | 33.805 | 967 | 176 |

5 | -113.307 | 34.785 | 1305 | 143 |

5 | -111.021 | 30.785 | 1470 | 155 |

5 | -111.762 | 31.172 | 774 | 194 |

5 | -112.074 | 31.334 | 697 | 195 |

5 | -111.181 | 31.862 | 1414 | 158 |

5 | -111.704 | 29.946 | 872 | 189 |

5 | -112.231 | 32.785 | 580 | 206 |

5 | -112.864 | 30.738 | 53 | 214 |

5 | -113.142 | 33.521 | 363 | 211 |

5 | -113.919 | 32.43 | 290 | 222 |

5 | -110.772 | 29.393 | 375 | 227 |

5 | -111.532 | 32.402 | 856 | 194 |

5 | -111.685 | 30.032 | 879 | 189 |

5 | -111.271 | 32.394 | 605 | 206 |

5 | -111.801 | 30.135 | 714 | 194 |

5 | -111.626 | 33.539 | 422 | 209 |

5 | -112.394 | 30.23 | 491 | 199 |

5 | -114.078 | 33.532 | 512 | 210 |

5 | -111.195 | 28.185 | 89 | 243 |

5 | -111.649 | 31.229 | 852 | 188 |

5 | -110.15 | 28.658 | 544 | 236 |

5 | -114.131 | 33.201 | 447 | 218 |

5 | -113.968 | 32.585 | 197 | 228 |

5 | -110.519 | 28.831 | 543 | 232 |

5 | -111.255 | 32.921 | 643 | 205 |

5 | -112.899 | 32.396 | 513 | 221 |

5 | -113.291 | 32.442 | 260 | 227 |

5 | -110.666 | 28.163 | 76 | 245 |

5 | -110.626 | 32.217 | 1513 | 156 |

5 | -110.89 | 32.386 | 1702 | 144 |

5 | -111.049 | 32.518 | 1298 | 170 |

5 | -113.766 | 33.685 | 366 | 213 |

5 | -111.46 | 32.264 | 809 | 197 |

## Assignment #2: Regression Models

For this assignment you will need to download the trees.csv file. This file contains data on the elevational distribution of five ‘tree’ species. For your analysis you will be looking at variables that may influence the elevation at which the species is found. During this process, you will hopefully learn a bit about linear regression models and aspects of evaluating models.

The data for this analysis was created by randomly selecting points (n=100 for most species) using GIS maps of the distribution of the species. These were then intersected with digital elevation models and the mean annual temperature (Bio_1) layer from WorldClim ( __http://www.worldclim.org/__ ). We are looking at five species: PIPO (Ponderosa pine, *Pinus ponderosa*), ABLA (Subalpine fir, *Abies lasiocarpa*), JUSC (Rocky Mountain juniper, *Juniperus scopulorum*), PIED (Piñon pine, *Pinus edulis*), and CAGI (Saguaro, *Carnegiea gigantea*).

Types of Variables and Other Terminology

In regression, we consider two broad types of information that are used in the modeling. We are interested in what features influence something about another feature. The feature being influenced is a variable that we call the ‘response variable’. Other common terms for this are the ‘dependent variable’ as its value depends on the value of other variables. These other variables that we believe influence the response variable are called ‘explanatory variables’ because they explain the response variable. Other common terms for these variables are ‘independent variable’ or ‘covariate’.

In a simple example of a regression model we have the equation of a line: Y = a + bX (which you may have seen before as mX+b). We will make a simple change of notation to make this into standard regression ‘language’. The a will be called β0 and the b becomes β1 so our equation is now Y=β0+β1X. In this case, X represents a single explanatory variable, and Y represents the response variable. What do β0 and β1 represent? These are called ‘coefficients’. They are parameters we estimate during the regression modeling process. In this case, you probably already know that m is the slope and b is the y-intercept. In the following you will see references to the ‘intercept’ and the ‘slope coefficients’ which indicate we are dealing with linear models. In many linear models the equation is more complex and may not produce a true line, but these are really expansions of this basic equation. You may see the coefficients referred to as ‘betas’ at times as well, referring to the notation using the Greek letter β.

For this assignment, we are interested in what variables may explain the elevational distribution of these species, so elevation (in m) is our response variable. Our possible explanatory variables are latitude and longitude (in decimal degrees) and mean annual temperature (in 10ths of deg C). Because we may be asking about differences among the species, the species can also be considered an explanatory variable.

Now let’s open R and get to work. Remember to set your working directory following the procedure used in the Week 1 Assignment. Once you have done this, you can import the data in trees.csv into an R object called ‘trees’ and then we will perform some basic manipulations that will be necessary for our analysis. Remember that all items below that are in bold, italic are R commands.

Let’s import these data using the read.csv function, and then let R know that the Type column should be treated as a factor – or nominal (name) variable.

*trees<-read.csv(file.choose(),header=T)*

*trees$Type<-factor(trees$Type, labels=c(‘PIPO’,’ABLA’,’JUSC’,’PIED’,’CEGI’))*

Because the temperatures in these data are in tenths of a degree Celsius, we want to convert them to degrees Celsius by dividing them by 10 and placing that result back in the original column.

*trees$MeanTemp<-trees$MeanTemp/10*

Let’s summarize and visualize these data so you get a feel for it using boxplots to see the elevational distribution by species for these data. We use the summary() and boxplot() functions you learned last week to obtain summary values for each variable and produce potentially useful boxplots. The par() function is changing the graphics window so that all four boxplots are produced in the same window.

*summary(trees)*

*par(mfrow=c(2,2),mar=c(5,4,4,4))*

*boxplot(trees$Elev~trees$Type, col=c(2,3,5,6,7),main=’Elevational Distribution by Species’, ylab=’Elevation (in m)’, xlab=’Species’)*

*boxplot(trees$Long~trees$Type, col=c(2,3,5,6,7),main=’Longitudinal Distribution by Species’, ylab=’Longitude’, xlab=’Species’)*

*boxplot(trees$lat~trees$Type, col=c(2,3,5,6,7),main=’Latitudinal Distribution by Species’, ylab=’Latitude’, xlab=’Species’)*

*boxplot(trees$MeanTemp~trees$Type, col=c(2,3,5,6,7),main=’Mean Temperature by Species’, ylab=’Temperature (deg C)’, xlab=’Species’)*

We may also want to look at a scatterplot of these data to see how latitude, longitude, and species, our explanatory variables, are possibly related. We will essentially be creating a map of the distribution of these species. Keep in mind it will be somewhat distorted because degrees latitude and longitude will be treated as the same size when they really are not the same and the ‘length’ of a degree longitude shortens as you move away from the equator. We need to reset our graphic parameter to a single box, and then use the plot function to create an empty plot (type=’n’argument) specifying that longitude is on the x-axis and latitude on the y-axis. We then use the points() function to add in the locations of each species sample with a different color and marker, and add a legend with the legend() function.

*par(mfrow=c(1,1),mar=c(0,0,0,0))*

*plot(trees$Long, trees$lat, type=’n’, bty=’n’, main=’Geographic Distribution by Species’,ylab=’Latitude’, xlab=’Longitude’)*

*points(trees$Long[trees$Type==’PIPO’], trees$lat[trees$Type==’PIPO’],col=2,pch=2)*

*points(trees$Long[trees$Type==’ABLA’], trees$lat[trees$Type==’ABLA’],col=3,pch=3)*

*points(trees$Long[trees$Type==’JUSC’], trees$lat[trees$Type==’JUSC’],col=4,pch=4)*

*points(trees$Long[trees$Type==’PIED’], trees$lat[trees$Type==’PIED’],col=5,pch=5)*

*points(trees$Long[trees$Type==’CEGI’], trees$lat[trees$Type==’CEGI’],col=6,pch=6)*

*legend(‘bottomleft’,title=’Species’,c(‘Ponderosa’,’Subalpine Fir’,’Rocky Mtn Juniper’, ‘Pinon’, ‘Saguaro’),col=c(2,3,4,5,6),pch=c(2,3,4,5,6))*

Okay, now let’s build some regression models. In our first case we will be using simple linear regression so we are basically applying the Y=β0+β1X formula. You may have noticed in one of your boxplots that there is a lot of overlap among most of these species in their elevation. However, remember that boxplots are showing the variation in the sample, maybe we want to see if the mean elevations are different, which is often the question of interest. We can do that by finding the confidence intervals for each species, and we’ll use a linear model to find those intervals. In R there are multiple ways to fit regression models, the most basic uses the lm() function (which stands for ‘linear model’) although the glm() function (for ‘generalized linear model’) can fit a wider type of models. We will use the lm() function here. Note that in the parentheses there is a formula similar to that used in the boxplot() function – these is specifying our regression model to fit. The response variable goes on the left and the explanatory variable(s) goes on the right with a ~ representing the equal sign. For Y=β0+β1X we would write Y~X. Note that we do not specify the intercept term because it is fitted by default. The data argument just tells R that the data is in object ‘trees’ so we don’t have to be writing trees$Elev~trees$Type. The results of the model fit are being placed in the object mod.type.

*mod.type<-lm(Elev~Type, data=trees)*

We can know look at the model that was fitted by using the summary() function.

*summary(mod.type)*

Be sure to look at this output carefully and detect what features you recognize from previous statistics classes. Why do we have 5 coefficients (an intercept and one for each of 4 of the 5 tree species) reported? Shouldn’t there be just two? Remember that the explanatory variable is a nominal variable (a factor). It is not the typical X variable of the equation of a line. In reality, we just fitted the following model:

The ,,,, and are the coefficients reported in the summary of this model for the ABLA, JUSC, PIED, and CEGI types respectively. Remember that we were wanting the mean elevation for each of the tree species and we wanted to know if they were different from each other. How do we get that? In the equation above the variables for the tree types (ABLA, JUSC, etc) are really just 0’s or 1’s. For example, if we want the mean elevation for ABLA (subalpine fir) in our dataset, the equation becomes:

Because we’re multiplying 3 of those coefficients by zero they drop out so the equation really is:

The mean elevation of subalpine fir in our sample is 1368 meters. We can verify this using the mean() function

*mean(trees$Elev[trees$Type==’ABLA’]*

So why did we do all this if we could have just used the mean()? Hopefully this has helped you understand what regression models are doing – in this case finding the coefficients that best fit the data to produce an estimate of a response variable based on combinations of explanatory variables. Take some time to make sure you understand this procedure as this is the basis of all regression models, including the more complex forms of generalized linear regression such as logistic regression, Poisson regression, etc.

Before we move on, you may notice that the tree type ‘PIPO’ is not present in the output. Why? Ponderosa pine are the intercept value in this case, so the mean elevation of ponderosa pine is given by the intercept = 1429.18 m. The elevation of all other species is in relation to this value, so we know that the subalpine fir has a mean elevation 61.26 m lower than ponderosa pine – the slope coefficient gives the value higher or lower than the reference type of the intercept type. This allows us to get information we didn’t get using just the mean. If a slope coefficient isn’t different than zero, then that variable doesn’t add any explanatory value to the intercept. The coefficients reported above are the point estimates for the coefficient value, we really want to see what the 95% confidence interval estimates of these coefficients is. We do this using the confint() function.

*confint(mod.type)*

Note that the coefficient interval estimate for subalpine fir goes from -211 to 89 meters – it includes the value zero. Remember these are slope coefficients. What type of line has a slope of 0? A horizontal line. This means that we really cannot conclude that the mean elevation of subalpine fir is different than the mean elevation of ponderosa pine.

*Question note:* *Make sure you record the values for the point and interval estimates of all coefficients from this model for use in answering the questions.*

From your previous statistics classes you may have recognized that the above question could be asked using Analysis of Variance (ANOVA) because we have a continuous response variable and a categorical (factor) explanatory variable. We can show the ANOVA table using the anova() function specifying our model object in the parentheses.

*anova(mod.type)*

Compare the results of this table with that provided in the summary(mod.type) output. Note that you see a F value (93.066) and a p-value (2.2×10-16) for the test of the null hypothesis “Tree species do not differ in elevation” in both the ANOVA table and the summary output. This is a key point to recognize – ANOVA is based on linear regression, it is not a separate type of analysis. The difference is the information you can utilize from the analyses – note the different outputs – which ones produce more information?

The t-test you probably remember is just a simplified version as well, in the case where there are only two categories involved. If these data were in the right format (they weren’t collected to meet the needed assumptions) we would find that the t.test() function would provide an estimate of the difference of mean elevation of ponderosa and subalpine fir exactly the same as the coefficient for subalpine fir, and it would report the same t-statistic and p-value reported in the summary of the linear model for the subalpine fir coefficient (i.e, .t=-0.799, p=0.42455). We see that the t-test and ANOVA are just special cases of linear regression that emphasize significance testing whereas the regression approach allows us to work in both the significance testing and information-theoretic (discussed shortly) frameworks, and provides substantially more information about the relationship than the other two approaches.

What if we wanted confidence intervals on the mean elevation for each tree species, rather than on the difference in elevation of the four tree species from ponderosa pine? To obtain that we specify what tree type we want to be the intercept in our regression model using the relevel() function. Because ponderosa pine is the intercept now, we can get it’s 95% confidence interval directly using

*(pipo.cl<-confint(mod.type)[1,])*

The [1,] is telling R to extract the first listed confidence interval (row 1) from the output. We now use relevel() to set subalpine fir as the intercept, and then rerun the regression and extract the confidence interval on the intercept.

*trees$Type<-relevel(trees$Type,’ABLA’)*

*mod.type<-lm(Elev~Type, data=trees)*

*(abla.cl<-confint(mod.type)[1,])*

*Question note:* *You should now be able to find the 95% confidence intervals on mean elevation for the remaining 3 tree species (JUSC, PIED, CEGI). Keep these confidence intervals for all 5 species for use in answers.*

### Maximum Likelihood Estimation (MLE) and the Information-Theoretic Approach with AIC

Maximum likelihood estimation underlies much of modern statistics. The concept was first described by Sir R.A. Fisher in 1912 when he was an undergraduate at Cambridge. It works on a really basic premise – the best estimate for a given parameter (e.g., the mean of the population being sampled) is the one that makes the presumed distribution fit the data better than other such estimates. For example, the normal distribution has a probability density function (pdf) given by which produces the readily recognizable bell-shaped curve. For a mean of 50 and standard deviation of 15, it should be intuitive that the highest density value, 0.0266 in the figure below, should be associated with the true mean of the distribution, i.e., the normal pdf is maximized at the value of the mean.

*Figure 1. PDF of Normal Distribution w/mean=50 & sd=15*

Similarly, if we have some data and a hypothesized model to fit them, we should pick the parameters of that model (mean and standard deviation in the above case) that make the model’s density function fit the observed data the ‘best’. Note that this is basically a probability statement, but with a twist. If we go with the standard notation of probability, we can make a statement like ‘the probability of x given the model parameters equals’ as Pr{x | parameters}=. For the figure above, this would be Pr{50 |50,15}=0.0266, which happens to be the maximum that can be obtained. Likelihoods just turn the statement around to reflect what researchers actually do – we have data and we want to know the underlying parameter values – which means we refer to the ‘likelihood of model parameters given the data’ or *L*(parameters|data) – we want the value of the parameters that maximize the likelihood function built with the observed data, and we use those as our best estimates of the underlying population values we are trying to estimate.

Let’s illustrate this with a simple probability example, which is directly comparable to flipping a coin. Let’s assume we have 100 animals radiocollared and we follow them for some set period, say a year. During this period, 18 of the animals die. We want to know the best estimate of the yearly survival rate. Intuitively, we had 82 animals out of 100 survive so we’d think 82/100=0.82 is our best guess. Now let’s look at it from a MLE standpoint, what is the likelihood of 0.82 (=p) given N=100 trials and y=82 successes? This follows a classic binomial (or Bernoulli) distribution which has a likelihood function of: . We see in the figure below that, in fact, this function is maximized when p is set to 0.82, resulting in a likelihood value of 0.103.

*Figure 2. Binomial likelihood function w/N=100, y=82.*

So why don’t we just use the estimator p=y/N? Well, we do. This is the ‘closed’ form solution to finding the maximum of the above likelihood. For those of you with calculus backgrounds, you will remember that finding maxima (or minima) of functions is done by solving the first derivative (partial with respect to the parameter of interest) of the function when it is set equal to 0. The following figure shows the value of the first derivative of this function as p varies, and we see that it is 0 when y/N=0.82.

*Figure 3. First derivative of binomial likelihood with N=100, y=82.*

y/N is the solution when the first derivative is set equal to 0 and is known as the maximum likelihood estimate for a Bernoulli trial situation. Many of our common estimators are MLE’s for the same reason – they are the closed form solutions to the first derivative of the likelihood when it is set to zero. However, for many of our applications, there is no closed form estimator available, so we must use numerical optimization routines to develop our MLE of the parameter of interest.

For several reasons we often use log-likelihoods instead of likelihoods. If you notice in Fig 2 above, the value of the likelihood is extremely small (essentially 0) for much of the range of p, which can create issues due to rounding to 0, especially in a numerical optimization. In addition, logarithms often simplify calculation by making multiplicative functions additive which can also help in numerical optimization, e.g., becomes . This results in the following likelihood shape (compare to Fig 2).

*Figure 4. Log-likelihood function of binomial w/N=100, y=82.*

#### Why MLE’s?

Okay, so why do we care about using Maximum Likelihood Estimators (as opposed to other forms of estimators that aren’t MLE’s)? Well, for several reasons, all of which imply that there are no better estimators available given a large sample size. The likelihood principle states that the likelihood function contains all relevant information from a sample. Some reasons for using MLE’s are:

· They are asymptotically (i.e., at large sample sizes) normally distributed

· They have minimum variance (therefore provide more precise estimates)

· They are asymptotically unbiased.

· They are efficient (i.e., extract information most effectively, hence the minimum variance)

· They relate to Fisher information, which enables use in model selection, among other things.

#### Comparison of likelihoods and least squares

Most people are introduced to regression (and ANOVA) through the method of least squares, you have probably heard of ‘Sum of Squares’ and seen it calculated as where x is an individual data point. This is the sum of the squared residual values. For data with normally-distributed errors, it happens that the MLE of the regression is the value that minimizes the sum of squares, which is why it is called ‘least squares’. In simple linear regression, these can be solved with closed-form equations, which are the series of least squares equations you may have had to calculate at some point in previous statistics classes (SST, SSE, MSE). In log-likelihoods involving normally-distributed error, the deviance is equivalent to sum of squares term in least squares.

#### Profile likelihood confidence intervals

Remembering that deviance is a general form of sum of squares – it gets at the amount of residual variation that is unexplained by the model. It also is approximately chi-square distributed with 1 degree of freedom. This leads to the ability to generate confidence intervals based on the likelihood function. The χ2 value with 1 df for 95% confidence= 1.92. If we subtract 1.92 from the maximum value of the log-likelihood, and find the parameter values that produce these values in the likelihood we get the 95% confidence limits for our parameter estimates. In the example we’ve been using, we have a point estimate of 0.82 which was produced when the log-likelihood was maximized at -2.269711. Subtracting 1.92 from this gives us -4.189711. We then find that the log-likelihood equals -4.189711 where p=0.737 and 0.887. Therefore our 95% profile likelihood confidence interval is [0.737, 0.887]. We can see this in a zoomed in version of figure 3:

*Figure 5. Profile likelihood confidence intervals.*

You may notice that the confidence interval is not symmetrical about the point estimate (0.82), extending further on the lower end than on the upper end. If you look at figure 3, you will notice that the log-likelihood function is not symmetrical, it is steeper on the right side than on the left side. It should not surprise us that we then that the confidence interval is asymmetric, and in fact we should not expect them to be so unless we assume error is normally distributed. You should note that when you receive confidence interval estimates on coefficients from your linear models based on lm() and glm() you are getting profile likelihood intervals.

#### Information Theory and Akaike’s Information Criterion (AIC)

AIC stands for ‘An information criterion’ but is more commonly known as “Akaike’s Information Criterion” because it was developed by Hirotugu Akaike. AIC is based on the Fisher Information from the log-likelihood (the negative second derivative). Recall that this is related to the deviance. Specifically, AIC=-2log*L*+ 2K where K is the number of parameters in the model and log*L *is the value of the log-likelihood function at its maximum. In our example above, if you remove the constant involving the factorials, the value of the maximum at its maximum is -47.13935. There is only one parameter, p, to be estimated in the model, therefore the AIC=-2(-47.13935)+2(1)= 96.2787. This is the same AIC that R would report if you ran a GLM on a factored vector, success, consisting of 82 1’s and 18 0’s. Run the following code:

*success<-factor(c(rep(1,82),rep(0,18)))*

*(glm(success~1,family=binomial(link=’logit’)))*

We have used the glm() function to build our model, which presents a somewhat different output from the lm() function. Note the AIC is reported at the end, and that this matches the value shown above. Also note that our formula was success~1. We have not specified any explanatory variables. The 1 indicates we want to fit an intercept-only model to these data.

If models are based on the same underlying data, then they can be compared using AIC. Models with lower AIC values fit the data better than those with higher AIC values. Note that there are two reasons for this:

1. they have higher maximum values for their log-likelihoods (as log-likelihoods are generally less than 0 their negatives will be lower), and

2. more complex models will have a higher ‘parameter penalty’ (the 2K part). AIC is trying to combine fit with model simplicity, with the goal of trying to find the simplest model that fits the data well – this follows the ‘Principle of Parsimony’ or ‘Occam’s Razor’.

We usually compare models using deltaAIC (ΔAIC) which is the difference =AICbestmodel-AICcurrentmodel. Note that there isn’t a clearcut decision as when a model is not competitive, however, a common recommendation (Burnham and Anderson 2002) is that if ΔAIC<2 than the model is competitive, and support for the model drops off quickly as ΔAIC gets larger, with ΔAIC>7 indicating highly improbable models. Another common way of looking at models is based on Akaike weights, which can be used to look at the weight of evidence in support of the given model. Akaike weights are given by where the denominator is summed over all models in your model set. We can then compare two models, 1 and 2, with weights w1 and w2, using the evidence ratio=w1/w2. For example, let’s look at the following 5 models with ΔAIC’s of 0, 1.2, 2, 3.2, and 7. Based on these values we get the following where the evidence ratio is best model compared with the model listed (e.g., model 1 is w1):

Model | ΔAIC | Wi | Evidence Ratio |

1 | 0 | 0.465 | 1.00 |

2 | 1.2 | 0.255 | 1.82 |

3 | 2 | 0.171 | 2.72 |

4 | 3.2 | 0.094 | 4.95 |

5 | 7 | 0.014 | 33.1 |

We see that model 1 has 46.5% of the weight of evidence, but model 2 still has 25.5% of the weight. The odds of model 1 being the best model over model 4 are nearly 5 to 1 (explicitly, it is 4.95 times more likely than model 4). The nice thing about these approaches is it allows us to quantify the uncertainty involved in our model selection process, which enables us to incorporate it – which is important in that it allows for model averaging in which we don’t have to select a single ‘best model’.

One last thing concerning AIC. It is recommended that we use the small sample size correction form of AIC, AICc, which slightly increases the weight of the ‘parameter penalty’. Specifically this is given by: where n is the sample size.

### Model Selection

Now let’s return to our tree dataset to compare several models to see which explanatory variables produce the model that best fits these data. We are going to use a generalized linear model with a normally-distributed error and the ‘identity’ link function. We will have three different models, we have already run the model above (mod.type) that has tree species as the only explanatory model. Now we’ll use both tree species and latitude as explanatory variables in an additive model. First let’s rerun our first model using glm() and place the results in object ‘gmod.type’ and then see what the results look like compared to the previous output.

*gmod.type<-glm(Elev~Type, data=trees)*

*mod.type*

*gmod.type*

Now let’s run a multiple linear regression with tree type and latitude as the explanatory variables.

*gmod.typelat<-glm(Elev~Type+lat, data=trees)*

*summary(gmod.typelat)*

We’ll also show the 95% confidence intervals on the coefficients. Note that there is a line at the top printed while the function was running that states “Waiting for profiling to be done …”. R is calculating the intervals using the profile likelihood approach as discussed above.

*confint(gmod.typelat)*

Then we’ll use only latitude as an explanatory variable. We’ll log transform elevation in this case because the latitude variable is somewhat skewed. By taking the natural logarithm of the latitude these data become more normally distributed. That does mean we have to remember the values reported in the output are the logarithms of the latitude, so if we want to report the real latitude values we need to back transform the values with evalue.

*gmod3.lat<-glm(Elev~lat, data=trees)*

*summary(gmod3.lat)*

*confint(gmod3.lat)*

So now we have three linear models, two with a single explanatory variable each, and one with these two variables both included in an additive model. Which one of these models best describes (or ‘fits’) these data? This is where AIC is useful. Remember that as AIC gets smaller the model appears to fit the data better. In addition, adhering to the ‘principle of parsimony’, large complex models with many terms (so they have many parameters) are penalized over simpler models. AIC then provides a means of ranking models with a preference toward finding the most simple model that fits the data well. This is the basis of the information-theoretic approach to statistical inference that predominates ecological statistics today (see Burnham and Anderson 2002). Anderson et al (2000) provides an additional short accessible overview of the information-theoretic approach.

So let’s look at the AIC’s for our models, which are extracted using the AIC() function:

*AIC(mod.type)*

*AIC(gmod2.typelat)*

*AIC(gmod3.lat)*

We can clearly see that the addition of latitude as an explanatory variable made this model fit the data much better. In practice, we use delta AIC (ΔAIC) to compare all models with the model with the model that has the lowest AIC. There is no hard and fast ‘rule’ but models with ΔAIC’s > 2 are generally considered not particularly competitive. However, there is some inferential uncertainty here and we can capture that with ‘model averaging’, but that is beyond our scope today.

*Question note:* *You should now be able to run additional models. Run at least two additional models, one with a single explanatory variable, and one with two explanatory variables. Record the output for all 5 GLM models, including confidence intervals on the coefficients. In addition, note the AIC for all 5 models you have run. You will use this information to answer questions.*

Let’s conclude the assignment by looking at the confidence intervals and prediction intervals of our current best model (gmod.typelat). Remember that this is an additive model with the explanatory variables of latitude and tree species was the best. We will focus on how well this model demonstrates the elevational distribution of ponderosa pine.

First, we need to create an object that contains latitude values representing the range observed in our dataset for ponderosa pine. The following code does this by creating an object ‘lat’. It then adds a column for type that only has PIPO in it. We need this two column object, newpred, to have both of the explanatory variables in it. R will apply the coefficients from the model to the data in this prediction object to create new objects representing the confidence and prediction intervals.

*lat<-seq(min(trees$lat[trees$Type==’PIPO’]),max(trees$lat[trees$Type==’PIPO’]),.1)*

*Type<-rep(‘PIPO’,length(lat))*

*newpred<-data.frame(lat,Type)*

Now we need to create objects containing the upper and lower confidence and prediction limits based on our best model using the predict() function. The predict() function specifically works with objects created by lm() so we need to create the best model in that form using

*mod.typelat<-lm(Elev~Type+lat, data=trees)*

Which we now can use to create the 95% limits using

*pipo.cl<-predict(gmod.typelat,newpred,interval=c(‘confidence’))*

*pipo.pl<-predict(gmod.typelat,newpred,interval=c(‘prediction’))*

We will create a graph showing the data for ponderosa pine with latitude on the x-axis and elevation on the y-axis.

*plot(trees$lat[trees$Type==’PIPO’],trees$Elev[trees$Type==’PIPO’],type=’p’,pch=20,col=2,main=’Relationship of Latitude and Elevation for Ponderosa’,xlab=’Latitude’,ylab=’Elevation’)*

We then add lines showing the point estimate and 95% confidence limits for elevation at each latitude.

*lines(newpred[,1],pipo.cl[,1],lwd=2,col=4)*

*lines(newpred[,1],pipo.cl[,2],lty=2,col=4)*

*lines(newpred[,1],pipo.cl[,3],lty=2,col=4)*

And similarly we add the 95% prediction limits for elevation of ponderosa pine at each latitude. We will also add a legend to the graph.

*lines(newpred[,1],pipo.pl[,2],lty=4,col=6)*

*lines(newpred[,1],pipo.pl[,3],lty=4,col=6)*

*legend(‘bottomleft’,c(‘Predicted Value’,’95% Confidence Limits’,’95% Prediction Limits’),col=c(4,4,6),lty=c(1,2,4),lwd=c(2,1,1))*

*Question note:* *Save an image of this graph for the questions.*

Note that we are using this model to explore the explanatory potential of variables (confidence limits), and in predicting particular values (prediction limits). Observe the graph and see how the confidence interval and prediction intervals differ. For example, assume we are latitude 33 deg N and want to know what the mean elevation that ponderosa pine might be found at this elevation. We can find the point estimate manually by using the equation Elev = intercept + -48.57*latitude + 1278.44*PIPO or Elev= 2130.09+-48.57(33)+1278.44(1)= 1806 m.

The following R code extracts each coefficient from the model output and then runs this equation. The [[1]] indicates we are extracting a coefficient from this output, the number in single brackets following indicates which coefficient. This follows the listing shown on the object display so the intercept is [1], the PIPO coefficient is [5], and the latitude coefficient is last at [6] (there are 6 coefficients total). Note that we have a PIPO coefficient because we have not releveled back to PIPO as the intercept.

*(int<-mod.typelat[[1]][1])*

*(lat.coef<-mod.typelat[[1]][6])*

*(pipo.coef<-mod.typelat[[1]][5]*

*int+lat.coef*33+pipo.coef*

*Question note:* *Make sure you have the coefficients for the mod.typelat model recorded. You will be asked to calculate the predicted elevation for a different tree species and different latitude as a question.*

Note that this result is the predicted mean value on the graph for an x-axis value of 33 degrees latitude. We can see the values for the confidence and prediction limits by displaying these objects.

*pipo.cl*

*pipo.pl*

Our example was very close to the latitude of the 99th object in this list, so we can show them with

*pipo.cl[99,]*

*pipo.pl[99,]*

We believe the true mean elevation of ponderosa pine at 33 deg N latitude is between 1692 and 1919 meters. However, if someone asked us to guess the elevation of a single ponderosa pine that they found at 33 deg N latitude, we would say that it is probably between 854 and 2756 meters.

*Question note:* *You will be asked to provide the 95% confidence and prediction limits for ponderosa pine at a different latitude based on the pipo.cl and pipo.pl objects. Know how to access these objects to find those values.*

### Literature Cited

Anderson, D. R., K. P. Burnham, and W. L. Thompson. 2000. Null hypothesis testing: problems, prevalence, and an alternative. Journal of Wildlife Management 64(4):912-923.

Burnham, K. P.; and D. R. Anderson. 2002. Model selection and multimodel inference: a practical information-theoretic approach, 2nd edition. Springer-Verlag, New York, NY.

Questions: Based on the analysis you ran, answer the following:

1. What are the point estimate and 95% confidence intervals for the coefficients from the lm() regression of tree type explaining elevation?

2. What are the 95% confidence intervals on the mean elevation for the 5 tree species?

3. Based on your answers in #2, which species differ from subalpine fir in mean elevation? From piñon?

4. Of the 5 glm() models you ran, which appears to be the best model. Support your answer by providing the relevant information from your R output. You should also provide ΔAIC values for all 5 models in your answer.

5. Of your 5 models, what was the model weight (Akaike weight) of the second best model? Show your calculation of this value.

6. Provide the image of the graph showing the confidence and prediction limits for the role of latitude in explaining elevation of ponderosa pine.

7. What is the predicted elevation, in meters, for juniper (JUSC) at 38.5 deg N latitude?

8. Provide the 95% confidence and prediction limits, as well as the predicted point value of elevation for ponderosa pine at 39.006 degrees N latitude?

9. What is the difference between confidence and prediction intervals? Provide an example of when you would use each.