library(ggfortify)
## Loading required package: ggplot2
  library(ggplot2)
  library(readr)
  library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
  library(tidyr)
  library(viridis)
## Loading required package: viridisLite
  library(ggthemes)
  library(ggalt)
## Registered S3 methods overwritten by 'ggalt':
##   method                  from     
##   fortify.table           ggfortify
##   grid.draw.absoluteGrob  ggplot2  
##   grobHeight.absoluteGrob ggplot2  
##   grobWidth.absoluteGrob  ggplot2  
##   grobX.absoluteGrob      ggplot2  
##   grobY.absoluteGrob      ggplot2
Week6 <- read.table(file="C:/R/classwork/Assignment/wek6/data6.csv", header=TRUE,  sep=",", stringsAsFactors = TRUE)
Week6
##     Expenditures Enrolled       RVUs    FTEs Quality.Score
## 1      114948144    25294  402703.73  954.91          0.67
## 2      116423140    42186  638251.99  949.25          0.58
## 3      119977702    23772  447029.54  952.51          0.52
## 4       19056531     2085   43337.26  199.98          0.93
## 5      246166031    67258 1579789.36 2162.15          0.96
## 6      152125186    23752  673036.55 1359.07          0.56
## 7      737556867    53781 2397334.12 5798.04          0.84
## 8      431714041    98763 2256730.04 3623.94          0.82
## 9      378230874    47986 1558835.73 3305.32          0.76
## 10     289246447    64634 1713157.92 2404.80          0.81
## 11     292001890    76714 1156318.42 1690.42          0.83
## 12      33290437    11163  161196.70  214.72          0.70
## 13      89918238    33266  550546.15  786.15          0.60
## 14     200289585    35008 1050922.34 1784.82          0.75
## 15     154264931    42984 1010128.12 1325.65          0.64
## 16     111397716    15821  372044.89  957.25          0.73
## 17      63691831    21657  485389.31  483.36          0.68
## 18     177511820    57006  838595.08 1323.09          0.83
## 19     155047333    18580 1030776.45 1326.46          0.83
## 20     421917863    40639 1357463.45 3495.57          0.82
## 21      49422291    17343  248057.53  337.61          0.76
## 22     704000406   108960 3017131.83 5345.62          0.85
## 23     231372781    48338 1665055.71 2032.83          0.75
## 24      92965171    27454  560475.02  762.67          0.89
## 25     148661984    20476  736191.93 1166.26          0.84
## 26      52500954    17125  254384.25  428.16          0.84
## 27      48990120    13781  240808.17  434.20          0.59
## 28     175601378    30571  994000.52 1474.55          0.93
## 29     627739846    65154 2707224.50 4784.79          0.88
## 30      56291987    12107  184173.46  500.96          0.74
## 31     384804579    65885 1648839.75 3444.47          0.70
## 32     211543524    57098 1102229.23 1744.00          0.90
## 33     481316889   115521 2552169.39 4003.16          0.73
## 34     123018246    30540  488432.15  753.12          0.84
## 35      17193213     4327   49293.75  177.65          0.56
## 36      30664899    13527  128738.76  283.17          0.75
## 37      19768937     7209   89148.62  206.42          0.69
## 38      55784977    17266  174289.61  586.06          0.71
## 39      37992105    14842  146174.89  348.40          0.71
## 40      39448397    11953  138345.36  373.62          0.70
## 41      49637051    25420  241419.44  497.49          0.74
## 42      28530205    12110  124162.92  260.72          0.55
## 43      30673348    11466  113732.83  298.50          0.76
## 44      25234710    11454  113222.94  265.81          0.53
## 45      49671099    16845  145258.22  413.01          0.40
## 46      22557139     8131   91710.45  217.08          0.65
## 47      15516577     4521   54406.39  204.56          0.71
## 48      47429842     8002  120720.78  426.67          0.76
## 49      43366439    13364  146786.49  406.80          0.74
## 50      20223890    10009   83916.19  202.41          0.62
## 51      18363510     6103   60862.37  188.40          0.75
## 52      47778415    22259  218827.23  410.02          0.63
## 53      45322490    22959  232476.04  366.63          0.80
## 54      41314090     7604  111419.60  464.88          0.73
## 55      41831991    10417  142963.42  378.73          0.81
## 56      20109657     6149   72473.83  229.39          0.65
## 57      50755308     7042  127018.26  517.54          0.91
## 58      69272642    24565  323225.69  703.60          0.67
## 59      40575888    14849  129274.86  343.20          0.41
## 60      20958223     2578   49777.27  207.06          0.68
## 61      25628795     7691   93237.75  277.07          0.53
## 62      44432989    16932  185326.68  329.76          0.59
## 63      33521880    12213  132282.28  352.28          0.69
## 64      46306286    14439  143826.20  307.96          0.76
## 65      15736197     3887   45836.14  169.74          0.72
## 66      91103765    22214  356917.60  947.74          0.65
## 67      29637497    11648  133160.97  288.03          0.64
## 68      32821893    11552  131678.51  332.10          0.56
## 69      28426761    11298  110997.40  288.20          0.76
## 70      37534503     7319  109734.18  457.09          0.62
## 71      35432093    11743  120563.35  352.10          0.65
## 72      82601055    28151  320705.78  746.06          0.85
## 73      64545467    27250  313899.05  546.20          0.66
## 74      28901543     6758   71855.26  268.14          0.67
## 75     671959058    54771 1865586.33 5697.77          0.81
## 76      29361928    12577  118062.13  300.97          0.89
## 77     320604335    40225  808455.56 2415.15          0.59
## 78      19790938     8265   75995.61  161.15          0.68
## 79      28382056    12188  125125.92  268.02          0.50
## 80     133789826    35570  550683.00 1239.03          0.77
## 81      11906768     1424   23581.51  137.55          0.72
## 82      19448328     6766   48223.16  170.92          0.61
## 83     150947798    37795  608182.20 1260.65          0.63
## 84     113604093    33319  406929.00  640.55          0.79
## 85      15487046     4227   44759.38  168.01          0.67
## 86      55312465    22109  256084.38  502.99          0.60
## 87      49645517    17442  242765.52  433.78          0.78
## 88     151611402    27667  556371.89 1373.80          0.63
## 89      47833729    15449  181309.06  429.29          0.76
## 90      31467898    10324  112718.98  311.40          0.68
## 91     221899340    27207  710440.86 1824.36          0.68
## 92      51656073    10054  199461.51  492.75          0.72
## 93      93746534    20601  231366.13  919.47          0.78
## 94      45093715    16176  185456.99  421.68          0.70
## 95     290852934    36549  855724.09 2271.85          0.83
## 96      16275452     2062   32058.03  185.23          0.49
## 97      23880752     8922  101135.34  228.50          0.72
## 98      30422168    10949  108488.17  300.02          0.41
## 99     179510966    33125  684679.01 1587.88          0.81
## 100     15868393     4943   55961.81  151.10          0.71
## 101    191489002    45613  738618.70 1649.62          0.55
## 102     33946305     9001   90746.40  389.07          0.82
## 103    112886022    26776  503561.98  966.04          0.81
## 104    118474189    10184  584607.15 1129.51          0.78
## 105    170396460    34609  714332.05 1315.37          0.83
## 106    242465456    31301 1212558.88 2432.32          0.79
## 107    279086160    48049 1468797.93 2317.23          0.83
## 108     90695660    10976  280721.41  811.31          0.73
## 109     33692909     1218   52387.28  290.49          0.73
## 110    281085750    56812 1387650.41 2353.20          0.81
## 111     70232710    14086  297280.10  659.61          0.72
## 112     67058602     5628  154626.03  556.60          0.78
## 113     57406032    14897  327289.34  473.52          0.69
## 114    133421055    15611  734445.95 1318.31          0.78
## 115    239806816    46403 1030474.35 2031.98          0.78
## 116     44222933     2642   90139.68  398.66          0.82
## 117     55797686     7852  167676.80  503.27          0.64
## 118     74134323    14783  337025.73  636.82          0.64
## 119    129861050    21585  480628.61 1306.36          0.58
## 120     38680530    13153  243534.20  332.89          0.76
## 121     49129643    16577  231843.71  419.97          0.91
## 122     49575746    14431  279027.99  401.68          0.79
## 123     66972157    12728  169068.75  471.70          0.73
## 124     75793328    29339  525417.05  664.01          0.86
## 125     38437460    15428  177338.98  321.46          0.86
## 126     59443879    21742  347643.62  551.92          0.71
## 127    806367625   101454 3434703.16 6658.61          0.92
## 128    785079539    40402 1844285.41 4655.55          0.92
## 129    129946379    25540  460637.39  910.46          0.72
## 130    117827082    42206  763481.71  974.07          0.53
## 131    124633496    24435  471401.75  941.42          0.60
## 132     15335594     1906   45977.13  186.63          0.70
## 133    280918530    71993 1810996.19 2094.17          0.93
## 134    142671518    29449  680826.00 1227.45          0.67
## 135   1052311021    57397 2892975.46 7518.63          0.79
## 136    452667260   100569 2390290.31 3587.36          0.76
## 137    370586067    45085 1624727.69 3107.84          0.76
## 138    294389493    68214 1836855.21 2311.60          0.85
## 139    478981007    81497 1736067.57 3542.01          0.69
## 140     34827530    10631  150177.82  208.10          0.64
## 141     94258566    34222  568984.13  788.41          0.49
## 142    204873437    32113  945113.43 1598.94          0.73
## 143    164690465    45838 1157782.51 1363.49          0.65
## 144    105635716    13241  338120.18  811.58          0.63
## 145     73110154    21077  512124.61  501.03          0.73
## 146    178424383    59407  989358.63 1164.10          0.84
## 147    168267964    20236 1071997.55 1297.82          0.85
## 148    453595967    41256 1453868.97 3361.97          0.73
## 149     55868770    17757  264847.07  338.83          0.83
## 150    672113787   116389 3093666.05 5004.26          0.79
## 151    263617995    54261 1692788.53 2050.02          0.74
## 152     88213119    25920  587833.28  725.47          0.91
## 153    154460753    21819  723014.94 1105.41          0.79
## 154     54996100    16242  261201.56  395.37          0.86
## 155     48828341    12078  252941.14  394.23          0.94
## 156    187119684    30279 1015301.82 1422.28          0.82
## 157    674563921    66212 2673082.99 4685.47          0.74
## 158     59942400    11141  213605.00  483.70          0.83
## 159    417756027    72259 1852559.13 3478.57          0.81
## 160    214429435    58625 1290205.03 1671.86          0.85
## 161    522108466   116298 2616782.68 3879.58          0.79
## 162    122543052    29016  479062.73  720.95          0.77
## 163     18386529     4199   56064.49  156.28          0.59
## 164     33333082    13781  133997.55  270.14          0.83
## 165     20523439     7050   91612.91  176.79          0.76
## 166     59426076    17134  172765.34  532.25          0.57
## 167     40355791    13909  153028.08  351.94          0.78
## 168     41684323    12776  147494.34  373.30          0.67
## 169     53590324    23901  247909.39  463.56          0.78
## 170     29439049    11834  134265.66  249.42          0.71
## 171     30939512    10869  121982.43  297.32          0.82
## 172     26985594    11279  122499.26  256.12          0.64
## 173     51174054    16994  185507.03  394.24          0.39
## 174     23753605     7853   94789.14  210.53          0.59
## 175     15659058     4749   63977.31  187.68          0.72
## 176     50888100     7850  136429.27  412.04          0.85
## 177     43768308    12351  154733.89  350.68          0.81
## 178     23082323     9982   90140.88  241.51          0.66
## 179     18261275     5937   67479.03  186.47          0.66
## 180     49348318    19519  227044.07  394.49          0.68
## 181     43254472    24654  258675.34  330.13          0.85
## 182     43335191     7259  128745.31  398.97          0.70
## 183     42773074    10141  165737.75  374.74          0.67
## 184     21323162     6142   62422.39  193.86          0.49
## 185     56032849     6812  143776.97  459.01          0.63
## 186     70268334    24571  344199.65  657.36          0.69
## 187     42586104    12020  139945.55  320.77          0.31
## 188     21902259     2662   55472.38  190.79          0.74
## 189     27534164     7644   99528.47  271.41          0.68
## 190     47356861    16513  192851.20  307.29          0.60
## 191     33675604    11456  146346.45  316.67          0.64
## 192     49966638    14648  168293.14  277.44          0.78
## 193     15484896     3810   47317.01  150.47          0.70
## 194     95034213    17811  359659.92  811.18          0.59
## 195     30276033    11075  129988.91  281.42          0.76
## 196     33343818    11080  136237.85  324.82          0.48
## 197     28896477    11666  112823.36  265.84          0.79
## 198     40787554     7357  115452.21  427.65          0.85
## 199     38388629     8548  109251.92  330.95          0.61
## 200     80916337    27326  361224.99  685.37          0.74
## 201     68113499    26144  330031.76  518.75          0.66
## 202     29372038     7087   64318.29  267.16          0.73
## 203    651743770    50687 1601793.92 5048.47          0.88
## 204     29696092    12393  127030.34  276.22          0.80
## 205    348797885    39078  863863.99 2340.06          0.58
## 206     20663099     8438   82060.19  164.62          0.58
## 207     30201767    11945  144498.15  272.21          0.54
## 208    150320044    37600  620445.23 1284.54          0.76
## 209     12085971     1445   23218.01  120.30          0.79
## 210     20375822     6716   58518.34  165.32          0.68
## 211    160608494    37162  641388.93 1228.19          0.58
## 212     96365310    33829  415452.70  581.08          0.68
## 213     14780257     4145   53073.19  145.87          0.67
## 214     57948488    20244  262939.04  454.48          0.54
## 215     50683600    17047  256896.61  396.00          0.72
## 216    148969823    28338  558736.60 1130.04          0.63
## 217     49950740    13792  189081.27  420.35          0.80
## 218     32146051    10634   99266.92  288.41          0.83
## 219    235165404    26731  740702.89 1684.47          0.76
## 220     49943851     9517  195731.34  444.26          0.70
## 221     93550306    20120  235349.05  839.14          0.65
## 222     46805669    16892  213023.68  408.52          0.61
## 223    322738262    37171  903695.93 2031.06          0.87
## 224     17519828     2423   34588.14  184.65          0.60
## 225     25110314     8647   92861.20  213.82          0.57
## 226     32623104    10319  118254.98  293.35          0.48
## 227    191736477    34861  721944.14 1549.64          0.84
## 228     16646964     5166   60638.99  146.90          0.66
## 229    223513993    47105  869628.09 1659.27          0.58
## 230     35964730     8748   97346.03  361.02          0.83
## 231    121800528    26994  519196.24  965.89          0.70
## 232    121524734    10564  564985.07 1078.21          0.84
## 233    182373869    34255  747807.29 1319.79          0.79
## 234    256575567    31548 1331724.66 2282.88          0.76
## 235    288406519    48251 1483892.38 2229.13          0.76
## 236     95104995    10983  301374.21  806.66          0.67
## 237     36287531     1602   49394.58  280.38          0.61
## 238    287374111    56569 1358605.37 2252.70          0.71
## 239     73206957    13163  303746.49  615.57          0.77
## 240     63328607     5319  153975.67  531.35          0.81
## 241     59419192    14653  332710.38  427.31          0.77
## 242    144359005    16182  783710.24 1265.67          0.67
## 243    246761080    45429 1075503.19 1973.93          0.87
## 244     49838003     2700   99966.78  404.84          0.87
## 245     59641487     8344  186116.14  494.66          0.66
## 246     78802547    14439  353629.69  643.62          0.66
## 247    141710583    20243  525514.30 1281.47          0.80
## 248     44037424    13693  244664.82  316.48          0.67
## 249     50511046    16514  213393.96  349.72          0.87
## 250     49336614    14441  294497.96  401.89          0.79
## 251     61325036    12573  191410.10  462.72          0.69
## 252     84252197    29155  520728.07  642.60          0.83
## 253     43864242    15582  178586.90  312.64          0.74
## 254     61412502    21966  349811.35  548.66          0.68
## 255    818656771   100584 3574006.15 6613.28          0.89
## 256   1301993928    50927 2822798.99 7264.44          0.80
## 257     94047315    25065  490004.41  877.76          0.68
## 258     78707019    37484  685670.00  882.74          0.61
## 259     99843160    23433  464193.99  930.94          0.57
## 260     10411614     2146   52575.69  168.81          0.55
## 261    210852507    69862 1497851.52 2074.33          0.93
## 262    107067124    31989  670977.65 1365.40          0.87
## 263    782762374    57259 2694416.86 7410.52          0.82
## 264    337731158   101429 2209837.83 3334.43          0.78
## 265    282567119    44940 1330621.99 3016.47          0.71
## 266    229521482    70900 1782559.31 2330.10          0.83
## 267    380317663    82717 1649419.95 3447.24          0.64
## 268     26083915    11517  146801.47  191.09          0.76
## 269     69635722    32476  531543.72  779.58          0.42
## 270    150516975    32330  838022.94 1538.72          0.66
## 271    123626592    42568  955567.97 1324.11          0.67
## 272     76813305    13182  245494.03  714.26          0.60
## 273     46084228    21118  432508.24  482.78          0.71
## 274    140235269    61512  840078.05 1169.56          0.77
## 275    122357396    22131  992598.16 1285.99          0.78
## 276    360490554    52361 1519461.14 3440.47          0.67
## 277     37884197    17669  254492.22  318.90          0.78
## 278    524079263   119076 2860646.31 4868.98          0.74
## 279    186727705    55480 1469704.84 1985.09          0.57
## 280     63568011    25112  494032.79  670.45          0.90
## 281    110928482    23827  699243.04 1034.51          0.77
## 282     39233373    16640  260642.92  397.81          0.87
## 283     35323954    12072  228236.18  345.64          0.91
## 284    133895187    30483  931018.64 1341.27          0.78
## 285    529484041    67509 2382358.81 4505.88          0.72
## 286     43736668    10878  180151.59  499.05          0.65
## 287    328821735    70252 1773661.16 3362.13          0.78
## 288    160042102    59168 1061118.57 1671.68          0.78
## 289    389431356   119850 2296382.01 3842.06          0.78
## 290     88037818    28051  448635.12  683.56          0.68
## 291     12643654     4176   62945.84  138.28          0.64
## 292     24252878    13885  128449.03  247.60          0.89
## 293     13805046     7456   88515.40  161.19          0.81
## 294     42703747    16813  157896.70  484.02          0.63
## 295     29590277    14476  138303.63  322.78          0.75
## 296     29827614    12618  163418.40  359.91          0.78
## 297     41077626    24956  250186.86  480.69          0.77
## 298     20069865    11401  122452.70  254.62          0.73
## 299     21702658    10566  104959.54  271.87          0.77
## 300     19829246    11045  110138.68  246.52          0.79
## 301     35631699    17212  174017.19  383.20          0.45
## 302     17309855     7802   88910.56  193.31          0.62
## 303     12232590     5041   58002.30  171.03          0.75
## 304     38724750     7633  126546.43  444.72          0.78
## 305     28129131    12915  134342.38  296.44          0.89
## 306     16982095     9906   96588.69  211.67          0.61
## 307     13481673     5633   55652.31  163.42          0.55
## 308     40115495    20690  219136.01  369.63          0.69
## 309     28374756    24649  230505.80  328.96          0.89
## 310     35739680     7267  114423.35  406.87          0.59
## 311     30151930    10063  145334.13  385.38          0.68
## 312     16189811     5999   67858.67  202.65          0.44
## 313     43005541     7012  129690.83  430.12          0.59
## 314     54299717    24207  315507.42  630.25          0.70
## 315     29156276    11793  133477.57  305.89          0.31
## 316     18592043     2500   44197.16  185.50          0.82
## 317     20081127     7446   88526.54  248.49          0.69
## 318     32138620    16419  170237.89  306.84          0.58
## 319     22877488    11449  127905.57  301.17          0.68
## 320     33859690    14823  144092.99  265.25          0.91
## 321     10180284     3685   52157.86  125.00          0.75
## 322     70781594    17746  320445.13  814.42          0.66
## 323     20969209    10753  109821.43  272.34          0.70
## 324     23225910    10673  117906.07  288.43          0.50
## 325     19876545    11915  106202.23  246.63          0.77
## 326     29423436     7619  107960.68  398.87          0.75
## 327     27852806     7943   87815.68  315.10          0.66
## 328     58803092    27118  331616.59  648.77          0.69
## 329     48609297    25552  310370.02  497.67          0.58
## 330     21187801     7384   74864.60  242.31          0.74
## 331    463611180    52490 1426871.64 4665.43          0.88
## 332     20926931    12575  128328.62  261.39          0.75
## 333    248413335    39215  810171.13 2261.38          0.48
## 334     16339169     8284   65142.62  170.92          0.60
## 335     22953113    12253  134131.67  269.36          0.64
## 336    111205662    38545  598097.42 1297.28          0.65
## 337      7839563     1390   23391.25  116.29          0.86
## 338     16286538     6901   47320.66  135.83          0.58
## 339    119293449    37124  623674.43 1186.71          0.63
## 340     68360435    36696  385697.33  578.16          0.59
## 341     10836186     4120   47847.89  135.89          0.71
## 342     40189939    20393  243788.74  441.88          0.55
## 343     35401236    17116  223210.61  343.91          0.72
## 344    107506235    28789  479689.96 1146.34          0.70
## 345     34917728    15227  159420.23  406.61          0.75
## 346     22436001     9892   98620.22  264.85          0.75
## 347    164036058    26372  666386.35 1580.19          0.71
## 348     33399114     9693  176535.27  382.26          0.71
## 349     70201713    19743  197356.55  799.58          0.65
## 350     32754540    17299  207190.31  384.97          0.50
## 351    206886756    37266  783489.55 1870.42          0.81
## 352     13779195     2232   28972.31  162.39          0.55
## 353     17940731     8509   86070.80  205.99          0.44
## 354     21996524    10731  111598.06  279.85          0.40
## 355    145052995    36714  651147.15 1554.25          0.75
## 356     11599674     5117   53306.14  139.95          0.70
## 357    157480675    48077  774026.56 1467.97          0.57
## 358     25699503     9269   94087.39  338.05          0.78
## 359     87606611    26811  460717.48  931.23          0.77
## 360     88268292    10638  584343.14 1032.31          0.85
## 361    137687522    34157  659398.59 1331.56          0.77
## 362    209778567    28452 1207717.46 2291.80          0.77
## 363    217234362    54088 1468947.94 2256.08          0.73
## 364     72748524    12578  272805.82  807.40          0.67
## 365     27017111     2495   45743.93  273.63          0.65
## 366    211706640    55780 1186891.23 2197.67          0.65
## 367     53091253    12886  283437.31  602.52          0.73
## 368     50101230     5085  137424.07  548.62          0.72
## 369     44076052    14108  294641.54  457.95          0.75
## 370    114704162    17808  758965.24 1361.03          0.64
## 371    180743712    47608  997600.45 1919.63          0.89
## 372     41248792     2627   86193.90  436.02          0.91
## 373     43070966     7366  171945.87  492.47          0.74
## 374     57893841    14046  333834.43  632.80          0.68
## 375    115901469    20703  482809.71 1259.61          0.74
## 376     30655008    12915  225910.92  301.84          0.79
## 377     33484177    16302  181430.97  372.68          0.88
## 378     36840773    14143  311830.18  414.35          0.73
## 379     44320061    12909  165571.09  448.58          0.73
## 380     62746031    29229  468078.61  652.88          0.75
## 381     27700261    15128  159782.94  295.72          0.68
## 382     42906055    20627  286767.83  523.77          0.53
## 383    613026612   102325 3313522.61 6392.68          0.82
## 384    973911640    50913 2384670.02 6666.90          0.71
str(Week6)
## 'data.frame':    384 obs. of  5 variables:
##  $ Expenditures : num  1.15e+08 1.16e+08 1.20e+08 1.91e+07 2.46e+08 ...
##  $ Enrolled     : int  25294 42186 23772 2085 67258 23752 53781 98763 47986 64634 ...
##  $ RVUs         : num  402704 638252 447030 43337 1579789 ...
##  $ FTEs         : num  955 949 953 200 2162 ...
##  $ Quality.Score: num  0.67 0.58 0.52 0.93 0.96 0.56 0.84 0.82 0.76 0.81 ...
## x<-model.matrix(~ Expenditures + Enrolled + RVUs + FTEs + Quality.Score,Week6)

## x
## y<-Week6$Enrolled
## y
##xtxi<-solve(t(x) %*% x)

## xtxi %*% t(x) %*% y
#loading psych package
require(psych)
## Loading required package: psych
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
Week6Desc <- describe(Week6)    # Summary Statistics
Week6Desc
##               vars   n         mean           sd      median     trimmed
## Expenditures     1 384 124765816.51 173435868.06 52796103.84 84600936.46
## Enrolled         2 384     24713.82     22756.42    16466.00    20647.21
## RVUs             3 384    546857.77    680047.21   246701.71   398680.18
## FTEs             4 384      1060.86      1336.29      483.07      750.11
## Quality.Score    5 384         0.71         0.11        0.73        0.72
##                       mad        min          max        range  skew kurtosis
## Expenditures  47444814.57 7839562.52 1.301994e+09 1.294154e+09  3.04    11.27
## Enrolled         13092.10    1218.00 1.198500e+05 1.186320e+05  1.94     4.14
## RVUs            237760.93   23218.01 3.574006e+06 3.550788e+06  2.10     4.27
## FTEs               401.38     116.29 7.518630e+03 7.402340e+03  2.55     6.94
## Quality.Score        0.10       0.31 9.600000e-01 6.500000e-01 -0.55     0.40
##                       se
## Expenditures  8850612.08
## Enrolled         1161.28
## RVUs            34703.51
## FTEs               68.19
## Quality.Score       0.01

The RVUs values, are greater than 3 standard deviations from the mean. This could influence any interpretations made from the outcome of the correlation analysis.

Week6$outlier_Enrolled <- ( Week6$Enrolled - Week6Desc["Enrolled","mean"] ) / Week6Desc["Enrolled","sd"] 

sum(abs((Week6$outlier_Enrolled)>3))
## [1] 12
Week6$outlier_RVUs <- ( Week6$RVUs - Week6Desc["RVUs","mean"])  / (Week6Desc["RVUs","sd"] ) 

sum(abs((Week6$outlier_RVUs)>3))  
## [1] 12
slope <-cor(Week6$RVUs,Week6$Enrolled) * (sd(Week6$Enrolled)/sd(Week6$RVUs))
slope
## [1] 0.03062542
intercept <- mean(Week6$Enrolled) - (slope * mean(Week6$RVUs))
intercept
## [1] 7966.066
library('tidyverse')
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ tibble  3.1.8     ✔ stringr 1.5.0
## ✔ purrr   1.0.1     ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ psych::%+%()    masks ggplot2::%+%()
## ✖ psych::alpha()  masks ggplot2::alpha()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(ggplot2)


library(dplyr)
library(ggplot2)

Week6 %>%
 ggplot(aes(x = Week6$RVUs, y = Week6$Enrolled)) +
 geom_point(colour = "red")
## Warning: Use of `Week6$RVUs` is discouraged.
## ℹ Use `RVUs` instead.
## Warning: Use of `Week6$Enrolled` is discouraged.
## ℹ Use `Enrolled` instead.

cor(Week6)
##                  Expenditures  Enrolled      RVUs      FTEs Quality.Score
## Expenditures        1.0000000 0.7707756 0.9217239 0.9796506     0.2749501
## Enrolled            0.7707756 1.0000000 0.9152024 0.8148491     0.2526991
## RVUs                0.9217239 0.9152024 1.0000000 0.9504093     0.3075742
## FTEs                0.9796506 0.8148491 0.9504093 1.0000000     0.2769058
## Quality.Score       0.2749501 0.2526991 0.3075742 0.2769058     1.0000000
## outlier_Enrolled    0.7707756 1.0000000 0.9152024 0.8148491     0.2526991
## outlier_RVUs        0.9217239 0.9152024 1.0000000 0.9504093     0.3075742
##                  outlier_Enrolled outlier_RVUs
## Expenditures            0.7707756    0.9217239
## Enrolled                1.0000000    0.9152024
## RVUs                    0.9152024    1.0000000
## FTEs                    0.8148491    0.9504093
## Quality.Score           0.2526991    0.3075742
## outlier_Enrolled        1.0000000    0.9152024
## outlier_RVUs            0.9152024    1.0000000
plot(Week6)

** The strength of the relationship can be quantified using the Pearson correlation coefficient.

cor(Week6$RVUs,Week6$Enrolled)
## [1] 0.9152024
Week6 %>%
 ggplot(aes(x = sqrt(RVUs), y = sqrt(Enrolled))) +
 geom_point(colour = "orangered") 

cor(sqrt(Week6$RVUs), sqrt(Week6$Enrolled))
## [1] 0.9317273

*determine whether the relationship is statistically significant . data fit well to the line, then the relationship is likely to be a real effect. The goodness of fit can be quantified using the root mean squared error (RMSE) and R-squared metrics.. A rule of thumb for OLS linear regression is that at least 20 data points are required for a valid model.

Week6 %>%
 ggplot(aes(x = sqrt(RVUs), y = sqrt(Enrolled))) +
 geom_point(colour = "maroon") +
 geom_smooth(method = "lm", fill = NA)
## `geom_smooth()` using formula = 'y ~ x'

hist(x = Week6$RVUs, xlab = "", main = "Outpatients (RVU)")

hist(x=Week6$Enrolled,xlab = "",main = "Week6 Enrolled")

plot(x = Week6$RVUs, y = Week6$Enrolled, xlab = "RVUs", ylab = "Enrolled") 

univariate_reg  =  lm(Week6$Enrolled ~ Week6$RVUs)

summary(univariate_reg)
## 
## Call:
## lm(formula = Week6$Enrolled ~ Week6$RVUs)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -43488  -4115   -436   3998  41556 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 7.966e+03  6.016e+02   13.24   <2e-16 ***
## Week6$RVUs  3.063e-02  6.900e-04   44.39   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9183 on 382 degrees of freedom
## Multiple R-squared:  0.8376, Adjusted R-squared:  0.8372 
## F-statistic:  1970 on 1 and 382 DF,  p-value: < 2.2e-16
options(scipen = 999)      
summary(univariate_reg)
## 
## Call:
## lm(formula = Week6$Enrolled ~ Week6$RVUs)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -43488  -4115   -436   3998  41556 
## 
## Coefficients:
##               Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) 7966.06606  601.62884   13.24 <0.0000000000000002 ***
## Week6$RVUs     0.03063    0.00069   44.39 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9183 on 382 degrees of freedom
## Multiple R-squared:  0.8376, Adjusted R-squared:  0.8372 
## F-statistic:  1970 on 1 and 382 DF,  p-value: < 0.00000000000000022
?abline
## starting httpd help server ... done
abline(reg = univariate_reg, col="blue")

model<-lm(Enrolled ~ RVUs,data=Week6)
summary(model)
## 
## Call:
## lm(formula = Enrolled ~ RVUs, data = Week6)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -43488  -4115   -436   3998  41556 
## 
## Coefficients:
##               Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) 7966.06606  601.62884   13.24 <0.0000000000000002 ***
## RVUs           0.03063    0.00069   44.39 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9183 on 382 degrees of freedom
## Multiple R-squared:  0.8376, Adjusted R-squared:  0.8372 
## F-statistic:  1970 on 1 and 382 DF,  p-value: < 0.00000000000000022
lmodel <- lm(sqrt(RVUs) ~ sqrt(Enrolled), data = Week6)
lmodel
## 
## Call:
## lm(formula = sqrt(RVUs) ~ sqrt(Enrolled), data = Week6)
## 
## Coefficients:
##    (Intercept)  sqrt(Enrolled)  
##       -173.623           5.609
lmodel$coefficients
##    (Intercept) sqrt(Enrolled) 
##     -173.62320        5.60907
summary(lmodel)
## 
## Call:
## lm(formula = sqrt(RVUs) ~ sqrt(Enrolled), data = Week6)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -304.61  -90.46  -21.67   61.43  587.94 
## 
## Coefficients:
##                 Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)    -173.6232    17.5848  -9.873 <0.0000000000000002 ***
## sqrt(Enrolled)    5.6091     0.1119  50.145 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 139.2 on 382 degrees of freedom
## Multiple R-squared:  0.8681, Adjusted R-squared:  0.8678 
## F-statistic:  2514 on 1 and 382 DF,  p-value: < 0.00000000000000022
Fvalue<-fitted.values(model)
Fvalue
##          1          2          3          4          5          6          7 
##  20299.037  27512.801  21656.534   9293.288  56347.779  28578.093  81385.430 
##          8          9         10         11         12         13         14 
##  77079.371  55706.065  60432.247  43378.803  12902.783  24826.773  40151.004 
##         15         16         17         18         19         20         21 
##  38901.664  19360.097  22831.318  33648.393  39534.028  49538.954  15562.932 
##         22         23         24         25         26         27         28 
## 100366.996  58959.097  25130.849  30512.253  15756.691  15340.917  38407.750 
##         29         30         31         32         33         34         35 
##  90875.954  13606.456  58462.476  41722.299  86127.326  22924.506   9475.708 
##         36         37         38         39         40         41         42 
##  11908.745  10696.280  13303.759  12442.733  12202.951  15359.638  11768.608 
##         43         44         45         46         47         48         49 
##  11449.182  11433.566  12414.660  10774.737   9632.285  11663.191  12461.464 
##         50         51         52         53         54         55         56 
##  10536.035   9830.002  14667.742  15085.742  11378.338  12344.381  10185.608 
##         57         58         59         60         61         62         63 
##  11856.054  17864.989  11925.163   9490.516  10821.511  13641.773  12017.266 
##         64         65         66         67         68         69         70 
##  12370.804   9369.817  18896.817  12044.177  11998.776  11365.408  11326.721 
##         71         72         73         74         75         76         77 
##  11658.369  17787.815  17579.356  10166.664  65100.431  11581.768  32725.357 
##         78         79         80         81         82         83         84 
##  10293.464  11798.100  24830.964   8688.260   9442.921  26591.901  20428.438 
##         85         86         87         88         89         90         91 
##   9336.841  15808.758  15400.862  25005.189  13518.732  11418.132  29723.616 
##         92         93         94         95         96         97         98 
##  14074.659  15051.751  13645.764  34172.976   8947.857  11063.378  11288.562 
##         99        100        101        102        103        104        105 
##  28934.648   9679.920  30586.574  10745.213  23387.863  25869.906  29842.785 
##        106        107        108        109        110        111        112 
##  45101.191  52948.620  16563.277   9570.449  50463.443  17070.394  12701.553 
##        113        114        115        116        117        118        119 
##  17989.440  30458.782  39524.776  10726.632  13101.238  18287.621  22685.519 
##        120        121        122        123        124        125        126 
##  15424.403  15066.377  16511.415  13143.868  24057.184  13397.147  18612.798 
##        127        128        129        130        131        132        133 
## 113155.293  64448.081  22073.280  31348.014  22402.943   9374.135  63428.585 
##        134        135        136        137        138        139        140 
##  28816.648  96564.655  81169.711  57724.034  64220.528  61133.865  12565.325 
##        141        142        143        144        145        146        147 
##  25391.444  36910.562  43423.642  18321.139  23650.097  38265.590  40796.441 
##        148        149        150        151        152        153        154 
##  52491.414  16077.119 102710.888  59808.426  25968.707  30108.702  15965.474 
##        155        156        157        158        159        160        161 
##  15712.495  39060.111  89830.355  14507.809  64701.468  47479.137  88106.135 
##        162        163        164        165        166        167        168 
##  22637.563   9683.065  12069.797  10771.750  13257.077  12652.615  12483.142 
##        169        170        171        172        173        174        175 
##  15558.395  12078.008  11701.829  11717.657  13647.297  10869.023   9925.398 
##        176        177        178        179        180        181        182 
##  12144.270  12704.856  10726.668  10032.640  14919.386  15888.107  11908.945 
##        183        184        185        186        187        188        189 
##  13041.854   9877.778  12369.296  18507.325  12251.957   9664.931  11014.167 
##        190        191        192        193        194        195        196 
##  13872.215  12447.988  13120.114   9415.169  18980.802  11947.031  12138.407 
##        197        198        199        200        201        202        203 
##  11421.329  11501.838  11311.952  19028.733  18073.427   9935.841  57021.678 
##        204        205        206        207        208        209        210 
##  11856.424  34422.264  10479.194  12391.383  26967.462   8677.127   9758.215 
##        211        212        213        214        215        216        217 
##  27608.871  20689.480   9591.455  16018.685  15833.633  25077.609  13756.759 
##        218        219        220        221        222        223        224 
##  11006.157  30650.403  13960.421  15173.730  14490.006  35642.134   9025.342 
##        225        226        227        228        229        230        231 
##  10809.979  11587.674  30075.909   9823.161  34598.792  10947.329  23866.669 
##        232        233        234        235        236        237        238 
##  25268.971  30867.978  48750.693  53410.894  17195.778   9478.796  49573.926 
##        239        240        241        242        243        244        245 
##  17268.430  12681.636  18155.461  31967.521  40903.803  11027.591  13665.951 
##        246        247        248        249        250        251        252 
##  18796.124  24060.162  15459.029  14501.346  16985.190  13828.081  23913.582 
##        253        254        255        256        257        258        259 
##  13435.365  18679.186 117421.506  94415.471  22972.657  28964.998  22182.202 
##        260        261        262        263        264        265        266 
##   9576.219  53838.398  28515.038  90483.714  75643.278  48716.923  62557.694 
##        267        268        269        270        271        272        273 
##  58480.245  12461.923  24244.816  33630.871  37230.737  15484.424  21211.813 
##        274        275        276        277        278        279        280 
##  33693.809  38364.802  54500.202  15759.997  95574.561  52976.394  23096.028 
##        281        282        283        284        285        286        287 
##  29380.678  15948.365  14955.895  36478.903  80926.805  13483.284  62285.184 
##        288        289        290        291        292        293        294 
##  40463.268  78293.730  21705.705   9893.809  11899.872  10676.887  12801.719 
##        295        296        297        298        299        300        301 
##  12201.673  12970.823  15628.144  11716.231  11180.496  11339.109  13295.416 
##        302        303        304        305        306        307        308 
##  10688.989   9742.411  11841.604  12080.358  10924.135   9670.441  14677.198 
##        309        310        311        312        313        314        315 
##  15025.403  11470.329  12416.985  10044.266  11937.902  17628.613  12053.873 
##        316        317        318        319        320        321        322 
##   9319.623  10677.229  13179.673  11883.228  12378.974   9563.422  17779.833 
##        323        324        325        326        327        328        329 
##  11329.393  11576.989  11218.554  11272.407  10655.458  18121.963  17471.278 
##        330        331        332        333        334        335        336 
##  10258.826  51664.609  11896.184  32777.897   9961.086  12073.905  26283.051 
##        337        338        339        340        341        342        343 
##   8682.433   9415.281  27066.357  19778.209   9431.428  15432.199  14801.985 
##        344        345        346        347        348        349        350 
##  22656.773  12848.378  10986.352  28374.428  13372.533  14010.193  14311.356 
##        351        352        353        354        355        356        357 
##  31960.763   8853.355  10602.020  11383.804  27907.721   9598.589  31670.955 
##        358        359        360        361        362        363        364 
##  10847.532  22075.732  25861.820  28160.425  44952.921  52953.214  16320.859 
##        365        366        367        368        369        370        371 
##   9366.993  44315.109  16646.453  12174.736  16989.587  31209.695  38517.999 
##        372        373        374        375        376        377        378 
##  10605.790  13231.981  18189.886  22752.316  14884.683  13522.466  17515.996 
##        379        380        381        382        383        384 
##  13036.750  22301.170  12859.486  16748.451 109444.088  80997.587
Res<-lm(formula = model, data = Week6)
Res
## 
## Call:
## lm(formula = model, data = Week6)
## 
## Coefficients:
## (Intercept)         RVUs  
##  7966.06606      0.03063
# Residual Analysis
# plot(fitted(model),resid(model))

## plot(fitted(model),Res)
# abline(0,0)
qqnorm(resid(model))
qqline(resid(model))

par(mfrow=c(2,2))
plot(model)

Interpret the linear model - Expenditures~RVUs. Enrolled=7966.06606 + 0.03063.1∗RVUs

1 unit increase in RVUs is associated with 235.1 units increase in Expenditures.

plot(x = univariate_reg)

qqnorm(y=Week6$Enrolled)

qqnorm( y = log(Week6$Enrolled))

Transformed regression - ln(Enrolled)~RVU

hist(x = log(Week6$Enrolled),xlab = "", main = "Log Enrolled Details" )

hist(x=log(Week6$RVUs),  xlab = "", main = "Log Outpatient Details (RVU)")

plot(x = Week6$RVUs, y = log (Week6$Enrolled) , xlab = "RVUs", ylab = "Log of Enrolled") 

univariate_reg_transformedY  =  lm( formula = log(Week6$Enrolled) ~ Week6$RVUs)
?abline
abline(reg = univariate_reg_transformedY, col="blue")

summary(univariate_reg)
## 
## Call:
## lm(formula = Week6$Enrolled ~ Week6$RVUs)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -43488  -4115   -436   3998  41556 
## 
## Coefficients:
##               Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) 7966.06606  601.62884   13.24 <0.0000000000000002 ***
## Week6$RVUs     0.03063    0.00069   44.39 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9183 on 382 degrees of freedom
## Multiple R-squared:  0.8376, Adjusted R-squared:  0.8372 
## F-statistic:  1970 on 1 and 382 DF,  p-value: < 0.00000000000000022
summary(univariate_reg_transformedY)
## 
## Call:
## lm(formula = log(Week6$Enrolled) ~ Week6$RVUs)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.13708 -0.24629  0.08705  0.39173  0.98413 
## 
## Coefficients:
##                  Estimate    Std. Error t value            Pr(>|t|)    
## (Intercept) 9.18878091966 0.03716184238  247.26 <0.0000000000000002 ***
## Week6$RVUs  0.00000101667 0.00000004262   23.86 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5672 on 382 degrees of freedom
## Multiple R-squared:  0.5983, Adjusted R-squared:  0.5973 
## F-statistic: 569.1 on 1 and 382 DF,  p-value: < 0.00000000000000022
plot(univariate_reg_transformedY)

Constant variability The plot of residuals versus fitted observations shows that the variability of errors around the predicted values is slightly better.

Scale-Location plot - For OLS, the trend line is even and the residuals are uniformly scattered.

plot( univariate_reg , which = 3)               

plot( univariate_reg_transformedY , which = 3)         

hist(x = log(Week6$Enrolled), xlab = "", main = "Log Enrolled Details" )

hist(x = log(Week6$RVUs) ,        xlab = "", main = "Log Outpatient Details (RVU)")

log_log_reg =  lm( formula = log(Week6$Enrolled) ~ log(Week6$RVUs))
summary(log_log_reg)
## 
## Call:
## lm(formula = log(Week6$Enrolled) ~ log(Week6$RVUs))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.3934 -0.1784  0.0763  0.2389  0.5527 
## 
## Coefficients:
##                 Estimate Std. Error t value             Pr(>|t|)    
## (Intercept)       0.5550     0.1856    2.99              0.00297 ** 
## log(Week6$RVUs)   0.7310     0.0147   49.71 < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3275 on 382 degrees of freedom
## Multiple R-squared:  0.8661, Adjusted R-squared:  0.8658 
## F-statistic:  2472 on 1 and 382 DF,  p-value: < 0.00000000000000022
plot(log_log_reg)

 plot(x = Week6$RVUs, y = log (Week6$Enrolled) , xlab = "RVUs", ylab = "Log of Enrolled") 

Week6$RVUs2 <- Week6$RVUs^2

univariate_reg_transformedY2  =  lm( formula = log(Week6$Enrolled) ~ Week6$RVUs+ Week6$RVUs2)
# abline(reg = univariate_reg_transformedY2, col="blue")


# summary(univariate_reg)
# summary(univariate_reg_transformedY)
summary(univariate_reg_transformedY2)
## 
## Call:
## lm(formula = log(Week6$Enrolled) ~ Week6$RVUs + Week6$RVUs2)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.88905 -0.22091  0.09647  0.33631  0.91031 
## 
## Coefficients:
##                         Estimate           Std. Error t value
## (Intercept)  8.87524472896051719  0.03858990397976500  229.99
## Week6$RVUs   0.00000229359534853  0.00000010161348123   22.57
## Week6$RVUs2 -0.00000000000050606  0.00000000000003778  -13.39
##                        Pr(>|t|)    
## (Intercept) <0.0000000000000002 ***
## Week6$RVUs  <0.0000000000000002 ***
## Week6$RVUs2 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4683 on 381 degrees of freedom
## Multiple R-squared:  0.7269, Adjusted R-squared:  0.7255 
## F-statistic: 507.1 on 2 and 381 DF,  p-value: < 0.00000000000000022
plot(univariate_reg_transformedY2)

Some ways to fix heteroskedasticity - Transform the dependent variable. sqrt() will have larger penalty, but interpretation is not as easy/standard as when taking log.

Alternative models - sqrt(Enrolled)~RVU

plot(x = Week6$RVUs, y =  sqrt(Week6$Enrolled) , xlab = "RVUs", ylab = "Square Root of Enrolled") 

univariate_reg_transformedY_sqrt  =  lm( formula = sqrt(Week6$Enrolled) ~ Week6$RVUs)
?abline
abline(reg = univariate_reg_transformedY_sqrt, col="blue")

summary(univariate_reg)
## 
## Call:
## lm(formula = Week6$Enrolled ~ Week6$RVUs)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -43488  -4115   -436   3998  41556 
## 
## Coefficients:
##               Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) 7966.06606  601.62884   13.24 <0.0000000000000002 ***
## Week6$RVUs     0.03063    0.00069   44.39 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9183 on 382 degrees of freedom
## Multiple R-squared:  0.8376, Adjusted R-squared:  0.8372 
## F-statistic:  1970 on 1 and 382 DF,  p-value: < 0.00000000000000022
summary(univariate_reg_transformedY)
## 
## Call:
## lm(formula = log(Week6$Enrolled) ~ Week6$RVUs)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.13708 -0.24629  0.08705  0.39173  0.98413 
## 
## Coefficients:
##                  Estimate    Std. Error t value            Pr(>|t|)    
## (Intercept) 9.18878091966 0.03716184238  247.26 <0.0000000000000002 ***
## Week6$RVUs  0.00000101667 0.00000004262   23.86 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5672 on 382 degrees of freedom
## Multiple R-squared:  0.5983, Adjusted R-squared:  0.5973 
## F-statistic: 569.1 on 1 and 382 DF,  p-value: < 0.00000000000000022
summary(univariate_reg_transformedY_sqrt)
## 
## Call:
## lm(formula = sqrt(Week6$Enrolled) ~ Week6$RVUs)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -105.941  -18.065   -0.457   20.797   82.874 
## 
## Coefficients:
##                Estimate  Std. Error t value            Pr(>|t|)    
## (Intercept) 98.68414087  1.96206332   50.30 <0.0000000000000002 ***
## Week6$RVUs   0.00008252  0.00000225   36.67 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 29.95 on 382 degrees of freedom
## Multiple R-squared:  0.7788, Adjusted R-squared:  0.7782 
## F-statistic:  1345 on 1 and 382 DF,  p-value: < 0.00000000000000022
plot( univariate_reg_transformedY_sqrt)          # much better -