6.7 Graph: Predicted values

  • Figure 6.5 plots the data against the predicted values.
  • Questions:
    • What does the graph show? What are the underlying variables (and data)?
    • How many scales/mappings does it use? Could we reduce them?
    • What do you like, what do you dislike about the figure? What is good, what is bad?
    • What kind of information could we add to the graph (if any)?
    • How would you approach a replication of the graph?
Predicted values plot

Figure 6.5: Predicted values plot

6.7.1 Lab: Data & code

The underlying functions are very simple. First we fit the model



Then we augment the original data with the predicted values for each observed unit (they are called .fitted in the dataframe below).

Fertility Catholic Agriculture Education .fitted .se.fit .resid .hat .sigma .cooksd .std.resid
80.2 9.96 17.0 12 71.35382 2.382879 8.8461774 0.0950817 7.686424 0.0380384 1.2033653
83.1 84.84 45.1 9 79.73758 1.986646 3.3624191 0.0660897 7.800760 0.0035864 0.4502418
92.5 93.40 39.7 5 86.36550 2.749965 6.1345049 0.1266332 7.753333 0.0261545 0.8494302
85.8 33.77 36.5 7 76.21257 1.816038 9.5874340 0.0552259 7.669656 0.0238081 1.2763945
76.9 5.16 43.5 15 62.05992 1.565132 14.8400828 0.0410200 7.461386 0.0411227 1.9610021
76.1 90.57 35.3 7 84.70365 2.738870 -8.6036475 0.1256133 7.689243 0.0509128 -1.1906315
83.8 92.85 70.2 7 77.94869 1.863265 5.8513084 0.0581356 7.763671 0.0093930 0.7801989
92.4 97.16 67.8 8 77.98965 1.920812 14.4103471 0.0617821 7.474642 0.0610151 1.9251701
82.4 97.67 53.3 7 82.07990 2.120883 0.3201012 0.0753228 7.819045 0.0000378 0.0430763
82.9 91.38 45.2 13 76.37831 1.996965 6.5216935 0.0667781 7.749513 0.0136527 0.8736037
87.1 98.61 64.5 6 81.01451 1.974877 6.0854871 0.0653090 7.758656 0.0115894 0.8145314
64.1 8.52 62.0 12 62.00804 1.938108 2.0919628 0.0628997 7.812100 0.0013123 0.2796453
66.9 2.27 67.5 7 65.34456 2.103094 1.5554442 0.0740646 7.815234 0.0008750 0.2091754
68.9 4.43 60.7 12 61.67811 1.964156 7.2218873 0.0646019 7.733856 0.0161208 0.9662711
61.7 2.82 69.3 5 67.20324 2.135950 -5.5032423 0.0763968 7.769129 0.0113547 -0.7410072
68.3 24.20 72.6 2 72.85406 1.887983 -4.5540632 0.0596883 7.785561 0.0058611 -0.6077286
71.7 3.30 34.0 8 71.22373 1.913856 0.4762715 0.0613355 7.818845 0.0000661 0.0636130
55.7 12.11 19.4 28 54.02437 2.368731 1.6756342 0.0939560 7.814494 0.0013453 0.2277986
54.3 2.15 15.2 20 62.00809 2.141015 -7.7080933 0.0767596 7.720612 0.0223991 -1.0380926
65.1 2.84 73.0 9 62.16632 2.441139 2.9336804 0.0997879 7.804644 0.0044366 0.4001169
65.5 5.23 59.8 10 64.12130 1.809818 1.3786987 0.0548483 7.816151 0.0004886 0.1835123
65.0 4.52 55.1 3 72.47751 1.873811 -7.4775133 0.0587956 7.728238 0.0155355 -0.9973825
56.6 15.14 50.9 12 65.22299 1.400457 -8.6229883 0.0328423 7.701273 0.0109292 -1.1346337
57.4 4.20 54.1 6 69.41765 1.701651 -12.0176461 0.0484880 7.584603 0.0323800 -1.5942587
72.5 2.40 71.2 1 71.04507 2.262283 1.4549265 0.0857012 7.815688 0.0009085 0.1968990
74.2 5.23 58.1 8 66.61076 1.713207 7.5892409 0.0491488 7.726439 0.0131074 1.0071371
72.0 2.56 63.5 3 70.48740 1.994731 1.5125978 0.0666287 7.815480 0.0007325 0.2026016
60.5 7.72 60.8 10 64.27981 1.795511 -3.7798150 0.0539845 7.796186 0.0036078 -0.5028841
58.3 18.46 26.8 19 63.09324 1.672496 -4.7932370 0.0468407 7.782428 0.0049589 -0.6353202
65.4 6.10 49.5 8 68.48321 1.563767 -3.0832083 0.0409484 7.804108 0.0017717 -0.4074069
75.5 99.71 85.9 2 81.11782 2.312001 -5.6178154 0.0895095 7.766260 0.0142655 -0.7618619
69.3 99.68 84.9 6 77.02791 2.341290 -7.7279097 0.0917917 7.718450 0.0278221 -1.0493391
77.3 100.00 89.7 2 80.38838 2.434368 -3.0883806 0.0992351 7.803075 0.0048836 -0.4210868
70.5 98.96 78.2 6 78.28372 2.116960 -7.7837172 0.0750444 7.718843 0.0222476 -1.0473049
79.4 98.22 64.9 3 84.09311 2.104557 -4.6931098 0.0741677 7.782909 0.0079782 -0.6311623
65.0 99.06 75.9 9 75.54878 2.142516 -10.5487835 0.0768672 7.633481 0.0420195 -1.4207472
92.2 99.46 84.6 3 80.27332 2.271382 11.9266828 0.0863920 7.578458 0.0616348 1.6146792
79.3 96.83 63.1 13 73.53528 1.997243 5.7647206 0.0667967 7.764807 0.0106707 0.7722122
70.4 5.62 38.4 12 66.37864 1.526976 4.0213575 0.0390443 7.793550 0.0028624 0.5308447
65.7 13.79 7.7 11 74.87034 3.045111 -9.1703410 0.1552742 7.666145 0.0766076 -1.2911424
72.7 11.22 16.7 13 70.52554 2.322946 2.1744592 0.0903590 7.811295 0.0021616 0.2950277
64.4 16.92 17.6 32 50.79966 2.748782 13.6003353 0.1265242 7.489869 0.1284116 1.8830884
77.6 4.97 37.6 7 71.80743 1.854261 5.7925740 0.0575751 7.764817 0.0091058 0.7721377
67.6 8.65 18.7 7 76.17918 2.762755 -8.5791790 0.1278138 7.689659 0.0517707 -1.1887421
35.0 42.34 1.2 53 35.30542 5.209194 -0.3054172 0.4543956 7.818953 0.0005961 -0.0535058
44.7 50.43 46.6 29 52.99371 2.848807 -8.2937095 0.1358999 7.697062 0.0524109 -1.1545515
42.8 58.33 27.7 29 57.97821 2.546661 -15.1782122 0.1086014 7.415297 0.1318153 -2.0803249



Then we can plot the real outcome values of the variable Fertility against the predictions made by our model .fitted. Importantly, the gray line in the figure below is no the regression line!