mydata <- read.csv("~/Intro to Data Science/Finals/week 6 data-1.csv")
mydata
## 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(mydata)
## '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 : num 25294 42186 23772 2085 67258 ...
## $ 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 ...
head(mydata)
## 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
mean_exp <- mean(mydata$Expenditures)
sd_exp <- sd(mydata$Expenditures)
mydata_exp_out <- (mydata$Expenditures - mean_exp)/ sd_exp
sum(abs((mydata_exp_out)>3))
## [1] 13
#Outliers absent
mean_rvus <- mean(mydata$RVUs)
sd_rvus <- sd(mydata$RVUs)
mydata_rvus_out <- (mydata$RVUs - mean_rvus)/ sd_rvus
sum(abs((mydata_rvus_out)>3))
## [1] 12
hist(x = mydata$Expenditures, main = "Expenditure")

hist(x = mydata$RVUs, main = "RVU")

cor(mydata)
## 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
plot(x = mydata$RVUs, y = mydata$Expenditures, xlab = "RVUS", ylab = "Expenditures")

#Linear regression
reg <- lm(mydata$Expenditures ~ mydata$RVUs)
summary(reg)
##
## Call:
## lm(formula = mydata$Expenditures ~ mydata$RVUs)
##
## Residuals:
## Min 1Q Median 3Q Max
## -185723026 -14097620 2813431 11919781 642218316
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.785e+06 4.413e+06 -0.858 0.392
## mydata$RVUs 2.351e+02 5.061e+00 46.449 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 67350000 on 382 degrees of freedom
## Multiple R-squared: 0.8496, Adjusted R-squared: 0.8492
## F-statistic: 2157 on 1 and 382 DF, p-value: < 2.2e-16
options(scipen = 999 )
summary(reg)
##
## Call:
## lm(formula = mydata$Expenditures ~ mydata$RVUs)
##
## Residuals:
## Min 1Q Median 3Q Max
## -185723026 -14097620 2813431 11919781 642218316
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3785072.158 4412905.480 -0.858 0.392
## mydata$RVUs 235.072 5.061 46.449 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 67350000 on 382 degrees of freedom
## Multiple R-squared: 0.8496, Adjusted R-squared: 0.8492
## F-statistic: 2157 on 1 and 382 DF, p-value: < 0.00000000000000022
#1 unit increase in RVUs will enhance the expenditure by 235.07
#When RVU is 0, expenditure is expected to be -3785000 (unrealistic)
#T value = 46.449, and p value = 2e-16, suggesting a positive correlation.
#The model explained 84.96% variance in Expenditures
plot(reg)




#The Gauss Markow Assumptions did not hold because the regression is only validating two out of the 4 assumptions. We saw how the residuals does not fit well in linear line and that we have some extreme values at the distance.
#Transformed Linear model
reg2 <- lm(log(mydata$Expenditures) ~ mydata$RVUs)
summary(reg2)
##
## Call:
## lm(formula = log(mydata$Expenditures) ~ mydata$RVUs)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.59439 -0.29504 0.06135 0.35333 1.20871
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.29584389074 0.03325414655 520.11 <0.0000000000000002 ***
## mydata$RVUs 0.00000134911 0.00000003814 35.38 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5076 on 382 degrees of freedom
## Multiple R-squared: 0.7661, Adjusted R-squared: 0.7655
## F-statistic: 1251 on 1 and 382 DF, p-value: < 0.00000000000000022
plot(x = mydata$RVUs, y = log (mydata$Expenditures), xlab = "RVUS", ylab = "log of Expenditures")

plot(reg2)




1.
## [1] 1
#The model explained 76.61% varience in Expenditure, which is lower than the linear model.
#A 1 unit increace in RVUS causes a 0.000134911 % increase in expenditure. Using log-level.
2.
## [1] 2
log_log_reg <- lm(formula = log(mydata$Expenditures) ~ log(mydata$RVUs))
summary(log_log_reg)
##
## Call:
## lm(formula = log(mydata$Expenditures) ~ log(mydata$RVUs))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.74657 -0.19864 -0.02431 0.18642 0.93551
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.91487 0.16621 41.60 <0.0000000000000002 ***
## log(mydata$RVUs) 0.88444 0.01317 67.17 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2932 on 382 degrees of freedom
## Multiple R-squared: 0.9219, Adjusted R-squared: 0.9217
## F-statistic: 4512 on 1 and 382 DF, p-value: < 0.00000000000000022
plot(log_log_reg)



