Data Summary

The below dataset contains real-world data from 2008. The variables included:

variable description
Country name of the country.
LifeExp average life expectancy for the country in years.
InfantSurvival proportion of those surviving to one year or more.
Under5Survival proportion of those surviving to five years or more.
TBFree proportion of the population without TB.
PropMD proportion of the population who are MDs
PropRN proportion of the population who are RNs.
PersExp mean personal expenditures on healthcare in US dollars at average exchange rate.
GovtExp mean government expenditures per capita on healthcare, US dollars at average exchange rate.
TotExp sum of personal and government expenditures.
df <- read.csv("/Users/aaronzalki/Desktop/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

Problem 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.

Linear Model

lm1 = lm(df$LifeExp ~ df$TotExp)
summary(lm1)
## 
## Call:
## lm(formula = df$LifeExp ~ df$TotExp)
## 
## 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 ***
## df$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

Although the variables are significant with low p-values, the model is not good because the \(R^2\) is low (~26%). The \(R^2\) value represents the proportion of variability in the response variable that is explained by the explanatory variable. For this model, 26% of the variability in average life expectancy for the country is explained by the sum of personal and government expenditures. The F-statistic is 65 (we would like this to be higher) and this metric is used to compare different models.

Scatterplot

plot(df$LifeExp, df$TotExp)
abline(lm1, col = "green")

Diagnostic Plots

plot(lm1)

Based on the diagnostic plots, we can see that some residuals are very high. The Normal Q-Q plot shows the residuals following a slighly skewed distribution. In the Scale-Location plot, the residuals appear to not be following the model very well, since there are a lot of residuals that do not follow the line. Lastly, the Residuals vs Leverage plot, shows that a few residuals have higher leverage than our other models and some have very high influence.

Problem 2

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 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?”

#transform data
df2 <- df
df2$LifeExp <- df2$LifeExp^4.6
df2$TotExp <- df2$TotExp^0.06

Linear Model

lm2 <-lm(df2$LifeExp ~ df2$TotExp)
summary(lm2)
## 
## Call:
## lm(formula = df2$LifeExp ~ df2$TotExp)
## 
## 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 ***
## df2$TotExp   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 model has improved significantly. The low p-values demonstrate that the variables are still statistically significant.The \(R^2\) is much higher with an explained variance of 0.7298. The F-statistic (507.7) is much higher than the previous model, which is better for rejecting the null hypothesis that there is no relationship between the variables LifeExp and TotExp.

Scatterplot

plot(df2$LifeExp, df2$TotExp)
abline(lm2)

Diagnostic Plots

plot(lm2)

Overall the residuals are more normal than the original model. The Normal Q-Q plot shows that the residuals follow a less skewed distribution. In the Scale-Location plot, the residuals appear to be more evenly distributed. In the Residuals vs Leverage plot, no residuals have a very high leverage/influence.

Problem 3

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

\[ \hat{y} = -736527910 + 620060216 * {expenditures} \]

When TotExp^.06 =1.5, life expectancy is:

x_1.5 <- 1.5
y <- -736527910  + 620060216 * {x_1.5}
ylog <- y^(1/4.6)
ylog
## [1] 63.31153

When TotExp^.06 =2.5, life expectancy is:

x_2.5 <- 2.5
y2 <- -736527910  + 620060216 * {x_2.5}
ylog2 <- y2^(1/4.6)
ylog2
## [1] 86.50645

Problem 4

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

Multiple Regression Model

df$md_exp <- df$PropMD * df$TotExp
lm4 = lm(df$LifeExp ~ df$PropMD + df$TotExp + df$md_exp, data = df)
summary(lm4)
## 
## Call:
## lm(formula = df$LifeExp ~ df$PropMD + df$TotExp + df$md_exp, 
##     data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -27.320  -4.132   2.098   6.540  13.074 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  6.277e+01  7.956e-01  78.899  < 2e-16 ***
## df$PropMD    1.497e+03  2.788e+02   5.371 2.32e-07 ***
## df$TotExp    7.233e-05  8.982e-06   8.053 9.39e-14 ***
## df$md_exp   -6.026e-03  1.472e-03  -4.093 6.35e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.765 on 186 degrees of freedom
## Multiple R-squared:  0.3574, Adjusted R-squared:  0.3471 
## F-statistic: 34.49 on 3 and 186 DF,  p-value: < 2.2e-16

The p-values demonstrate that all variables are statistically significant. The standard error is only high for PropMD (proportion of the population who are MDs). Similar to Problem 1, the \(R^2\) is low with an explained variance of .3574. The F-statistic is 34 (we would like this to be higher). I think this is lower compared to the previous two models because this metric penalizes the user for utilizing more variables.

Problem 5

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

Coefficients

options(scipen=999)
#display coefficients without scientific notation
coef(lm4)
##      (Intercept)        df$PropMD        df$TotExp        df$md_exp 
##   62.77270325541 1497.49395251893    0.00007233324   -0.00602568644

\[ \hat{y} = 62.77 + 1497.49 * {MDproportion} + 0.00007 *expenditures -0.006*{MDproportion}*expenditures \]

md <- .03
exp <- 14
y5 <- 62.77  + 1497.49 * md + 0.00007 *exp -0.006*md*exp
y5
## [1] 107.6932

The forecast does not seem realistic. The prediction of 107 years old is very high for most countries. Therefore, this model must not be good at analyzing life expectancy.