df = read.csv("/Users/mathew.katz/Desktop/CUNYSPS/who.csv")
df
##                                       Country LifeExp InfantSurvival
## 1                                 Afghanistan      42          0.835
## 2                                     Albania      71          0.985
## 3                                     Algeria      71          0.967
## 4                                     Andorra      82          0.997
## 5                                      Angola      41          0.846
## 6                         Antigua and Barbuda      73          0.990
## 7                                   Argentina      75          0.986
## 8                                     Armenia      69          0.979
## 9                                   Australia      82          0.995
## 10                                    Austria      80          0.996
## 11                                 Azerbaijan      64          0.927
## 12                                    Bahamas      74          0.987
## 13                                    Bahrain      75          0.991
## 14                                 Bangladesh      63          0.948
## 15                                   Barbados      75          0.989
## 16                                    Belarus      69          0.994
## 17                                    Belgium      79          0.996
## 18                                     Belize      69          0.986
## 19                                      Benin      55          0.912
## 20                                     Bhutan      64          0.937
## 21                                    Bolivia      66          0.950
## 22                     Bosnia and Herzegovina      75          0.987
## 23                                   Botswana      52          0.910
## 24                                     Brazil      72          0.981
## 25                          Brunei Darussalam      77          0.992
## 26                                   Bulgaria      73          0.990
## 27                               Burkina Faso      47          0.878
## 28                                    Burundi      49          0.891
## 29                                   Cambodia      62          0.935
## 30                                   Cameroon      51          0.913
## 31                                     Canada      81          0.995
## 32                                 Cape Verde      70          0.975
## 33                   Central African Republic      48          0.886
## 34                                       Chad      46          0.876
## 35                                      Chile      78          0.992
## 36                                      China      73          0.980
## 37                                   Colombia      74          0.983
## 38                                    Comoros      65          0.949
## 39                                      Congo      54          0.921
## 40                               Cook Islands      73          0.984
## 41                                 Costa Rica      78          0.989
## 42                           C\xf4te d'Ivoire      53          0.910
## 43                                    Croatia      76          0.995
## 44                                       Cuba      78          0.995
## 45                                     Cyprus      80          0.997
## 46                             Czech Republic      77          0.997
## 47           Democratic Republic of the Congo      47          0.871
## 48                                    Denmark      79          0.997
## 49                                   Djibouti      56          0.914
## 50                                   Dominica      74          0.987
## 51                         Dominican Republic      70          0.975
## 52                                    Ecuador      73          0.979
## 53                                      Egypt      68          0.971
## 54                                El Salvador      71          0.978
## 55                          Equatorial Guinea      46          0.876
## 56                                    Eritrea      63          0.952
## 57                                    Estonia      73          0.995
## 58                                   Ethiopia      56          0.923
## 59                                       Fiji      69          0.984
## 60                                    Finland      79          0.997
## 61                                     France      81          0.996
## 62                                      Gabon      58          0.940
## 63                                     Gambia      59          0.916
## 64                                    Georgia      70          0.972
## 65                                    Germany      80          0.996
## 66                                      Ghana      57          0.924
## 67                                     Greece      80          0.996
## 68                                    Grenada      68          0.983
## 69                                  Guatemala      68          0.969
## 70                                     Guinea      53          0.902
## 71                              Guinea-Bissau      48          0.881
## 72                                     Guyana      64          0.954
## 73                                      Haiti      61          0.940
## 74                                   Honduras      70          0.977
## 75                                    Hungary      73          0.994
## 76                                    Iceland      81          0.998
## 77                                      India      63          0.943
## 78                                  Indonesia      68          0.974
## 79                 Iran (Islamic Republic of)      71          0.970
## 80                                       Iraq      56          0.963
## 81                                    Ireland      80          0.996
## 82                                     Israel      81          0.996
## 83                                      Italy      81          0.997
## 84                                    Jamaica      72          0.974
## 85                                      Japan      83          0.997
## 86                                     Jordan      71          0.979
## 87                                 Kazakhstan      64          0.974
## 88                                      Kenya      53          0.921
## 89                                   Kiribati      65          0.953
## 90                                     Kuwait      78          0.991
## 91                                 Kyrgyzstan      66          0.964
## 92           Lao People's Democratic Republic      60          0.941
## 93                                     Latvia      71          0.992
## 94                                    Lebanon      70          0.973
## 95                                    Lesotho      42          0.898
## 96                                    Liberia      44          0.843
## 97                     Libyan Arab Jamahiriya      72          0.983
## 98                                  Lithuania      71          0.993
## 99                                 Luxembourg      80          0.997
## 100                                Madagascar      59          0.928
## 101                                    Malawi      50          0.924
## 102                                  Malaysia      72          0.990
## 103                                  Maldives      72          0.974
## 104                                      Mali      46          0.881
## 105                                     Malta      79          0.995
## 106                          Marshall Islands      63          0.950
## 107                                Mauritania      58          0.922
## 108                                 Mauritius      73          0.988
## 109                                    Mexico      74          0.971
## 110          Micronesia (Federated States of)      69          0.967
## 111                                    Monaco      82          0.997
## 112                                  Mongolia      66          0.965
## 113                                Montenegro      74          0.991
## 114                                   Morocco      72          0.966
## 115                                Mozambique      50          0.904
## 116                                   Namibia      61          0.955
## 117                                     Nauru      61          0.975
## 118                                     Nepal      62          0.954
## 119                               Netherlands      80          0.996
## 120                               New Zealand      80          0.995
## 121                                 Nicaragua      71          0.971
## 122                                     Niger      42          0.852
## 123                                   Nigeria      48          0.901
## 124                                      Niue      70          0.966
## 125                                    Norway      80          0.997
## 126                                      Oman      74          0.990
## 127                                  Pakistan      63          0.922
## 128                                     Palau      69          0.990
## 129                                    Panama      76          0.982
## 130                          Papua New Guinea      62          0.946
## 131                                  Paraguay      75          0.981
## 132                                      Peru      73          0.979
## 133                               Philippines      68          0.976
## 134                                    Poland      75          0.994
## 135                                  Portugal      79          0.997
## 136                                     Qatar      77          0.991
## 137                         Republic of Korea      79          0.995
## 138                       Republic of Moldova      68          0.984
## 139                                   Romania      73          0.986
## 140                        Russian Federation      66          0.990
## 141                                    Rwanda      52          0.903
## 142                     Saint Kitts and Nevis      71          0.983
## 143                               Saint Lucia      75          0.988
## 144          Saint Vincent and the Grenadines      70          0.983
## 145                                     Samoa      68          0.977
## 146                                San Marino      82          0.997
## 147                     Sao Tome and Principe      61          0.937
## 148                              Saudi Arabia      70          0.979
## 149                                   Senegal      59          0.940
## 150                                    Serbia      73          0.993
## 151                                Seychelles      72          0.988
## 152                              Sierra Leone      40          0.841
## 153                                 Singapore      80          0.997
## 154                                  Slovakia      74          0.993
## 155                                  Slovenia      78          0.997
## 156                           Solomon Islands      67          0.945
## 157                              South Africa      51          0.944
## 158                                     Spain      81          0.996
## 159                                 Sri Lanka      72          0.989
## 160                                     Sudan      60          0.938
## 161                                  Suriname      68          0.971
## 162                                 Swaziland      42          0.888
## 163                                    Sweden      81          0.997
## 164                               Switzerland      82          0.996
## 165                      Syrian Arab Republic      72          0.988
## 166                                Tajikistan      64          0.944
## 167                                  Thailand      72          0.993
## 168 The former Yugoslav Republic of Macedonia      73          0.985
## 169                               Timor-Leste      66          0.953
## 170                                      Togo      57          0.931
## 171                                     Tonga      71          0.980
## 172                       Trinidad and Tobago      69          0.967
## 173                                   Tunisia      72          0.981
## 174                                    Turkey      73          0.976
## 175                              Turkmenistan      63          0.955
## 176                                    Tuvalu      65          0.969
## 177                                    Uganda      50          0.922
## 178                                   Ukraine      67          0.980
## 179                      United Arab Emirates      78          0.992
## 180                            United Kingdom      79          0.995
## 181               United Republic of Tanzania      50          0.926
## 182                  United States of America      78          0.993
## 183                                   Uruguay      75          0.987
## 184                                Uzbekistan      68          0.962
## 185                                   Vanuatu      69          0.970
## 186        Venezuela (Bolivarian Republic of)      74          0.982
## 187                                  Viet Nam      72          0.985
## 188                                     Yemen      61          0.925
## 189                                    Zambia      43          0.898
## 190                                  Zimbabwe      43          0.945
##     Under5Survival  TBFree      PropMD      PropRN PersExp GovtExp TotExp
## 1            0.743 0.99769 0.000228841 0.000572294      20      92    112
## 2            0.983 0.99974 0.001143127 0.004614439     169    3128   3297
## 3            0.962 0.99944 0.001060478 0.002091362     108    5184   5292
## 4            0.996 0.99983 0.003297297 0.003500000    2589  169725 172314
## 5            0.740 0.99656 0.000070400 0.001146162      36    1620   1656
## 6            0.989 0.99991 0.000142857 0.002773810     503   12543  13046
## 7            0.983 0.99952 0.002780191 0.000741044     484   19170  19654
## 8            0.976 0.99920 0.003698671 0.004918937      88    1856   1944
## 9            0.994 0.99993 0.002331953 0.009149391    3181  187616 190797
## 10           0.996 0.99990 0.003610904 0.006458749    3788  189354 193142
## 11           0.911 0.99913 0.003660005 0.008477873      62     780    842
## 12           0.986 0.99960 0.000954128 0.004045872    1224   55783  57007
## 13           0.990 0.99955 0.002679296 0.005967524     710   45784  46494
## 14           0.931 0.99609 0.000274894 0.000253034      12      75     87
## 15           0.988 0.99989 0.001098976 0.003372014     725   24433  25158
## 16           0.992 0.99929 0.004758674 0.012457093     204   11315  11519
## 17           0.995 0.99989 0.004230489 0.014079195    3451  239105 242556
## 18           0.984 0.99944 0.000890071 0.001074468     198    5376   5574
## 19           0.852 0.99865 0.000035500 0.000660845      28     600    628
## 20           0.930 0.99904 0.000080100 0.001124807      52     407    459
## 21           0.939 0.99734 0.001104233 0.001934039      71    2860   2931
## 22           0.985 0.99943 0.001411105 0.004669384     243    6578   6821
## 23           0.876 0.99546 0.000384822 0.002558127     431   19604  20035
## 24           0.980 0.99945 0.001046640 0.003481410     371   13940  14311
## 25           0.991 0.99901 0.001047120 0.005549738     519   30562  31081
## 26           0.988 0.99959 0.000253477 0.004553230     272   11550  11822
## 27           0.796 0.99524 0.000049300 0.000456647      27     304    331
## 28           0.819 0.99286 0.000024500 0.000164933       3      10     13
## 29           0.918 0.99335 0.000144185 0.000783616      29     140    169
## 30           0.851 0.99763 0.000171884 0.001432847      49     784    833
## 31           0.994 0.99996 0.001912607 0.010044633    3430  192800 196230
## 32           0.966 0.99676 0.000445087 0.000789981     114    5394   5508
## 33           0.826 0.99472 0.000077600 0.000378195      13     190    203
## 34           0.791 0.99430 0.000033000 0.000238728      22     234    256
## 35           0.991 0.99984 0.001047677 0.000607349     397   17952  18349
## 36           0.976 0.99799 0.001402082 0.000979500      81    1302   1383
## 37           0.979 0.99941 0.001289806 0.000525484     201   12410  12611
## 38           0.932 0.99914 0.000140587 0.000718826      14     304    318
## 39           0.874 0.99434 0.000204934 0.000995392      31     915    946
## 40           0.981 0.99976 0.001428571 0.005714286     466   27264  27730
## 41           0.988 0.99983 0.001182996 0.000830416     327   15376  15703
## 42           0.873 0.99253 0.000110024 0.000538226      34     315    349
## 43           0.994 0.99936 0.002469271 0.005459175     651   30210  30861
## 44           0.993 0.99990 0.005908139 0.007444750     310   21075  21385
## 45           0.996 0.99994 0.033228132 0.003972813    1350   39399  40749
## 46           0.996 0.99990 0.003591618 0.008942978     868   56137  57005
## 47           0.795 0.99355 0.000096100 0.000474721       5      66     71
## 48           0.996 0.99993 0.003551934 0.009958195    4350  314588 318938
## 49           0.870 0.98700 0.000170940 0.000361416      61    4002   4063
## 50           0.985 0.99984 0.000558824 0.004661765     288   13206  13494
## 51           0.971 0.99882 0.001629745 0.001596672     197    4148   4345
## 52           0.976 0.99805 0.001388805 0.001559309     147    3717   3864
## 53           0.965 0.99969 0.002425640 0.003367945      78    1290   1368
## 54           0.975 0.99936 0.001173913 0.000754658     177    5700   5877
## 55           0.794 0.99596 0.000308468 0.000546371     211    6474   6685
## 56           0.926 0.99782 0.000045800 0.000533887       8      80     88
## 57           0.994 0.99960 0.003294030 0.006900746     516   27393  27909
## 58           0.877 0.99359 0.000023900 0.000191851       6      64     70
## 59           0.982 0.99970 0.000456182 0.001992797     148    5355   5503
## 60           0.997 0.99996 0.003299183 0.008920357    2824  133956 136780
## 61           0.995 0.99989 0.003379700 0.007924442    3819  234850 238669
## 62           0.909 0.99572 0.000301297 0.005170099     276   17220  17496
## 63           0.886 0.99577 0.000093800 0.001131088      15     550    565
## 64           0.968 0.99916 0.004646289 0.004031356     123    1248   1371
## 65           0.995 0.99995 0.003441718 0.008010552    3628  209250 212878
## 66           0.880 0.99621 0.000140821 0.000856528      30     490    520
## 67           0.996 0.99984 0.004994696 0.003596152    2580   65195  67775
## 68           0.980 0.99992 0.000754717 0.003075472     342    6944   7286
## 69           0.959 0.99897 0.000764832 0.003452759     132    2400   2532
## 70           0.839 0.99534 0.000107505 0.000480122      21      66     87
## 71           0.800 0.99687 0.000114216 0.000651276      10      90    100
## 72           0.938 0.99785 0.000495264 0.002351827      60    1400   1460
## 73           0.920 0.99598 0.000206331 0.000088300      28     546    574
## 74           0.973 0.99905 0.000527479 0.001223705      91    2162   2253
## 75           0.993 0.99979 0.003039869 0.009163949     855   40602  41457
## 76           0.997 0.99997 0.003758389 0.009932886    5154  395622 400776
## 77           0.924 0.99701 0.000560733 0.001191281      36     203    239
## 78           0.966 0.99747 0.000128893 0.000786314      26     588    614
## 79           0.965 0.99972 0.000880461 0.001581144     212    7973   8185
## 80           0.953 0.99922 0.000666877 0.001333088      59    2948   3007
## 81           0.996 0.99989 0.002936271 0.019403222    3993  193553 197546
## 82           0.995 0.99994 0.003691336 0.006256828    1533   93748  95281
## 83           0.996 0.99994 0.003657769 0.007137294    2692  140148 142840
## 84           0.968 0.99992 0.000834754 0.001620600     170    4399   4569
## 85           0.996 0.99971 0.002113049 0.009461544    2936  159192 162128
## 86           0.975 0.99994 0.002349450 0.003218537     241    9047   9288
## 87           0.971 0.99858 0.003755648 0.007385268     148    5510   5658
## 88           0.879 0.99666 0.000123273 0.001015320      24     231    255
## 89           0.936 0.99598 0.000212766 0.002765957     118    4578   4696
## 90           0.989 0.99975 0.001741634 0.003576826     687   51940  52627
## 91           0.959 0.99863 0.002416809 0.005861190      28     396    424
## 92           0.925 0.99708 0.000347283 0.000972391      18      84    102
## 93           0.991 0.99940 0.003145478 0.005609436     443   18224  18667
## 94           0.969 0.99988 0.002081381 0.001163995     460   17400  17860
## 95           0.868 0.99487 0.000044600 0.000562907      41     437    478
## 96           0.765 0.99422 0.000028800 0.000289187      10     413    423
## 97           0.982 0.99982 0.001170724 0.004497433     223   13175  13398
## 98           0.991 0.99939 0.003964202 0.007670188     448   19932  20380
## 99           0.996 0.99990 0.002722343 0.009583514    6330  476420 482750
## 100          0.885 0.99585 0.000271465 0.000295475       9     162    171
## 101          0.880 0.99678 0.000019600 0.000535259      19     252    271
## 102          0.988 0.99875 0.000651758 0.001661178     222    6732   6954
## 103          0.970 0.99946 0.001006667 0.002953333     316    8100   8416
## 104          0.783 0.99422 0.000088000 0.000696691      28     434    462
## 105          0.994 0.99995 0.003861728 0.005953086    1235   91776  93011
## 106          0.944 0.99759 0.000413793 0.002620690     294   18876  19170
## 107          0.875 0.99394 0.000102825 0.000621879      17     451    468
## 108          0.985 0.99960 0.001040735 0.003677316     218    4704   4922
## 109          0.965 0.99975 0.001859629 0.000841810     474   16340  16814
## 110          0.959 0.99891 0.000540541 0.002252252     290    5830   6120
## 111          0.996 0.99998 0.005636364 0.014060606    6128  458700 464828
## 112          0.958 0.99809 0.002584261 0.003388100      35    1539   1574
## 113          0.990 0.99951 0.002051581 0.005717138     299   13725  14024
## 114          0.963 0.99921 0.000518296 0.000788513      89    1947   2036
## 115          0.862 0.99376 0.000024500 0.000294836      14     315    329
## 116          0.939 0.99342 0.000292135 0.003001954     165    3888   4053
## 117          0.970 0.99866 0.001000000 0.006300000     567   30200  30767
## 118          0.941 0.99756 0.000194783 0.000427807      16      64     80
## 119          0.995 0.99994 0.003694914 0.014602357    3560  187191 190751
## 120          0.994 0.99991 0.001978261 0.008342512    2403  159960 162363
## 121          0.964 0.99926 0.000369667 0.001059653      75    2183   2258
## 122          0.747 0.99686 0.000021500 0.000205139       9      85     94
## 123          0.809 0.99385 0.000241314 0.001453192      27     392    419
## 124          0.958 0.99915 0.002000000 0.011000000    1082   35211  36293
## 125          0.996 0.99996 0.003753052 0.016133219    5910  380380 386290
## 126          0.989 0.99986 0.001684996 0.003737628     312   18886  19198
## 127          0.903 0.99737 0.000785061 0.000439274      15     105    120
## 128          0.989 0.99949 0.001500000 0.006050000     690   43890  44580
## 129          0.977 0.99957 0.001347628 0.002481144     351   17424  17775
## 130          0.927 0.99487 0.000044300 0.000458078      34     390    424
## 131          0.978 0.99900 0.001056350 0.001705618      92    2006   2098
## 132          0.975 0.99813 0.001080104 0.000620102     125    4453   4578
## 133          0.968 0.99568 0.001047598 0.005574863      37     882    919
## 134          0.993 0.99973 0.001993865 0.005233928     495   21266  21761
## 135          0.996 0.99976 0.003416013 0.004629833    1800   75458  77258
## 136          0.989 0.99927 0.002618758 0.005943971    2186  163680 165866
## 137          0.995 0.99877 0.001561811 0.001915942     973   41715  42688
## 138          0.981 0.99846 0.002909731 0.006790764      58    1504   1562
## 139          0.984 0.99860 0.001925274 0.004212242     250    9504   9754
## 140          0.987 0.99875 0.004288359 0.008478449     277   12483  12760
## 141          0.840 0.99438 0.000045600 0.000385355      19     220    239
## 142          0.981 0.99983 0.000920000 0.003960000     478    9933  10411
## 143          0.986 0.99978 0.004595092 0.002030675     323    5068   5391
## 144          0.980 0.99953 0.000741667 0.003725000     218    6302   6520
## 145          0.972 0.99975 0.000270270 0.001675676     113    2093   2206
## 146          0.997 0.99995 0.035129032 0.070838710    3490  278163 281653
## 147          0.904 0.99748 0.000522581 0.001987097      49    2419   2468
## 148          0.974 0.99938 0.001417208 0.003065729     448   27621  28069
## 149          0.884 0.99496 0.000049200 0.000272283      38     504    542
## 150          0.992 0.99959 0.001987717 0.004287280     212    7956   8168
## 151          0.987 0.99944 0.001406977 0.007372093     557   20502  21059
## 152          0.731 0.99023 0.000029300 0.000437054       8     164    172
## 153          0.997 0.99975 0.001455956 0.004356458     944   30100  31044
## 154          0.992 0.99982 0.003130661 0.006636414     626   26096  26722
## 155          0.996 0.99985 0.002360320 0.007851574    1495   55233  56728
## 156          0.928 0.99806 0.000123967 0.001349174      28     442    470
## 157          0.931 0.99002 0.000721366 0.003820451     437   10920  11357
## 158          0.996 0.99976 0.003082917 0.007494042    2152  118426 120578
## 159          0.987 0.99920 0.000545582 0.001730255      51     360    411
## 160          0.911 0.99581 0.000293924 0.000884557      29     462    491
## 161          0.961 0.99905 0.000419780 0.001512088     209    7326   7535
## 162          0.836 0.98916 0.000150794 0.006021164     146    2256   2402
## 163          0.996 0.99995 0.003215466 0.010685724    3727  255696 259423
## 164          0.995 0.99995 0.003864789 0.010617438    5694  258248 263942
## 165          0.987 0.99960 0.000532873 0.001406018      61    1581   1642
## 166          0.932 0.99702 0.001998042 0.004994729      18     100    118
## 167          0.992 0.99803 0.000353619 0.002718571      98    2079   2177
## 168          0.983 0.99967 0.002547642 0.004338409     224   11060  11284
## 169          0.945 0.99211 0.000070900 0.001611311      45    1053   1098
## 170          0.893 0.99213 0.000035100 0.000302184      18     205    223
## 171          0.976 0.99966 0.000300000 0.003500000     104    1896   2000
## 172          0.962 0.99990 0.000756024 0.002750753     513    3575   4088
## 173          0.977 0.99972 0.001304944 0.002793637     158    4620   4778
## 174          0.974 0.99968 0.001569411 0.002944793     383   18632  19015
## 175          0.949 0.99922 0.002492345 0.004700143     156    4888   5044
## 176          0.962 0.99496 0.001000000 0.005000000     212    8786   8998
## 177          0.866 0.99439 0.000073900 0.000634436      22      78    100
## 178          0.976 0.99886 0.003087140 0.008343407     128    4624   4752
## 179          0.992 0.99976 0.001167608 0.002434087     833   45969  46802
## 180          0.994 0.99988 0.002208504 0.012241060    3064  240120 243184
## 181          0.882 0.99541 0.000020800 0.000336856      17     225    242
## 182          0.992 0.99997 0.002413151 0.008815197    6350  231822 238172
## 183          0.985 0.99969 0.003717802 0.000864605     404   15824  16228
## 184          0.956 0.99855 0.002615322 0.010754309      26     444    470
## 185          0.964 0.99935 0.000135747 0.001628959      67    1056   1123
## 186          0.979 0.99948 0.001765290 0.001029752     247   10528  10775
## 187          0.983 0.99775 0.000521541 0.000717003      37     270    307
## 188          0.900 0.99868 0.000310096 0.000632523      39     448    487
## 189          0.818 0.99432 0.000108071 0.001881840      36     595    631
## 190          0.915 0.99403 0.000157696 0.000707363      21     324    345
  1. Provide a scatterplot of LifeExp~TotExp, and run simple linear regression. Do not transform the variables. Provide and interpret the F statistics, R^2, standard error,and p-values only. Discuss whether the assumptions of simple linear regression met.
plot(df$TotExp, df$LifeExp, xlab = "Total Expenditures", ylab = "Life Expectancy")

model = lm(LifeExp ~ TotExp, data = df)
summary(model)
## 
## Call:
## lm(formula = LifeExp ~ TotExp, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -24.764  -4.778   3.154   7.116  13.292 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 6.475e+01  7.535e-01  85.933  < 2e-16 ***
## TotExp      6.297e-05  7.795e-06   8.079 7.71e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.371 on 188 degrees of freedom
## Multiple R-squared:  0.2577, Adjusted R-squared:  0.2537 
## F-statistic: 65.26 on 1 and 188 DF,  p-value: 7.714e-14

We can see that the distribution of the residuals do not appear to be strongly symmetrical. That means that the model predicts certain points that fall far away from the actual observed points.

plot(model$fitted.values, model$residuals)
abline(0,0)

With 120 residual degrees of freedom and 1 degree of freedom for regression, the F-table value is 6.851. The model has 1 degree of freedom for regression and 188 residual degrees of freedom, with an F-statistic of 65.26, significantly larger than the F-table value. Thus, we can reject the null hypothesis (a regression model with a zero coefficient) based on the F-statistic and p-value being below typical thresholds. However, the R2 value of 0.2577 indicates that only 25.77% of the data variation is accounted for by the model, suggesting a weak fit. Despite this, the standard error is a relatively small percentage of the coefficient.

Raise life expectancy to the 4.6 power (i.e., LifeExp^4.6). Raise total expenditures to the 0.06 power (nearly a log transform, TotExp^.06). Plot LifeExp^4.6 as a function of TotExp^.06, and r re-run the simple regression model using the transformed variables. Provide and interpret the F statistics, R^2, standard error, and p-values. Which model is “better?”

df$LifeExp4.6pow <- (df$LifeExp)^4.6
df$TotExp0.06pow <- (df$TotExp)^0.06
plot(df$TotExp0.06pow, df$LifeExp4.6pow, xlab = "Total Expenditures ^ 0.06", ylab = "Life Expectancy ^ 4.6")

model2 = lm(LifeExp4.6pow ~ TotExp0.06pow, data = df)
summary(model2)
## 
## Call:
## lm(formula = LifeExp4.6pow ~ TotExp0.06pow, data = df)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -308616089  -53978977   13697187   59139231  211951764 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -736527910   46817945  -15.73   <2e-16 ***
## TotExp0.06pow  620060216   27518940   22.53   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 90490000 on 188 degrees of freedom
## Multiple R-squared:  0.7298, Adjusted R-squared:  0.7283 
## F-statistic: 507.7 on 1 and 188 DF,  p-value: < 2.2e-16

The new model yields an F-statistic of 507.7, with the same degrees of freedom as the model from 1, which is significantly better than the F-table value compared to the previous model. Additionally, the p-value is even more favorable. Moreover, the R2 value of 0.7298 is considerably superior to the model from 1, making the transformed model the better choice. Finally, the standard error is a relatively small percentage of the coefficient.

Using the results from 3, forecast life expectancy when TotExp^.06 =1.5. Then forecast life expectancy when TotExp^.06=2.5.

LifeExpectancy = function(TotExp_0.06_value){
  y <- -736527910 + 620060216 *(TotExp_0.06_value)
  y <- y^(1/4.6)
  y
}
LifeExpectancy(1.5)
## [1] 63.31153
LifeExpectancy(2.5)
## [1] 86.50645

Build the following multiple regression model and interpret the F Statistics, R^2, standard error, and p-values. How good is the model?

LifeExp = b0+b1 x PropMd + b2 x TotExp +b3 x PropMD x TotExp

model3 <- lm(df$LifeExp4.6pow ~ df$PropMD + df$TotExp0.06pow + df$PropMD:df$TotExp0.06pow)
summary(model3)
## 
## Call:
## lm(formula = df$LifeExp4.6pow ~ df$PropMD + df$TotExp0.06pow + 
##     df$PropMD:df$TotExp0.06pow)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -296470018  -47729263   12183210   60285515  212311883 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                -7.244e+08  5.083e+07 -14.253   <2e-16 ***
## df$PropMD                   4.727e+10  2.258e+10   2.094   0.0376 *  
## df$TotExp0.06pow            6.048e+08  3.023e+07  20.005   <2e-16 ***
## df$PropMD:df$TotExp0.06pow -2.121e+10  1.131e+10  -1.876   0.0622 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 88520000 on 186 degrees of freedom
## Multiple R-squared:  0.7441, Adjusted R-squared:   0.74 
## F-statistic: 180.3 on 3 and 186 DF,  p-value: < 2.2e-16

Our multiple regression model yielded an F-statistic of 180.3, indicating strong evidence in favor of the model. The p-value supports this finding and suggests that all factors, with the exception of PropMD x TotExp0.06 (0.0622), are statistically significant. Moreover, the model’s R2 value of 0.7441 indicates that it can explain 74.41% of the variability in the data.

Forecast LifeExp when PropMD=.03 and TotExp = 14. Does this forecast seem realistic? Why or why not?

df2 = df
df2$PropMD=.03
df2$TotExp = 14
(predict(model3, newdata = df2))
##         1         2         3         4         5         6         7         8 
##  82671717 273513856 299721725 534027505 220102124 344900004 394772603 279477787 
##         9        10        11        12        13        14        15        16 
## 537630580 542617948 238285208 448352247 446453415  71594702 395546169 383577576 
##        17        18        19        20        21        22        23        24 
## 559337544 300770663 166348426 150523165 266366751 318610145 374743631 359497475 
##        25        26        27        28        29        30        31        32 
## 408775433 339747536 133070656 -18450642 101012763 183662399 538231817 294860944 
##        33        34        35        36        37        38        39        40 
## 108861204 119699985 375048811 229336640 354083180 132596277 191062309 404465067 
##        41        42        43        44        45        46        47        48 
## 366555758 136832139 419445577 426957746 657080602 465092955  58551122 576001196 
##        49        50        51        52        53        54        55        56 
## 273417070 351105273 295214757 285602884 243653240 307180262 304986047  67659758 
##        57        58        59        60        61        62        63        64 
## 419919393  56452188 294936410 518862697 556010424 365226330 161673982 276075698 
##        65        66        67        68        69        70        71        72 
## 548532238 158065501 484043748 315194953 253640164  68323978  75062594 219144468 
##        73        74        75        76        77        78        79        80 
## 164335133 243846866 441862159 591890064 125630247 166649224 323591782 262136558 
##        81        82        83        84        85        86        87        88 
## 541956922 497517006 523139392 288443390 525623043 346780924 335022878 121099190 
##        89        90        91        92        93        94        95        96 
## 282556523 448109469 185585133  80498714 395011173 382756262 152058125 145403582 
##        97        98        99       100       101       102       103       104 
## 356624236 407340987 603896795 103931764 122347882 311236330 326634993 150995026 
##       105       106       107       108       109       110       111       112 
## 496876507 372143909 151915817 295259317 377061215 302286934 603673267 253130727 
##       113       114       115       116       117       118       119       120 
## 367939318 238005674 132332303 274767623 407746231  66087263 542073740 525224890 
##       121       122       123       124       125       126       127       128 
## 241833125  70320339 148478138 425993905 589370445 383596610  96542590 435629925 
##       129       130       131       132       133       134       135       136 
## 375781679 145786642 247068724 291525806 202404596 394028198 482881633 529037730 
##       137       138       139       140       141       142       143       144 
## 433235519 257389929 345167698 384376370 116457763 338630840 342330653 308378157 
##       145       146       147       148       149       150       151       152 
## 239155687 638039202 248954300 405147644 158750260 335481504 386896430  99765656 
##       153       154       155       156       157       158       159       160 
## 411892438 416010495 456963827 152489481 341954134 509702617 152603635 157582139 
##       161       162       163       164       165       166       167       168 
## 313527749 242419483 561228223 563965978 226187075 118832943 239537055 360070114 
##       169       170       171       172       173       174       175       176 
## 197188339 112789767 233989763 280997268 296703574 381970489 313945233 330598111 
##       177       178       179       180       181       182       183       184 
##  74284215 317804476 436543073 554195309 116644697 553277910 392224015 193810573 
##       185       186       187       188       189       190 
## 199398329 349391878 137415376 157423343 167766627 137057824

The estimated lifespan was approximately 108 years, which is deemed unrealistic as it exceeds the maximum lifespan observed in reality. The reason for this is that we utilized a large value for PropMD. As linear regression is sensitive to outliers, the line of best fit that works well for most data points may not accurately represent the extreme values.