Homework
universities.df=read.csv(file="/Users/moneill2072/Desktop/MBA 264/Universities.csv",header = TRUE)
na.omit(universities.df[-c(1,2,3)])
pcs<-prcomp(na.omit(universities.df[-c(1,2,3)]),scale. = T)
summary(pcs)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6
## Standard deviation 2.2749 2.1426 1.09838 1.03247 0.97599 0.87284
## Proportion of Variance 0.3044 0.2700 0.07097 0.06271 0.05603 0.04481
## Cumulative Proportion 0.3044 0.5745 0.64542 0.70813 0.76416 0.80898
## PC7 PC8 PC9 PC10 PC11 PC12
## Standard deviation 0.80327 0.77279 0.70316 0.6622 0.62788 0.54973
## Proportion of Variance 0.03796 0.03513 0.02908 0.0258 0.02319 0.01778
## Cumulative Proportion 0.84693 0.88206 0.91115 0.9369 0.96013 0.97791
## PC13 PC14 PC15 PC16 PC17
## Standard deviation 0.4383 0.30389 0.20002 0.17428 0.14388
## Proportion of Variance 0.0113 0.00543 0.00235 0.00179 0.00122
## Cumulative Proportion 0.9892 0.99464 0.99700 0.99878 1.00000
#70% variance of model can be explain by the first four variable
#rotate data to see variance
pcs$rotation
## PC1 PC2 PC3 PC4
## X..appli..rec.d 0.07836149 -0.42016383 0.031982442 -0.07262064
## X..appl..accepted 0.02365875 -0.43447104 0.031422615 -0.11812757
## X..new.stud..enrolled -0.02880248 -0.44555599 0.038650539 0.03146642
## X..new.stud..from.top.10. 0.35402836 -0.09354696 0.120128679 0.37245697
## X..new.stud..from.top.25. 0.34049604 -0.11839579 0.142719780 0.38556529
## X..FT.undergrad -0.04958620 -0.44358316 0.004012153 0.05645942
## X..PT.undergrad -0.10637965 -0.28769996 -0.265769357 -0.05349515
## in.state.tuition 0.37938918 0.15024779 -0.084350215 -0.04106375
## out.of.state.tuition 0.40255490 0.04872785 -0.051577285 -0.07765821
## room 0.27316544 -0.05227149 -0.250577669 -0.45441559
## board 0.29043735 -0.01005076 -0.252096367 -0.30161976
## add..fees -0.01235062 -0.16949944 0.249746634 -0.44656205
## estim..book.costs 0.05730234 -0.05668860 -0.652240558 0.04435637
## estim..personal.. -0.14490773 -0.15683713 -0.403735455 0.40370868
## X..fac..w.PHD 0.25420056 -0.19685246 0.189366554 0.07460928
## stud..fac..ratio -0.27854201 -0.10103432 0.187598335 -0.10522171
## Graduation.rate 0.32530505 -0.02426412 0.181888434 0.01260031
## PC5 PC6 PC7
## X..appli..rec.d 0.016693535 -0.1123199317 0.26814545
## X..appl..accepted 0.089072664 -0.1143806355 0.26628527
## X..new.stud..enrolled 0.075981482 -0.0540786473 0.09887032
## X..new.stud..from.top.10. -0.162259553 0.0044452631 -0.10270892
## X..new.stud..from.top.25. -0.158186744 -0.0926362029 -0.13640855
## X..FT.undergrad 0.094780644 -0.0435042108 0.04315652
## X..PT.undergrad 0.343680612 0.1880406110 -0.50929697
## in.state.tuition 0.172639188 0.0005391433 0.12932831
## out.of.state.tuition 0.158498695 0.0444069008 0.07796549
## room 0.004482476 0.0150681763 0.12240242
## board 0.199066782 0.0384773272 -0.15213750
## add..fees -0.648919657 0.4184371378 -0.08235917
## estim..book.costs -0.518643773 -0.4211953235 -0.19072830
## estim..personal.. -0.103358179 0.4665984381 0.28927056
## X..fac..w.PHD 0.017277836 0.1806230379 -0.53334889
## stud..fac..ratio -0.002999589 -0.5221543003 -0.21151639
## Graduation.rate -0.109137248 -0.2153249506 0.20010479
## PC8 PC9 PC10
## X..appli..rec.d -0.093569576 0.039628249 -0.0873609767
## X..appl..accepted -0.080990581 0.022794614 0.0351970914
## X..new.stud..enrolled -0.058138458 0.096336432 0.0193532620
## X..new.stud..from.top.10. -0.112334415 0.028675676 -0.3266745490
## X..new.stud..from.top.25. -0.039926847 -0.006006804 -0.3141096995
## X..FT.undergrad -0.043463967 0.034857560 -0.0090574897
## X..PT.undergrad -0.122490191 0.172351373 0.2254594170
## in.state.tuition 0.009973765 0.092325279 0.1039045816
## out.of.state.tuition -0.010687726 0.044614794 0.1515097231
## room -0.091328610 -0.680594900 -0.1801388815
## board 0.466412444 0.421338868 -0.4194338097
## add..fees 0.048173899 0.205131618 -0.0133332674
## estim..book.costs -0.130177355 0.078975001 0.1708416857
## estim..personal.. 0.505882625 -0.194257614 0.0001275728
## X..fac..w.PHD 0.145008577 -0.404836795 0.2677677323
## stud..fac..ratio 0.525626694 -0.207194049 -0.1817202902
## Graduation.rate 0.389369809 0.112811016 0.5985373278
## PC11 PC12 PC13
## X..appli..rec.d -0.07302129 0.009995194 -0.602995698
## X..appl..accepted -0.16604598 0.062100043 -0.251256951
## X..new.stud..enrolled -0.07261324 -0.013719151 0.486305832
## X..new.stud..from.top.10. 0.20927469 0.043488661 0.003825278
## X..new.stud..from.top.25. 0.23435483 -0.010822686 -0.037524140
## X..FT.undergrad -0.06139242 -0.050778815 0.512672958
## X..PT.undergrad 0.53164209 0.107998565 -0.168015207
## in.state.tuition -0.04440606 0.497755070 0.066562948
## out.of.state.tuition -0.09928339 0.507936491 0.101072681
## room 0.30805960 -0.153113035 0.120440397
## board -0.18150560 -0.302579083 0.004475324
## add..fees 0.09838275 0.214784271 0.043949536
## estim..book.costs -0.17222024 0.033708549 0.006942686
## estim..personal.. 0.03871053 0.133196901 -0.051415815
## X..fac..w.PHD -0.50274813 -0.096447473 -0.101834652
## stud..fac..ratio 0.13610711 0.416235685 -0.005231965
## Graduation.rate 0.35341352 -0.333591631 0.009703360
## PC14 PC15 PC16
## X..appli..rec.d -0.198790352 -0.346774483 -0.344637255
## X..appl..accepted 0.240231762 0.452346721 0.429829958
## X..new.stud..enrolled -0.059300896 0.322662732 -0.010968884
## X..new.stud..from.top.10. -0.646398528 0.185718530 0.168396082
## X..new.stud..from.top.25. 0.685605333 -0.088571253 -0.055470028
## X..FT.undergrad -0.012861624 -0.441354147 -0.217175701
## X..PT.undergrad 0.006458524 0.036555746 0.009389704
## in.state.tuition 0.041637622 0.355982621 -0.592823841
## out.of.state.tuition -0.006316571 -0.449517115 0.507583803
## room -0.004845949 0.027486605 -0.009709587
## board -0.001880362 0.011573512 0.033038619
## add..fees 0.039395629 0.006339905 -0.039114859
## estim..book.costs -0.009861301 0.004616935 0.003224813
## estim..personal.. 0.013720726 0.012993452 0.017390432
## X..fac..w.PHD -0.027888817 0.050578161 -0.073086168
## stud..fac..ratio -0.065855411 0.006339521 0.010917787
## Graduation.rate -0.049079394 -0.006724304 0.009623027
## PC17
## X..appli..rec.d 0.2463541431
## X..appl..accepted -0.3922380257
## X..new.stud..enrolled 0.6457209153
## X..new.stud..from.top.10. -0.1712358332
## X..new.stud..from.top.25. 0.1052833181
## X..FT.undergrad -0.5199437282
## X..PT.undergrad -0.0038561950
## in.state.tuition -0.1570930221
## out.of.state.tuition 0.1755921232
## room 0.0203055365
## board -0.0049991388
## add..fees -0.0302372161
## estim..book.costs -0.0003840709
## estim..personal.. 0.0122510528
## X..fac..w.PHD 0.0097574751
## stud..fac..ratio 0.0035114776
## Graduation.rate -0.0249127915
#center data
pcs$center
## X..appli..rec.d X..appl..accepted
## 3147.30361 2062.95541
## X..new.stud..enrolled X..new.stud..from.top.10.
## 780.70488 28.01274
## X..new.stud..from.top.25. X..FT.undergrad
## 55.65180 3562.93843
## X..PT.undergrad in.state.tuition
## 797.45435 9406.63482
## out.of.state.tuition room
## 10575.16136 2221.10828
## board add..fees
## 2121.94055 379.02123
## estim..book.costs estim..personal..
## 548.78344 1311.94055
## X..fac..w.PHD stud..fac..ratio
## 73.20807 13.96263
## Graduation.rate
## 65.56263
#round data 2 digits
round(var(pcs$x), digits = 2)
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11 PC12 PC13 PC14
## PC1 5.18 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC2 0.00 4.59 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC3 0.00 0.00 1.21 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC4 0.00 0.00 0.00 1.07 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC5 0.00 0.00 0.00 0.00 0.95 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC6 0.00 0.00 0.00 0.00 0.00 0.76 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC7 0.00 0.00 0.00 0.00 0.00 0.00 0.65 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC8 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.6 0.00 0.00 0.00 0.0 0.00 0.00
## PC9 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.49 0.00 0.00 0.0 0.00 0.00
## PC10 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.44 0.00 0.0 0.00 0.00
## PC11 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.39 0.0 0.00 0.00
## PC12 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.3 0.00 0.00
## PC13 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.19 0.00
## PC14 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.09
## PC15 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC16 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC17 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0 0.00 0.00 0.00 0.0 0.00 0.00
## PC15 PC16 PC17
## PC1 0.00 0.00 0.00
## PC2 0.00 0.00 0.00
## PC3 0.00 0.00 0.00
## PC4 0.00 0.00 0.00
## PC5 0.00 0.00 0.00
## PC6 0.00 0.00 0.00
## PC7 0.00 0.00 0.00
## PC8 0.00 0.00 0.00
## PC9 0.00 0.00 0.00
## PC10 0.00 0.00 0.00
## PC11 0.00 0.00 0.00
## PC12 0.00 0.00 0.00
## PC13 0.00 0.00 0.00
## PC14 0.00 0.00 0.00
## PC15 0.04 0.00 0.00
## PC16 0.00 0.03 0.00
## PC17 0.00 0.00 0.02