In [1]:
:ext QuasiQuotes
import qualified H.Prelude as H
H.initialize H.defaultConfig
[r| require("ggplot2") |]
Loading required package: ggplot2
0x00007f393400a200

Small Dataset for Ringo

Haskell / R Logistics First

Testing R Globals .. Must use <<- for assignment

In [2]:
[rprint|y<<-3; 0|]
[1] 0
In [3]:
[rprint| y|]
[1] 3

This works ! The '0' is so the value of 'y' doesn't print as this may be problematic for large printouts.

First let's test getting R results into Haskell

In [4]:
get_normals :: Double -> H.R s [Double]
get_normals n = do
   H.dynSEXP <$> [r| rnorm(n_hs) |]
result <- H.runRegion $ get_normals 4
In [5]:
result
[-0.3465267137150862,-0.5142776987826775,-8.188609132274059e-2,-1.6941856238645805]

Now do an R function ...

In [6]:
[r| fahrenheit_to_celsius <<- function(temp_F) {
   temp_C <- (temp_F - 32) * 5 / 9
   return(temp_C) } |]
0x00007f39361d62d0

And test it ..

In [7]:
[rprint| fahrenheit_to_celsius(98.6) |]
[1] 37

Ringo Data Exploration

Now let's read in the dataset ..

In [8]:
[rprint| dset_small <<- read.table ("TM30-CES99.csv", header=TRUE, sep=",");
     |]
        fp0      fp1      fp2      fp3      fp4      fp5      fp6      fp7
1  16.93446 21.83035 24.64847 17.22998 29.86766 23.29893 36.21929 52.72085
2   9.71750  6.75260  8.94604  9.72321  8.65098  7.36825 20.13315 15.49065
3   1.82220  1.90120  2.23659  1.86512  2.74993  2.33337  3.69341  4.52031
4  10.27356 10.89583 11.58620 10.27655 13.33066  9.34798 22.24663 26.38608
5   6.50525  3.35570  3.65851  6.49614  4.06732  2.81869 12.89792  7.91331
6   4.81356  5.07652  5.12844  4.86420  6.63191  4.68535 10.45052 12.43096
7   4.81958  2.29321  2.27399  4.85271  3.07316  2.19343  9.34648  5.46505
8   4.32009  2.42861  2.34503  4.36334  3.32662  2.36727  8.37438  5.86644
9   1.23086  1.89535  1.98516  1.28237  2.82172  2.17618  2.64693  4.67328
10 15.14046  9.88862  7.44843 15.26593 12.54852  7.26781 32.78493 24.82972
11  8.07314  4.46510  2.96452  8.08658  5.13241  2.45169 17.63627 11.25718
12 10.67617  5.76283  3.61085 10.69819  6.62404  3.00086 22.91012 14.59226
13  3.93965  3.14704  2.07960  4.02599  4.46146  2.49034  8.28258  8.14300
14 10.38030 15.54128 14.66684 10.69132 21.65780 15.18408 22.61839 38.80433
15 10.53654 12.86093 11.09494 10.87205 18.38926 12.55283 22.63439 32.41340
16  4.56912  4.06842  2.41488  4.67106  5.55342  2.96059  9.58922 10.59975
17  4.50166  4.41680  2.58920  4.58650  5.74310  2.94946 10.00860 11.51452
18  5.96082  6.84532  4.97209  6.13688  9.58242  5.82112 12.87980 17.59720
19 10.65309 10.92272  5.46303 10.81852 13.62145  5.79075 23.89674 28.88070
20 10.74576  7.89572  2.26680 11.09906 11.92522  5.56707 22.85096 21.54981
21 17.48679 18.32550  7.88355 17.76423 22.58715  8.72068 39.08793 48.93344
22 14.23793 13.50051  5.10278 14.51035 17.14285  6.54947 31.60507 36.29289
23 17.97818 27.95465 22.68425 18.58373 38.61151 24.61653 39.63648 71.25858
24 18.08998 24.40519 12.89595 18.55580 31.69777 14.61538 40.62987 64.72082
25 10.17957 11.30726  2.80393 10.30906 13.09492  3.05880 23.02685 30.98586
26 18.10170 22.93871  9.61625 18.62984 30.12505 12.54139 40.69967 61.78557
27  9.69842 15.19259 10.91308 10.06747 21.01484 12.46806 21.52391 39.29304
28  2.55392  3.97963  2.13530  2.63373  5.22834  2.37541  5.75177 10.58930
29 15.77066 22.07239  8.81977 16.43235 30.29252 13.55699 35.57083 59.73071
30  7.13888 10.54111  6.57082  7.50332 15.26203  9.22958 15.90374 27.56354
31 16.42141 23.77060  9.68925 17.16455 33.10886 14.98262 37.12836 64.41244
32 10.22461 15.04621  4.29580 10.62375 19.92908  6.98502 23.39574 41.47607
33 16.70824 26.09087 16.29274 17.54961 37.49323 22.16829 37.32558 68.37978
34  6.11045  9.65346  2.84816  6.32156 12.37321  3.97112 14.08732 26.58623
35  2.46234  4.21663  2.26241  2.55458  5.63096  2.65664  5.60031 11.23577
36 12.29088 20.69682 19.43698 12.80945 29.55114 21.33943 26.87143 51.72485
37  3.01211  5.72270  2.64111  3.11145  7.23717  2.96069  6.98487 15.37723
38 14.59328 24.45319 17.44674 15.39430 35.51175 22.72745 32.52495 63.25155
39  1.73355  2.98087  2.35796  1.82515  4.40450  2.83232  3.80092  7.67867
40  3.74154  6.49165  4.14865  3.96702  9.70059  5.48214  8.23770 17.17294
41 15.28470 26.93019 23.44943 16.05305 39.24883 27.42479 33.59318 68.19018
42  6.36831 14.91374  4.57303  6.76129 19.95334  6.67078 15.01977 41.36297
43  7.56035 16.64721  4.96016  8.16933 24.04664  9.45195 17.74301 46.35448
44  1.11652  1.96141  1.93315  1.15905  2.78881  2.02286  2.42584  4.88213
45  4.12418 10.29640  4.35809  4.47333 14.83433  6.67907  9.66861 28.16342
46  6.21740 13.47919  7.81427  6.68611 19.81780 11.10570 14.34479 35.88226
47  7.62138 14.89716 10.85106  8.21673 22.97589 15.36496 17.02790 38.70135
48  8.64597 20.87374 13.42909  9.35527 30.47052 18.31083 20.15250 54.90192
49  2.40720  6.10808  3.19423  2.66117  9.36631  5.17395  5.57873 16.47518
50  3.71795  9.16117  6.67087  4.05870 14.04188  8.84982  8.29032 23.97511
51  4.65815 10.52026  8.29948  5.05073 16.26186 10.75429 10.27012 27.26167
52  1.78762  5.21583  3.30523  2.00983  8.25900  4.76864  4.03567 13.95450
53  2.11104  8.70247  5.79357  2.51127 14.06491  8.70974  4.87691 23.17145
54 13.13078 28.60071 27.72756 13.85300 41.41735 30.39966 28.94343 71.50135
55 11.56602 26.13256 25.61418 12.29555 38.57995 28.80402 25.34527 65.29417
56  5.78937 19.38666 17.44709  6.53548 30.44369 22.42817 12.97572 49.38347
57  3.04137 12.29324 10.77744  3.58002 19.87243 14.71316  6.85669 31.49506
58  2.48101 10.66965  9.91434  2.94934 17.34567 13.36017  5.55402 27.09700
59 13.32121 28.67617 28.71478 14.04093 41.93599 31.02120 29.02093 71.50226
60 15.18356 28.29432 29.55453 15.83547 40.85222 31.16231 32.86188 69.79881
61  9.64691 20.69085 21.77536 10.17461 30.51528 23.30491 20.80351 51.19075
62  7.21333 13.59770 14.63786  7.59798 20.24820 16.36847 15.61616 33.30597
63  1.66612  2.85366  3.09623  1.76517  4.45347  3.69673  3.68373  6.99204
64  3.50969 12.90181 15.47988  4.03049 21.19554 18.74998  7.40459 31.33221
65  1.71806  4.75515  5.71505  1.88914  7.57853  6.79462  3.85896 11.47625
66  1.94454  6.99292  9.50698  2.28165 12.18140 11.93080  3.98342 16.52079
67  2.29039  8.19904 11.49397  2.66704 14.15951 14.07898  4.66159 19.21817
68  5.74894 14.01336 17.75993  6.13766 21.55125 18.83807 12.02100 33.54719
69  4.23989  8.32106 10.05762  4.46615 12.65751 10.65427  8.89059 20.07318
70  7.85308 19.57259 27.63001  8.33311 29.93370 28.29625 16.19093 45.62399
71  1.44385  3.93192  6.76825  1.59168  6.59319  7.53175  2.92092  8.61707
72 10.29529 19.47663 21.94782 10.71590 28.18959 22.54836 22.07611 47.42311
73  4.08613 12.61514 21.65101  4.34713 19.51140 20.96031  7.92082 27.92961
74  1.05657  1.94688  2.19762  1.10363  2.84419  2.33151  2.28590  4.72671
75  1.32742  3.42107  6.39434  1.43322  5.58833  6.77366  2.65511  7.25951
76  3.15752  8.37302 17.89773  3.28090 13.18189 16.54484  5.77508 17.10295
77  2.66257  6.31595 11.06999  2.77780  9.65197 10.59591  5.14857 13.82609
78  2.62405  7.01307 15.86065  2.65566 10.42251 13.67109  4.76071 13.92603
79  9.40936 18.35800 25.54767  9.75075 27.02833 25.02648 19.45821 42.77763
80  7.44751 13.71660 22.07072  7.63737 20.05151 20.61178 15.13156 30.68639
81  3.13645  5.72870 12.33799  3.15178  8.46899 10.60961  5.91423 11.61511
82 15.31837 26.90936 31.43030 15.81328 38.31887 31.17818 32.79815 64.96565
83  9.58075 16.81547 22.93924  9.79393 23.72060 21.27577 20.20463 39.28528
84  1.21318  1.89610  2.43841  1.25931  2.86573  2.49594  2.52281  4.50312
85  2.66332  4.35487  6.51440  2.74142  6.38662  6.30782  5.44838  9.90482
86  8.23830 12.98294 21.39851  8.35806 18.65880 19.15726 16.17286 28.83776
87  2.99605  3.91706  8.52216  3.00112  5.68335  7.22336  5.80202  7.83504
88  7.98354 10.14386 17.22321  8.05557 14.47937 15.23070 16.15231 22.23402
89  2.70469  3.27622  6.43853  2.68867  4.41702  5.20690  5.38358  6.79188
90  3.88755  4.18561  8.19657  3.85816  5.67290  6.52118  7.78031  8.71751
91 12.66638 21.02476 23.34780 13.12456 30.15407 24.08405 27.08836 51.12651
92  6.18468  8.04191 11.48042  6.33353 11.77597 11.18272 12.32588 18.45953
93  8.88086 12.48377 16.04336  9.09971 17.83021 15.71257 18.40855 29.38006
94  3.19080  3.12063  5.40232  3.20115  4.29906  4.62508  6.22070  6.72257
95 10.60932 13.34962 17.87972 10.83934 19.17456 17.31865 21.67853 31.08842
96 13.60475 17.74116 22.41657 13.86454 24.88439 21.30922 28.31591 41.89375
97  5.62470  5.23930  8.24079  5.59490  6.58362  6.49832 12.14569 11.57997
98 10.23997  8.07198 12.10090 10.22089 10.37802  9.72672 21.58271 18.05653
99  7.19786  4.62962  7.22679  7.20925  6.26696  6.11799 14.17011 10.17260
        fp8      fp9     fp10     fp11     fp12     fp13     fp14        X
1  19.77298 40.67645 31.58421 13.00247 33.25382 21.61335 12.59739 74.79439
2   6.40574 23.56117 10.53724  4.50234 21.04046  7.10553  4.40021 38.52033
3   1.86855  4.20295  2.66326  1.22231  3.99320  1.91353  1.19554  7.46693
4   8.49214 25.39108 17.36641  5.89798 20.34604 11.08186  5.67913 44.98300
5   2.62359 15.16506  5.53448  1.85095 15.51463  3.80147  1.83041 24.73551
6   4.07866 11.92496  7.91610  2.71582 10.00436  5.21590  2.62861 21.21013
7   1.88668 11.06847  3.55848  1.25464 11.57119  2.64782  1.24493 17.19270
8   2.01483  9.83254  3.65003  1.31252 10.58263  2.72862  1.30317 15.99582
9   1.77647  2.91893  2.59480  1.10042  2.39165  1.86400  1.06759  5.46066
10  6.36217 38.42148 17.49624  4.18790 32.18079 11.09717  4.02852 58.97771
11  2.29394 20.73279  8.91679  1.63102 17.30683  5.21468  1.55877 31.84756
12  2.90055 27.04262 11.08313  2.03025 23.22584  6.76013  1.94199 40.94397
13  2.17543  9.62121  4.84066  1.26189  8.69276  3.44460  1.22105 15.01674
14 12.86743 25.03039 22.40864  8.09357 19.97354 15.46579  7.80661 46.69229
15 10.41536 25.54703 18.81950  6.39933 21.59201 13.14577  6.18516 44.28297
16  2.56341 11.01666  6.42485  1.51373 10.26820  4.41657  1.46127 18.25079
17  2.55613 11.45119  7.52584  1.57549  9.46782  4.76307  1.50087 19.40059
18  4.92567 14.59200 10.38428  2.96115 12.38591  7.13224  2.84877 24.80983
19  5.49965 27.22283 18.94153  3.35345 21.38428 11.76795  3.14486 45.14168
20  4.18722 26.53832 13.24579  1.97384 24.04330  9.03680  1.87932 40.48431
21  8.41761 44.54439 31.53165  5.03396 35.53942 19.81076  4.68759 74.04219
22  6.14013 36.22237 23.41006  3.51333 29.59453 14.83664  3.27612 58.37530
23 21.02718 43.67427 41.22971 12.93157 34.54648 28.09588 12.41188 81.57757
24 13.50743 45.38255 39.06833  7.94016 35.57141 25.50076  7.47762 79.84880
25  3.66169 26.15120 19.85259  2.07894 20.63220 12.34303  1.85842 43.70925
26 11.61387 45.66655 37.26599  6.47265 36.28953 24.35523  6.05475 77.80924
27 10.76507 23.68555 22.53360  6.46956 18.72211 15.39970  6.19302 43.25703
28  2.28612  6.32375  6.07701  1.31309  4.93969  4.10489  1.24007 11.40143
29 11.83514 39.53590 34.82982  6.35258 31.53188 23.27632  5.96405 68.01383
30  7.44321 17.60451 15.81376  4.30706 14.12970 10.84148  4.12542 30.92300
31 13.06474 41.11531 37.14774  6.91631 32.62511 24.98347  6.49935 71.03407
32  6.70416 25.88154 24.17530  3.38327 20.64677 15.98783  3.11855 45.49717
33 18.08979 41.06560 38.97847 10.39363 32.61630 26.70225  9.93182 73.99310
34  4.12977 15.48127 15.40762  2.12732 11.83657 10.17669  1.94652 27.39550
35  2.45167  6.10642  6.42998  1.39796  4.65098  4.32023  1.31779 11.37918
36 17.64365 29.36763 29.26823 11.04147 23.28396 20.42179 10.66436 55.90647
37  2.90250  7.57157  8.77947  1.67332  5.58376  5.86700  1.56077 14.67462
38 18.41740 35.53490 35.60761 10.86749 28.05431 24.68561 10.43499 65.21774
39  2.38208  4.13083  4.16193  1.38703  3.35389  2.98066  1.33603  7.74958
40  4.75058  8.92639  9.03179  2.59117  7.40144  6.58441  2.48661 16.26917
41 22.38168 36.46551 38.00352 13.56801 29.06279 26.67300 13.08541 70.72161
42  7.11814 15.65938 21.91530  3.46404 11.77235 15.32916  3.19875 30.69386
43  8.72322 18.60214 24.57858  4.02235 13.91427 17.17786  3.72963 34.89121
44  1.70026  2.63535  2.73508  1.06330  2.09193  1.91972  1.02697  5.22320
45  6.07988  9.94467 14.76394  3.06134  7.38253 10.43340  2.87875 20.07576
46  9.22167 15.12861 19.43523  5.03611 11.17544 13.55732  4.79020 29.71257
47 11.99657 18.20858 20.79837  6.79047 14.73632 14.88220  6.54187 35.66688
48 15.02340 20.97673 29.76134  8.54295 14.81010 20.74382  8.15166 42.81519
49  4.22283  5.72109  8.49804  2.17366  4.31635  6.12759  2.06811 11.66287
50  7.34166  8.52927 12.17626  4.08143  6.78980  9.01856  3.92677 17.83831
51  8.83664 10.72785 13.88597  4.98914  8.68462 10.34429  4.81414 21.78036
52  4.08592  3.99061  6.69951  2.11672  3.19615  5.14373  2.03396  8.55273
53  7.14734  4.40122 10.92141  3.73396  3.27776  8.44388  3.59086 11.38348
54 25.10627 30.52788 39.08885 15.53207 23.18093 27.65324 14.99415 65.10500
55 23.56435 26.56488 35.00820 14.45474 20.46988 25.18688 13.97453 57.18547
56 17.71471 12.52139 24.83085 10.28511  9.05719 18.49424  9.93679 31.55845
57 11.46058  6.24676 15.30975  6.51622  4.39948 11.67515  6.30093 17.12736
58 10.29281  4.95522 13.16479  5.92575  3.50050 10.06132  5.73826 14.61283
59 25.81611 30.64610 38.44329 15.88761 23.77860 27.65063 15.35698 65.20317
60 25.81700 35.44031 38.63164 16.22441 28.04648 27.41733 15.70145 71.94590
61 19.38222 21.96002 27.23804 11.99902 17.37538 19.85310 11.62417 46.74406
62 13.05554 16.81330 18.37923  8.19602 13.37020 13.13257  7.95069 34.24994
63  2.84236  4.01507  3.92299  1.74728  3.03096  2.77583  1.69520  7.67745
64 14.40637  6.90736 15.22329  8.73749  5.22905 11.88719  8.51092 19.72174
65  5.11390  3.90986  6.15613  3.17543  2.53212  4.43569  3.08230  9.24455
66  8.80081  3.72374  7.89684  5.37650  2.91984  6.34189  5.25750 10.65840
67 10.43051  4.36535  9.23959  6.43837  3.41276  7.40228  6.29709 12.67030
68 15.24850 12.40206 17.22046  9.60821  9.98605 13.05513  9.35834 28.75117
69  8.71866  9.50813 10.49695  5.47199  7.91515  7.90279  5.32861 19.71766
70 22.67579 16.65802 23.72833 14.66859 13.24568 17.93150 14.30769 40.47556
71  5.59746  2.98037  4.34337  3.67787  2.31208  3.47454  3.60843  7.52627
72 18.64287 23.76712 26.16254 11.86181 18.86876 18.69281 11.49931 49.19670
73 16.79060  7.76467 13.98832 11.19575  6.23635 11.06227 10.96120 22.86588
74  1.88713  2.46671  2.65244  1.20561  1.95474  1.87401  1.16999  5.12217
75  5.05184  2.74085  3.81794  3.40832  2.10908  2.98094  3.34487  7.06824
76 13.10848  5.87709  8.51080  8.99455  5.07817  7.05304  8.83937 17.14648
77  8.45546  5.32643  7.17062  5.69833  4.87288  5.59870  5.58847 14.04875
78 11.09496  4.85394  7.22965  7.84940  4.03913  5.81839  7.71205 14.68724
79 20.37601 20.84485 23.28879 13.35955 17.52088 17.11685 13.02661 46.53890
80 16.71477 16.36694 17.02046 11.30418 13.73406 12.54427 11.04923 36.59928
81  8.63507  6.40573  6.29361  6.04468  6.19418  4.95050  5.94620 16.30352
82 25.92476 35.67082 36.60790 16.75488 28.43911 25.85909 16.24917 72.82026
83 17.75574 21.99385 22.32366 11.82384 17.62216 15.84064 11.50188 46.62120
84  2.04154  2.78136  2.42632  1.30230  2.37035  1.81701  1.27024  5.35582
85  5.07750  5.98547  5.54379  3.41286  5.25706  4.07387  3.33809 12.50597
86 15.84263 17.69908 16.02449 10.78059 16.54082 11.95204 10.55892 38.64751
87  5.90071  6.58044  4.42862  4.18563  5.94155  3.47096  4.11616 13.38467
88 12.53209 18.24687 12.96206  8.60469 15.77965  9.48543  8.41994 35.70731
89  4.37033  6.10616  4.15001  3.14385  5.50179  2.99934  3.08577 12.48032
90  5.53218  8.92207  5.33795  3.93515  7.80975  3.87855  3.85727 17.09722
91 19.83488 29.65096 28.84175 12.74572 24.10159 20.40630 12.36330 57.88075
92  9.06705 13.77998 10.38792  6.04432 13.17639  7.71483  5.92274 26.79372
93 12.86554 20.48988 16.89054  8.50873 17.93910 12.07147  8.29510 39.75987
94  3.85009  7.12374  4.04766  2.71412  7.28802  3.00609  2.67541 13.77845
95 14.17512 24.39299 17.89626  9.42485 21.99622 12.96653  9.20687 45.69182
96 17.72578 31.75535 24.52534 11.75789 27.36165 17.30096 11.44583 59.77789
97  5.54830 13.93535  8.28984  4.03528 10.89796  5.16297  3.92782 24.53674
98  8.39563 25.14438 12.26557  5.97256 21.29232  8.20805  5.83274 42.13247
99  5.17899 16.66185  6.52660  3.61599 16.36939  4.80924  3.56273 27.64095
          Y        Z
1  64.76476 64.86676
2  25.72322 23.87620
3   5.98007  5.46440
4  35.77950 30.88332
5  15.04304 10.11276
6  16.92086 13.39176
7  10.48018  5.87402
8  10.20422  6.08117
9   5.29031  5.13090
10 41.78958 19.49134
11 21.37749  7.68647
12 27.32653  9.21260
13 11.67658  5.17635
14 44.62156 38.00108
15 39.84147 27.74810
16 14.66141  5.91684
17 16.05074  6.46905
18 22.09440 12.30144
19 38.90753 13.47221
20 32.19046  5.95869
21 64.70004 19.17557
22 49.71560 11.84811
23 80.89580 57.70853
24 77.09388 31.90022
25 39.64856  6.10069
26 74.80645 22.76478
27 44.18661 25.89331
28 11.78505  5.17782
29 69.41577 20.08469
30 31.70204 15.31290
31 73.87139 22.18297
32 47.41511  9.35038
33 77.12345 40.26675
34 29.47924  6.23760
35 12.24815  5.60517
36 57.20849 46.59135
37 16.31402  6.24501
38 69.79608 40.83259
39  8.26713  5.94869
40 18.10959 10.17962
41 74.23116 59.70119
42 40.20317  9.67958
43 46.05331 10.95033
44  5.31239  5.01518
45 27.20719 10.15178
46 36.53393 19.42160
47 40.78073 27.37915
48 54.73281 31.82469
49 15.93685  7.92945
50 23.11876 16.57185
51 26.86146 20.76343
52 12.68209  8.07299
53 19.90759 14.33877
54 73.23322 70.74536
55 65.84014 65.10833
56 45.20069 44.70510
57 27.63511 27.27705
58 23.65870 25.36933
59 72.80504 74.40146
60 74.61815 76.10557
61 51.93874 55.70017
62 35.77019 37.20883
63  7.82936  8.12688
64 28.00123 40.16693
65 11.33733 14.98823
66 14.91133 24.80842
67 17.37988 29.94669
68 32.78166 45.50777
69 20.75199 25.62167
70 44.74682 71.28549
71  8.41853 17.02001
72 50.49128 56.98780
73 25.83719 54.34103
74  5.16049  5.60854
75  7.31587 16.24848
76 16.40148 46.39456
77 13.83693 28.28180
78 13.49465 39.48454
79 45.37970 67.74192
80 33.45907 57.83608
81 12.85619 33.25567
82 71.26016 82.26565
83 43.46433 60.89344
84  5.03149  6.25944
85 11.24976 16.23713
86 32.65700 57.14506
87  9.76527 22.04486
88 27.81839 46.73865
89  8.95233 16.83527
90 11.89340 22.67550
91 56.87442 57.66741
92 22.34179 28.90660
93 34.83411 41.32793
94  9.50682 13.95888
95 38.25716 45.11613
96 51.02803 58.29759
97 17.59290 21.76497
98 28.73247 32.16129
99 17.37069 19.67762

Let's do a quick PCA

In [9]:
[rprint| dset_pca <<-prcomp (dset_small[c(1:15)], center=TRUE, scale=TRUE) |]
Standard deviations (1, .., p=15):
 [1] 3.497108e+00 1.517478e+00 6.733766e-01 1.065702e-01 4.741367e-02
 [6] 1.824746e-02 9.159435e-03 4.877200e-03 3.562465e-03 1.035096e-03
[11] 6.332675e-04 6.777833e-05 3.408059e-05 3.087402e-05 8.541166e-06

Rotation (n x k) = (15 x 15):
            PC1         PC2         PC3          PC4         PC5          PC6
fp0  -0.2532041  0.29198874 -0.20781706 -0.003172487  0.03279063  0.088152978
fp1  -0.2797700 -0.02972777  0.29853504  0.150437445  0.15660560 -0.005469843
fp2  -0.2337677 -0.34279938 -0.35963395  0.453094150  0.15122788  0.241830008
fp3  -0.2567914  0.28053333 -0.16348974 -0.130866235 -0.01020166  0.082529601
fp4  -0.2757387 -0.08881107  0.33302485 -0.380090805  0.05054910  0.372621255
fp5  -0.2496639 -0.31700406 -0.06752749 -0.583183663 -0.37104147 -0.347549465
fp6  -0.2521173  0.30567853 -0.12497577  0.084513091 -0.36232872  0.169781830
fp7  -0.2752094  0.01517451  0.40128695  0.086752334  0.18524240  0.103704839
fp8  -0.2573173 -0.28594966 -0.05770924 -0.184093672  0.06890558  0.360169958
fp9  -0.2443946  0.33260518 -0.17772812  0.081427014 -0.40767644  0.183841486
fp10 -0.2768940  0.08217377  0.31591645  0.337319861 -0.25028859 -0.525930540
fp11 -0.2490853 -0.30934875 -0.21342944  0.125426154 -0.01186275 -0.174884255
fp12 -0.2368337  0.34566881 -0.28650670 -0.253402828  0.62815548 -0.352605586
fp13 -0.2788354  0.02799193  0.32254799  0.105075044  0.13088019 -0.023476414
fp14 -0.2467103 -0.31699652 -0.23045930  0.102012698  0.01263265 -0.179162172
              PC7          PC8         PC9         PC10          PC11
fp0   0.084895707  0.554969133 -0.03432881  0.123493981 -0.1150769698
fp1  -0.095607799  0.105572456  0.32099773  0.158396289  0.0006734342
fp2   0.586899647 -0.052505212  0.19118114 -0.097360700  0.0874337942
fp3  -0.007072122  0.530942296 -0.14229177 -0.108131274  0.0990004899
fp4   0.172925821 -0.121396367 -0.29995273 -0.543100962  0.1496917462
fp5   0.258449717  0.058035108  0.37479242  0.124217066  0.0489038748
fp6  -0.060509097 -0.328130707 -0.09887920  0.339930879  0.6340813571
fp7  -0.094337828  0.038195656  0.20523330  0.004759474  0.0863844706
fp8  -0.080214252 -0.141572540 -0.36644229  0.563238471 -0.4335331915
fp9  -0.147515895 -0.307208240  0.29586846 -0.321325137 -0.5193856823
fp10  0.326079551 -0.039224670 -0.46665505  0.003834763 -0.1905924252
fp11 -0.407080495  0.070464194 -0.08775080 -0.215959971 -0.0199924863
fp12  0.087224343 -0.384160137 -0.01204068 -0.009332175 -0.0256091282
fp13 -0.160083301 -0.021114362  0.29331563  0.131142136 -0.0035693054
fp14 -0.443190328 -0.005008752 -0.15225550 -0.167624584  0.1997102038
            PC12        PC13          PC14        PC15
fp0  -0.52951759  0.37301792 -0.1466946066 -0.11254152
fp1   0.05103839  0.15760068  0.7650082445 -0.15309774
fp2   0.08322388 -0.03230792 -0.0514353454  0.01900309
fp3   0.58429488 -0.35534341  0.0696042429  0.09156850
fp4  -0.07547591  0.23763252  0.0692530972  0.01908419
fp5  -0.03289671 -0.05265758 -0.0381768251 -0.01682715
fp6  -0.08586526  0.01973856  0.0574950601  0.10168386
fp7  -0.35458911 -0.65678669 -0.2804297010 -0.12122597
fp8   0.08059905 -0.08849193  0.0003582488 -0.00752158
fp9   0.02912960 -0.05195249  0.0163005413 -0.10454199
fp10  0.02120151 -0.02429280 -0.0006718273 -0.02698781
fp11 -0.25287018 -0.06180557  0.1396259031  0.66149361
fp12 -0.02166617 -0.02980340  0.0390548844  0.01599468
fp13  0.38042655  0.43606275 -0.5036362391  0.26620754
fp14  0.10891757  0.10829402 -0.1503873226 -0.63957553

Inspect the results

In [10]:
[rprint| summary(dset_pca) |]
Importance of components:
                          PC1    PC2     PC3     PC4     PC5     PC6      PC7
Standard deviation     3.4971 1.5175 0.67338 0.10657 0.04741 0.01825 0.009159
Proportion of Variance 0.8153 0.1535 0.03023 0.00076 0.00015 0.00002 0.000010
Cumulative Proportion  0.8153 0.9688 0.99906 0.99982 0.99997 0.99999 1.000000
                            PC8      PC9     PC10      PC11      PC12      PC13
Standard deviation     0.004877 0.003562 0.001035 0.0006333 6.778e-05 3.408e-05
Proportion of Variance 0.000000 0.000000 0.000000 0.0000000 0.000e+00 0.000e+00
Cumulative Proportion  1.000000 1.000000 1.000000 1.0000000 1.000e+00 1.000e+00
                            PC14      PC15
Standard deviation     3.087e-05 8.541e-06
Proportion of Variance 0.000e+00 0.000e+00
Cumulative Proportion  1.000e+00 1.000e+00
In [11]:
[r| str (dset_pca) |]
List of 5
 $ sdev    : num [1:15] 3.4971 1.5175 0.6734 0.1066 0.0474 ...
 $ rotation: num [1:15, 1:15] -0.253 -0.28 -0.234 -0.257 -0.276 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:15] "fp0" "fp1" "fp2" "fp3" ...
  .. ..$ : chr [1:15] "PC1" "PC2" "PC3" "PC4" ...
 $ center  : Named num [1:15] 7.43 11.68 11.03 7.71 16.71 ...
  ..- attr(*, "names")= chr [1:15] "fp0" "fp1" "fp2" "fp3" ...
 $ scale   : Named num [1:15] 4.9 7.74 8.01 5.04 11.09 ...
  ..- attr(*, "names")= chr [1:15] "fp0" "fp1" "fp2" "fp3" ...
 $ x       : num [1:99, 1:15] -6.017 0.812 4.559 -0.417 2.939 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:15] "PC1" "PC2" "PC3" "PC4" ...
 - attr(*, "class")= chr "prcomp"
0x00007f39340082e0

Inspect the X's

In [12]:
[rprint| dset_pca$x |]
               PC1         PC2          PC3          PC4           PC5
  [1,] -6.01667020  0.54194176 -1.217431115  0.075265850 -1.793627e-02
  [2,]  0.81168533  1.42522522 -1.217988941 -0.058525767  2.549894e-02
  [3,]  4.55910586  0.06066636  0.039277455  0.012226631 -2.777270e-04
  [4,] -0.41679493  1.11755005 -0.704373398  0.225815931 -4.365102e-02
  [5,]  2.93885644  1.37077918 -0.729049792 -0.095356214  1.370422e-01
  [6,]  2.81355323  0.50685550 -0.188052242  0.063337868 -1.659036e-02
  [7,]  3.71380128  1.02187473 -0.476736351 -0.122724761  1.007769e-01
  [8,]  3.79478102  0.84393434 -0.366510618 -0.108913516  1.104235e-01
  [9,]  4.73815076 -0.08983721  0.188406057  0.040550799 -2.455672e-02
 [10,] -1.17812980  3.36089484 -1.421546237 -0.160282802 -9.528921e-02
 [11,]  2.33755514  2.01483085 -0.675479356 -0.007114197 -7.752691e-02
 [12,]  1.33410751  2.71907494 -0.988385701 -0.069653079 -3.571515e-02
 [13,]  3.74850100  0.73834238 -0.092164784 -0.054077004  1.484191e-02
 [14,] -1.95254190  0.25052890 -0.156169837  0.056023111 -1.659836e-02
 [15,] -1.10862152  0.94218313 -0.375140950 -0.133894306  7.358314e-03
 [16,]  3.35036440  0.86153820 -0.066165442 -0.051974921  4.573040e-02
 [17,]  3.27903220  0.84110086  0.021874896  0.032862400 -3.299020e-02
 [18,]  2.09372396  0.76242965 -0.037689765 -0.038713280  1.140610e-03
 [19,]  0.02821817  2.21907765 -0.084043061  0.116824448 -7.760050e-02
 [20,]  0.78062261  2.65139283 -0.447669774 -0.413908183  3.054727e-02
 [21,] -3.54956984  3.86948627 -0.116881470  0.149098276 -4.377796e-02
 [22,] -1.46113560  3.33903547 -0.217628273 -0.019640624 -3.568046e-02
 [23,] -7.49300866  0.91730528  0.069645810  0.086342400  3.029974e-03
 [24,] -5.58392849  2.92951885  0.461515840  0.207019616  4.496692e-03
 [25,]  0.44589011  2.58195085  0.383623144  0.229068590  4.084377e-03
 [26,] -4.99396377  3.48267415  0.503397579  0.065999547  6.655969e-03
 [27,] -1.31983472  0.66532055  0.318718143  0.056972015  5.919086e-04
 [28,]  3.96265018  0.28089571  0.359522913  0.095492912 -4.249051e-03
 [29,] -4.25351102  2.72237331  0.814004830 -0.080687398  7.405768e-03
 [30,]  0.71014523  0.63817659  0.301557576 -0.089595718 -4.429279e-02
 [31,] -4.91363349  2.69948242  0.951979352 -0.111053920  9.150753e-03
 [32,] -0.69346408  2.05595391  0.946032141  0.079479353  5.497579e-02
 [33,] -6.31383670  1.43668103  0.588926192 -0.212616910 -4.789654e-02
 [34,]  1.76494658  1.16645642  0.790323706  0.161861002  2.361436e-02
 [35,]  3.91418349  0.21509773  0.414591589  0.096904265 -1.101018e-02
 [36,] -4.18294170 -0.24137541 -0.028496115 -0.001606850 -2.649192e-02
 [37,]  3.43991738  0.31255141  0.578854063  0.164192721  4.731891e-03
 [38,] -5.54726909  0.57291302  0.501670722 -0.183178561 -5.474808e-02
 [39,]  4.32458838 -0.03720439  0.274824027  0.033889939 -1.436778e-02
 [40,]  2.81348125  0.14675098  0.408637114 -0.024189079  2.241735e-02
 [41,] -6.84876891 -0.27127962  0.230300020 -0.126862523 -1.583306e-02
 [42,]  0.37761493  0.73579009  1.619929779  0.228977891  1.464966e-01
 [43,] -0.51609278  0.83620701  1.718584913  0.009051837  7.165387e-02
 [44,]  4.77208116 -0.10953467  0.233092273  0.064131935 -2.145707e-02
 [45,]  1.87331238  0.09856974  1.114565339  0.066250828  4.509722e-02
 [46,]  0.19178950  0.01327570  0.981531380 -0.009327987 -2.331259e-02
 [47,] -0.94815012 -0.21762753  0.613216497 -0.219634081 -2.368746e-02
 [48,] -2.72561035 -0.51200272  1.392131179  0.016936249 -5.764053e-02
 [49,]  3.31739114 -0.14128326  0.695962723 -0.013201451 -7.771792e-03
 [50,]  1.92110633 -0.45273833  0.673621783 -0.038605356  2.616248e-02
 [51,]  1.17876323 -0.50147513  0.584426106 -0.084286196  2.630285e-02
 [52,]  3.67428800 -0.32761189  0.612989696 -0.012221849  2.237596e-02
 [53,]  2.48602668 -0.87548125  0.979633697 -0.072075958  3.375077e-02
 [54,] -7.02488326 -1.73205646  0.529575794  0.089475531 -7.698939e-03
 [55,] -5.90890081 -1.85563697  0.532492418 -0.009000275  7.197432e-03
 [56,] -2.17713500 -2.22267777  1.153437691 -0.143227568 -9.377858e-03
 [57,]  0.84511900 -1.65888282  0.963994807 -0.129224816 -1.422964e-02
 [58,]  1.45600695 -1.60553022  0.833599999 -0.111348646 -2.051231e-02
 [59,] -7.17941441 -1.84243213  0.402193612  0.046645627  4.147790e-02
 [60,] -7.65610925 -1.32489276 -0.134684691  0.030700645  9.373487e-03
 [61,] -3.73239430 -1.54308405  0.219754363  0.018840012  4.021708e-02
 [62,] -0.83600785 -0.85809216  0.009524384 -0.049693846 -4.620573e-02
 [63,]  4.26270958 -0.20296547  0.177529362  0.012763757 -5.452224e-02
 [64,]  0.06195340 -2.36590775  0.453162750 -0.167311111 -3.798365e-02
 [65,]  3.51822180 -0.75105805  0.264994334  0.006184650 -8.174745e-02
 [66,]  2.43748053 -1.56573404  0.213594110 -0.158288432 -6.751192e-02
 [67,]  1.84941966 -1.86686847  0.166108950 -0.176215605 -7.355025e-02
 [68,] -0.86677866 -1.91855348  0.020209495 -0.033130606  8.905738e-03
 [69,]  1.64326923 -0.80050831  0.011949180 -0.017017419  4.939282e-03
 [70,] -3.70655428 -3.17925259 -0.359065734 -0.020238291 -1.259312e-02
 [71,]  3.63464887 -1.02153073 -0.004897350 -0.033890644 -6.645921e-02
 [72,] -3.61153868 -1.25587924 -0.162903269  0.055243575  2.762864e-04
 [73,] -0.50410527 -3.05492010 -0.402878656  0.057142674 -4.958347e-03
 [74,]  4.75200666 -0.18309112  0.208226071  0.056795869 -2.756267e-02
 [75,]  3.84358791 -0.94737942 -0.039348199  0.000708889 -6.606278e-02
 [76,]  1.09172998 -2.51145845 -0.673481101  0.036615506 -2.139124e-02
 [77,]  2.40761304 -1.38682227 -0.225518826  0.036659475  8.526072e-03
 [78,]  1.81479749 -2.20878797 -0.609004014  0.145185982 -1.514153e-02
 [79,] -3.52702584 -2.12702353 -0.656523083  0.029102057  3.587015e-02
 [80,] -1.59644931 -1.96450253 -0.843668165  0.070602885 -4.334129e-03
 [81,]  2.33339391 -1.35363691 -0.571191125  0.074607618  3.024589e-02
 [82,] -7.51107290 -1.46386339 -0.645017073  0.109811792  8.972141e-05
 [83,] -2.85543014 -1.44692195 -0.672054614  0.166060094 -7.170823e-03
 [84,]  4.69671157 -0.17497587  0.138638248  0.038666238 -1.867289e-02
 [85,]  3.33938094 -0.49644807 -0.103920758  0.035605200 -8.408131e-03
 [86,] -1.50372078 -1.51277684 -1.071553389  0.043829919  1.178083e-01
 [87,]  3.17478171 -0.68753915 -0.481907722  0.050807821 -5.534283e-03
 [88,] -0.38429112 -0.75961321 -1.119124059  0.023014614  1.402116e-03
 [89,]  3.63041985 -0.36931379 -0.314034260  0.085755646 -4.982737e-04
 [90,]  2.96294401 -0.29919337 -0.538181312  0.080255244 -3.724051e-03
 [91,] -4.73692347 -0.78658554 -0.475041793  0.002208810 -1.958087e-03
 [92,]  1.07963956 -0.35906525 -0.600143378 -0.070887054  7.651930e-02
 [93,] -1.07041376 -0.40508436 -0.701144893 -0.028600335  3.878457e-02
 [94,]  3.62498284 -0.04567269 -0.341652317  0.010770704  5.373953e-02
 [95,] -1.90548543 -0.19725542 -1.073031304 -0.103674982  7.682773e-02
 [96,] -4.07300563 -0.10072984 -1.218980470 -0.025315121  5.323945e-02
 [97,]  2.27753983  0.27210472 -0.629973964  0.137697380 -1.000058e-01
 [98,]  0.06955766  1.05132437 -1.384681319  0.024448144 -4.376088e-02
 [99,]  2.08696699  0.90153900 -1.005144047 -0.119795530  1.007313e-01
                 PC6           PC7           PC8           PC9          PC10
  [1,]  0.0273284548  0.0069373422  3.540254e-03 -8.921709e-04  7.865700e-04
  [2,]  0.0212127881 -0.0040434572  7.734068e-04  2.161995e-03  6.519289e-04
  [3,] -0.0118120299  0.0016282408  3.383236e-03 -4.843759e-04 -1.021310e-04
  [4,]  0.0006142065  0.0119569281  5.138437e-03 -2.784208e-03 -3.299411e-04
  [5,] -0.0278845942  0.0088805487  7.260878e-04 -5.562427e-03  1.573073e-03
  [6,] -0.0067996729  0.0038494067 -1.322263e-02 -2.841350e-04 -3.842197e-04
  [7,] -0.0146937375 -0.0011674240  1.439862e-02 -1.175244e-03  5.641684e-04
  [8,] -0.0270405091  0.0011342057  3.705930e-03 -2.304018e-03  6.336456e-04
  [9,]  0.0012153199  0.0017728153  2.156316e-03 -6.510946e-05 -2.029236e-05
 [10,]  0.0536516930 -0.0141680530 -5.486111e-03  4.549990e-03  1.719089e-03
 [11,]  0.0065750290  0.0036835679 -7.563515e-03 -7.816546e-03  7.486035e-04
 [12,]  0.0164987528 -0.0069938397  1.299494e-03 -5.226233e-04  2.122790e-04
 [13,]  0.0165757808 -0.0049594541  1.459984e-03  2.795674e-03 -5.654473e-04
 [14,]  0.0152154278  0.0011607235  2.149045e-03  2.384001e-03  8.578685e-04
 [15,]  0.0153977288 -0.0124592501 -1.689419e-03  2.076294e-03 -9.681305e-04
 [16,] -0.0148294973 -0.0001562687 -1.693696e-03 -5.045477e-04  1.316816e-04
 [17,] -0.0161732161  0.0056079042 -1.086474e-02 -2.453830e-03 -5.868265e-04
 [18,]  0.0035416511 -0.0039102622 -1.816980e-04  9.500900e-04 -4.373893e-04
 [19,] -0.0033827547  0.0079593662  2.495018e-03 -1.233058e-02  5.899180e-04
 [20,]  0.0164241368  0.0245297873  3.310825e-03  6.013842e-03 -3.004429e-03
 [21,] -0.0224055333  0.0107421750  3.350310e-03  2.258663e-03 -1.040509e-03
 [22,] -0.0029826561  0.0009540611 -6.324028e-05 -1.982207e-03 -3.503062e-04
 [23,] -0.0024768850  0.0066319212  1.918506e-03  6.181301e-04 -4.665108e-04
 [24,] -0.0125905863  0.0111215433  3.755546e-03  1.282992e-03 -1.346642e-03
 [25,] -0.0307279296  0.0033976679  5.646944e-03  1.034680e-02 -5.033106e-04
 [26,] -0.0027284870  0.0016195467  7.844814e-04  3.821555e-04 -5.655753e-04
 [27,]  0.0001631581 -0.0097915859  3.063060e-03 -1.734935e-03 -9.993060e-04
 [28,]  0.0024190996 -0.0019925904  3.231430e-03  6.719617e-04  9.482475e-04
 [29,] -0.0144595125 -0.0090526153  5.337623e-04  2.012738e-03  9.982147e-04
 [30,] -0.0190852608 -0.0173907228  1.156069e-03 -3.663876e-03  1.135711e-03
 [31,]  0.0079223817 -0.0013441548 -2.592803e-03 -2.146671e-03 -8.609641e-04
 [32,] -0.0203754457  0.0027089348 -1.604340e-02  3.447140e-03 -1.119529e-03
 [33,] -0.0261584902 -0.0077830497  8.503736e-04  2.112985e-03  2.918684e-03
 [34,] -0.0010299926 -0.0033030877  3.147853e-03  5.673987e-03  7.618257e-04
 [35,] -0.0021596851  0.0032483114  3.089050e-03  1.304071e-03 -2.233748e-04
 [36,] -0.0137221311 -0.0212632695  2.168814e-03 -4.159061e-03 -2.425863e-03
 [37,] -0.0124524054 -0.0023861214  1.682080e-03  1.011348e-02 -2.470574e-04
 [38,] -0.0333476559 -0.0316111365  6.369940e-04 -3.856441e-03  1.418741e-04
 [39,]  0.0047307580  0.0012845834  1.762529e-03 -7.633920e-04 -1.272339e-04
 [40,]  0.0278130541 -0.0041948312 -1.689989e-03 -2.589521e-03 -3.080471e-04
 [41,] -0.0131275956  0.0034432332 -6.795038e-03  5.412975e-04  6.399200e-04
 [42,]  0.0274475900 -0.0278205962 -5.833271e-03  5.879260e-03  3.731027e-03
 [43,]  0.0484944537  0.0032756722  3.147890e-03 -9.227452e-03 -6.410504e-04
 [44,] -0.0025358497  0.0027251582  3.100866e-03  1.682269e-05  7.205601e-05
 [45,]  0.0189426154 -0.0008336597 -4.753197e-04 -4.621879e-03  2.194023e-05
 [46,]  0.0075421061  0.0123649668  8.133472e-04 -5.864113e-04 -6.268450e-04
 [47,] -0.0162132535  0.0132432900 -1.686536e-02  2.465480e-03 -8.820906e-04
 [48,] -0.0224309759 -0.0094751003  2.622007e-03 -4.213831e-04 -1.499083e-04
 [49,]  0.0066893081  0.0084284842  5.109659e-04  5.805878e-04 -4.818882e-04
 [50,]  0.0207609495  0.0012526083 -2.601605e-03 -7.350306e-04 -7.928396e-04
 [51,]  0.0300306809 -0.0001862129 -4.901425e-03 -2.431113e-04 -9.964883e-04
 [52,]  0.0295713207 -0.0018335928 -1.756102e-03 -4.725296e-03 -3.478064e-04
 [53,]  0.0328548153  0.0009771736 -1.585142e-03 -5.323633e-03 -2.493014e-04
 [54,] -0.0153224267  0.0064496814  2.369988e-03 -1.324140e-03  3.757241e-04
 [55,] -0.0054834786 -0.0014727820  7.110496e-04  5.395892e-04  7.135513e-04
 [56,]  0.0018344049  0.0180166366  2.172369e-03  2.903721e-03 -2.631607e-04
 [57,]  0.0044104521  0.0068271739  4.724068e-03  1.075691e-03  4.547654e-04
 [58,] -0.0078890252  0.0101741543  2.527446e-03  2.324901e-03  3.104802e-04
 [59,]  0.0317932472  0.0121485561  9.687001e-04  1.802974e-03 -1.470224e-04
 [60,]  0.0107163347  0.0040258951  1.017423e-03  8.634937e-05  4.942115e-05
 [61,]  0.0294358230 -0.0038636759 -1.874561e-04 -1.929703e-03  5.180963e-05
 [62,] -0.0168796794 -0.0030748528 -5.561949e-04 -5.060525e-04  9.085885e-04
 [63,]  0.0010242517  0.0052791604  1.780323e-03 -3.413271e-04  2.225757e-04
 [64,] -0.0005111902  0.0060575330  2.220581e-03  2.614301e-03  1.172058e-03
 [65,] -0.0072269326  0.0139359104  4.291443e-03  2.148882e-03  1.108785e-04
 [66,] -0.0071994072  0.0063186836  2.786559e-03  1.349936e-03  8.511864e-04
 [67,] -0.0099166714  0.0061039911  3.011916e-03  1.772693e-03  9.117458e-04
 [68,]  0.0211438275 -0.0060834775  3.528133e-04 -2.870009e-03 -2.087148e-04
 [69,]  0.0191876937 -0.0074756487  3.992275e-04 -1.619289e-03 -7.396211e-05
 [70,]  0.0054246761 -0.0050761618  3.225819e-03 -7.135100e-04  1.774729e-04
 [71,] -0.0137058135 -0.0097631344  9.717571e-04  3.175313e-03  7.838196e-04
 [72,]  0.0086681673  0.0046711745  3.441539e-03  3.494430e-04  2.549773e-04
 [73,]  0.0009946870 -0.0164203911  1.223687e-03  4.121975e-04 -2.567763e-03
 [74,] -0.0061761303  0.0016762689  2.302393e-03 -6.971251e-04  1.820771e-04
 [75,] -0.0194483220 -0.0077312514  2.197343e-03  2.025332e-03  1.076693e-03
 [76,]  0.0061145639 -0.0106753187 -5.080718e-04  4.840500e-03 -7.497301e-04
 [77,] -0.0191672581 -0.0032537489 -5.309805e-03 -4.237981e-04 -3.569064e-04
 [78,] -0.0051877011 -0.0188152838  1.755741e-03 -6.157098e-04 -2.898900e-03
 [79,] -0.0118676390  0.0105598316 -1.018235e-02  2.184780e-03  1.211926e-03
 [80,] -0.0127925694  0.0001667439 -1.670369e-03  2.974449e-04  5.880124e-04
 [81,] -0.0139594499  0.0062804956 -1.551534e-02  7.948296e-04 -2.411710e-04
 [82,]  0.0078647474  0.0093209345 -8.047855e-04  2.077056e-04  4.022708e-04
 [83,]  0.0050945529  0.0106126003 -3.825335e-03 -3.330875e-04  4.778130e-04
 [84,]  0.0033709492  0.0004372212  2.461098e-03  1.365118e-04 -1.596339e-04
 [85,] -0.0146815259 -0.0030228732 -2.527933e-03 -1.424907e-04 -8.609793e-04
 [86,] -0.0223952691  0.0133143328  5.289665e-05 -4.898705e-03  1.791103e-03
 [87,]  0.0064897888 -0.0069248871  1.070793e-03  3.698150e-03 -1.207683e-03
 [88,]  0.0244980659  0.0056003503  4.058340e-03  6.245379e-03  6.035906e-04
 [89,] -0.0078683476 -0.0009405393 -1.877928e-03 -6.275717e-04 -2.286394e-04
 [90,]  0.0168485664  0.0050383992  2.785215e-03  3.041923e-03  4.295370e-04
 [91,] -0.0094576550 -0.0136581252  3.952788e-03 -2.415293e-03 -2.252971e-03
 [92,] -0.0286655666 -0.0033438275 -7.295557e-04 -3.790702e-03 -5.296150e-04
 [93,] -0.0237361083 -0.0037515527 -2.712528e-03 -1.135067e-03  4.265414e-04
 [94,] -0.0256010737 -0.0002042074 -7.335383e-03 -2.035868e-03 -4.878451e-05
 [95,] -0.0156687569 -0.0079455964  4.067576e-04 -6.632516e-05 -1.656666e-03
 [96,] -0.0026543585  0.0017460612  4.892716e-03 -8.228017e-04 -1.421107e-04
 [97,]  0.0073031535  0.0073908545  4.185096e-04 -1.098974e-02  1.536185e-03
 [98,]  0.0430704932 -0.0064375954 -9.567572e-03  4.997604e-03  3.569329e-04
 [99,]  0.0021669921 -0.0006175453  9.154283e-03  2.591844e-03  4.756043e-04
                PC11          PC12          PC13          PC14          PC15
  [1,]  1.882905e-04 -1.116724e-06 -5.418156e-06 -7.360121e-06  4.675018e-06
  [2,]  3.854556e-04 -4.144456e-06  1.575902e-05 -3.271616e-06  7.031069e-06
  [3,]  9.190849e-05  3.666674e-05  5.124072e-05  6.011750e-05 -2.873575e-06
  [4,] -5.781021e-04 -4.658058e-05 -5.554865e-05 -1.928751e-05 -8.204715e-07
  [5,]  1.533271e-03 -9.048860e-05  3.228627e-05 -5.789725e-05 -2.293096e-05
  [6,] -2.657640e-04  4.782755e-05  4.796114e-05 -2.450078e-05  5.030848e-06
  [7,] -3.545236e-04  2.834673e-05  1.635794e-05 -1.623976e-05  4.949849e-06
  [8,] -8.366430e-05 -1.308300e-05 -9.187423e-06 -8.862005e-06 -2.126273e-07
  [9,] -1.706726e-04 -3.474465e-05 -1.189930e-05  1.312409e-05  2.422247e-06
 [10,]  9.203008e-04 -1.214863e-04  2.483668e-05  2.430860e-05 -1.436792e-05
 [11,]  9.327280e-04  2.170719e-06  3.994754e-05 -1.536117e-05  3.184931e-06
 [12,] -3.609701e-04 -2.205097e-05 -2.079250e-05  1.423394e-05  8.173412e-06
 [13,] -7.236720e-04 -6.457793e-06 -6.675412e-06  7.385093e-06 -6.485833e-07
 [14,]  4.606736e-04 -5.327345e-05 -1.138712e-05  2.770911e-06  2.982828e-07
 [15,] -1.642749e-03  4.134390e-05 -2.662218e-05 -1.875070e-05 -2.834051e-05
 [16,] -2.095756e-04  1.014935e-05  5.573950e-07 -6.658345e-06  6.280752e-07
 [17,] -6.246465e-04  7.441699e-05  3.858740e-05 -3.395615e-05  4.047130e-06
 [18,] -7.976406e-04  1.760139e-05 -1.632802e-05  7.020895e-06 -1.010647e-05
 [19,] -7.523663e-04  2.374409e-04 -5.148765e-05  8.816312e-06 -1.327552e-05
 [20,]  7.838100e-04  1.439426e-04 -1.048769e-04 -3.601754e-05  2.265959e-05
 [21,]  7.098662e-05 -6.441869e-05 -7.364331e-06  1.968565e-05  2.619412e-07
 [22,]  6.978515e-05  1.540379e-06  8.947919e-06  8.080910e-06 -4.123842e-06
 [23,] -3.458537e-04 -3.294259e-05  1.259450e-05  1.267519e-05 -1.577127e-06
 [24,] -7.081376e-04 -5.191901e-05 -9.532936e-06  7.979817e-06 -4.008034e-06
 [25,]  7.892346e-04 -1.266649e-04  1.904298e-05  4.014593e-05  1.864661e-05
 [26,] -3.548968e-05 -9.517696e-06 -8.669134e-06 -6.401359e-08 -2.867225e-06
 [27,]  5.682066e-04  7.077191e-05  9.915820e-05  6.251244e-05 -3.169725e-06
 [28,]  2.194972e-04  7.792010e-05 -4.884154e-05  1.749395e-05 -7.861322e-06
 [29,]  2.255157e-04  2.199461e-05  1.260476e-05 -5.406006e-06 -3.354250e-06
 [30,] -1.221836e-03 -1.456998e-04  1.255951e-05 -2.433462e-05  2.365797e-05
 [31,]  2.235188e-04  1.982541e-05  1.868545e-05 -4.682454e-07 -8.281723e-06
 [32,] -1.164592e-04 -2.950142e-05 -2.483150e-05  2.037913e-05 -9.459272e-07
 [33,] -8.525416e-04  2.622138e-06 -1.640344e-06  3.292982e-05  1.030216e-05
 [34,]  1.103536e-03 -3.607580e-06 -3.083802e-06 -5.515614e-06  5.808391e-06
 [35,] -1.215104e-04 -6.347492e-05  1.869469e-07  6.445431e-06  3.162013e-06
 [36,]  6.965754e-04  2.220384e-05 -9.549593e-06 -1.781713e-06 -8.527867e-06
 [37,]  2.875880e-04  7.748960e-05  5.460524e-05 -1.055989e-04 -8.559187e-07
 [38,] -3.120859e-04 -6.965324e-05 -7.762750e-05 -5.754279e-05  5.224876e-06
 [39,] -2.398028e-04 -3.078312e-05 -1.202833e-05  9.069866e-06  1.780322e-06
 [40,] -3.025509e-04 -4.342968e-05 -1.223319e-05 -1.124778e-05  6.343112e-06
 [41,] -2.674140e-04  3.098153e-05 -2.783482e-06  8.295062e-06  4.984145e-06
 [42,]  8.846620e-04  2.485103e-04 -8.156253e-05  1.694259e-05 -2.226398e-07
 [43,] -3.000912e-04 -8.637802e-05  4.133802e-05  9.548409e-07  1.507626e-06
 [44,] -2.379924e-04 -1.445522e-05 -2.024830e-05  1.261766e-05 -2.647856e-06
 [45,] -6.469858e-04  7.469098e-06  4.350385e-05  1.633418e-05 -9.408548e-07
 [46,]  2.899227e-04 -9.048439e-06  5.247048e-06 -6.841964e-06 -1.095326e-05
 [47,]  3.402108e-04  5.869142e-05  2.450818e-06 -3.697815e-05 -5.295397e-06
 [48,] -3.437799e-04 -4.129786e-05 -2.860519e-05 -7.950714e-06  9.645799e-07
 [49,]  7.572753e-05  2.920619e-06 -1.688831e-05  7.047216e-06 -7.022208e-06
 [50,]  2.736029e-04 -9.596858e-05  9.448798e-06  3.144303e-06  7.807018e-06
 [51,]  4.844214e-04 -1.328615e-04  2.518486e-05 -9.083578e-07  1.002613e-05
 [52,] -2.615042e-04 -4.387967e-05 -1.356146e-05 -1.400849e-05  8.509745e-06
 [53,] -6.207590e-04 -2.407685e-05  5.135209e-05  1.236709e-05  8.670685e-07
 [54,]  3.311423e-04 -1.808087e-05  2.696845e-05 -5.802005e-05 -9.951948e-06
 [55,]  2.419734e-04 -1.690053e-05  3.133556e-05 -7.141519e-06 -1.901247e-06
 [56,]  7.018854e-04  3.456701e-05 -2.412518e-05 -3.693868e-05 -7.458477e-06
 [57,]  6.968878e-04 -1.874582e-05  3.771720e-06  7.303555e-06  2.755303e-06
 [58,]  1.656060e-04  3.785980e-05  1.696526e-05  2.749007e-05 -1.930550e-06
 [59,] -6.818106e-06 -5.120912e-05  5.050205e-06 -2.615530e-06 -3.548023e-06
 [60,]  9.128050e-05 -9.374678e-06 -1.166022e-06  8.479883e-07 -2.354883e-06
 [61,]  2.065427e-04 -6.365285e-06 -1.896559e-05 -1.190096e-05  3.644108e-06
 [62,]  2.166008e-04  3.034566e-05  6.284871e-05 -6.066707e-05  2.053849e-05
 [63,]  4.299562e-05 -1.246793e-06 -2.250239e-06  8.503174e-06 -3.256043e-06
 [64,]  1.782858e-04  3.406546e-05  5.685990e-06  3.208190e-05 -4.504330e-06
 [65,]  9.903440e-04  1.700058e-05 -2.097903e-05  2.522664e-05 -2.728182e-06
 [66,] -5.641244e-05  2.954447e-05  1.329508e-06  4.381844e-05 -3.037347e-06
 [67,]  1.506648e-05  2.329948e-05 -4.658972e-06  4.050225e-05 -3.251762e-06
 [68,] -1.988046e-04 -2.949972e-05 -1.933931e-05 -8.043189e-06  7.971393e-06
 [69,] -3.391453e-04 -2.482816e-05 -2.468636e-05 -8.161345e-06  3.770952e-06
 [70,] -7.526884e-05  5.259230e-06 -2.549108e-05  1.010063e-05  2.958769e-06
 [71,]  1.560888e-04 -7.952358e-05  4.185665e-05 -1.708578e-05 -1.223106e-05
 [72,] -3.623963e-04  5.212044e-06 -2.092235e-05  1.067916e-05  1.936616e-07
 [73,]  9.162968e-04  8.408311e-05  1.139926e-05  1.749554e-05  7.117263e-06
 [74,] -1.570434e-04  1.077071e-05  1.956826e-06 -1.994804e-05  6.153410e-06
 [75,] -1.824852e-04 -5.597105e-05  2.904141e-05  1.229297e-05 -6.293270e-06
 [76,]  4.664341e-04 -1.197656e-04 -6.207203e-05 -2.585896e-05 -1.641949e-05
 [77,]  6.658416e-05  8.821116e-06 -2.176024e-05  1.591442e-05 -1.775563e-06
 [78,]  5.899423e-04  3.789634e-06 -2.923672e-05 -2.423737e-05  1.175967e-05
 [79,] -8.773289e-04  7.344180e-05  4.962703e-06  8.991239e-05  1.205834e-05
 [80,] -3.242766e-04  4.562432e-05  2.016271e-05 -2.826005e-05  5.686887e-06
 [81,] -9.224151e-04 -1.689263e-04 -6.912629e-05  7.666726e-05 -7.689827e-06
 [82,] -7.522146e-04  3.840689e-05 -1.713557e-06 -3.549050e-05  7.433525e-06
 [83,] -6.871411e-04  1.836145e-05  9.414363e-06 -2.838490e-05  1.099193e-05
 [84,] -2.255435e-04 -1.755709e-05 -1.236539e-05  1.351645e-05  1.120068e-06
 [85,] -2.217683e-04  5.598082e-05  3.837126e-05 -1.604693e-05 -1.032116e-05
 [86,]  1.368742e-03 -1.688263e-04 -3.209518e-05 -8.904380e-06 -4.421778e-06
 [87,] -5.808360e-04 -1.037380e-05 -5.898408e-05 -1.057366e-05 -1.062536e-05
 [88,] -1.524705e-03  7.368670e-05  6.243488e-05 -7.832582e-05 -1.373509e-05
 [89,] -4.615196e-04  7.658490e-05  2.510443e-05 -2.961351e-05  9.318115e-06
 [90,] -1.036042e-03 -7.854952e-06  9.967984e-07  2.856479e-05 -3.016755e-06
 [91,]  8.876196e-04  8.169181e-05  4.581050e-05  4.719415e-05 -1.103212e-05
 [92,]  5.730690e-04  3.056885e-06 -3.520539e-05  4.274774e-06 -5.563816e-06
 [93,] -1.957283e-04 -1.901060e-05 -3.310228e-05 -9.262989e-06  2.253838e-06
 [94,] -1.117222e-04  1.127441e-05  1.614430e-05 -2.659928e-05  7.179043e-08
 [95,]  2.644847e-04  8.835137e-05  6.133304e-05  8.797460e-05  6.119007e-06
 [96,] -4.401418e-05  1.756457e-05  2.096361e-05  2.875490e-05 -5.832369e-07
 [97,]  1.698703e-03  9.482952e-05 -5.192889e-05  4.383725e-06  9.353801e-06
 [98,]  1.314744e-03  1.616645e-05  2.982704e-05 -1.183333e-05  3.718410e-06
 [99,] -1.237978e-03  3.457758e-05  1.126870e-05  4.345927e-06  5.920233e-06

Plot PC1 vs PC2

In [13]:
[rgraph|
  ggplot(dset_small, aes(x=dset_pca$x[,1], y=dset_pca$x[,2])) + 
  ggtitle("PC1 vs PC2") +
  xlab("PC1") + ylab("PC2") +
  geom_point(size=2, shape=21) +
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(text=element_text(family="Ariel", size=12)) |]

Test understanding if row vector of samples times PC1 vector yields x value ..

In [14]:
[rprint| as.data.frame(dset_pca$rotation[,1:2])
 0|]
[1] 0
In [15]:
[r| pc1 <<- dset_pca$rotation[,1]
    pc2 <<- dset_pca$rotation[,2]
    dataline <<- dset_small[1,] |]
0x00007f38f9215660
In [ ]:

In [16]:
[rprint| dataline |]
       fp0      fp1      fp2      fp3      fp4      fp5      fp6      fp7
1 16.93446 21.83035 24.64847 17.22998 29.86766 23.29893 36.21929 52.72085
       fp8      fp9     fp10     fp11     fp12     fp13     fp14        X
1 19.77298 40.67645 31.58421 13.00247 33.25382 21.61335 12.59739 74.79439
         Y        Z
1 64.76476 64.86676

Answer for conversion of first two cols should be

-6.01667020 0.54194176

In [17]:
[rprint| # project new data onto the PCA space
         scale((dataline[1,1:15]), dset_pca$center, dset_pca$scale) %*% dset_pca$rotation |]
       PC1       PC2       PC3        PC4         PC5        PC6         PC7
1 -6.01667 0.5419418 -1.217431 0.07526585 -0.01793627 0.02732845 0.006937342
          PC8           PC9       PC10         PC11          PC12          PC13
1 0.003540254 -0.0008921709 0.00078657 0.0001882905 -1.116724e-06 -5.418156e-06
           PC14         PC15
1 -7.360121e-06 4.675018e-06

Works great!

Later need to limit it to the first 3 cols?

In [18]:
[rprint| dim(dataline[1,1:15]) |]
[1]  1 15
In [19]:
[rprint| dim(dset_pca$rotation) |]
[1] 15 15

Now Export Data for AI or Monte Carlo

Use ..
write.table(mydata, "c:/mydata.txt", sep="\t")
but first make a data.frame.

In [20]:
[r| x=dset_pca$x[,1] #PC1
    y=dset_pca$x[,2] #PC2
    # dset_small$XScaled = scale((dset_small$X, dset_pca$center, dset_pca$scale)
    dset_small$XScaled = scale(dset_small$X)
    actX=dset_small$XScaled
    exportFrame <<- data.frame(x,y,actX)
    write.csv(exportFrame, "frame.txt", row.names=FALSE) |]
0x00007f39340082e0
In [21]:
[rprint| exportFrame |]
             x           y        actX
1  -6.01667020  0.54194176  1.91722730
2   0.81168533  1.42522522  0.23260496
3   4.55910586  0.06066636 -1.20956200
4  -0.41679493  1.11755005  0.53274115
5   2.93885644  1.37077918 -0.40758297
6   2.81355323  0.50685550 -0.57130696
7   3.71380128  1.02187473 -0.75788250
8   3.79478102  0.84393434 -0.81346742
9   4.73815076 -0.08983721 -1.30273622
10 -1.17812980  3.36089484  1.18267670
11  2.33755514  2.01483085 -0.07728859
12  1.33410751  2.71907494  0.34516248
13  3.74850100  0.73834238 -0.85893738
14 -1.95254190  0.25052890  0.61212317
15 -1.10862152  0.94218313  0.50023070
16  3.35036440  0.86153820 -0.70874320
17  3.27903220  0.84110086 -0.65534474
18  2.09372396  0.76242965 -0.40413144
19  0.02821817  2.21907765  0.54011049
20  0.78062261  2.65139283  0.32381517
21 -3.54956984  3.86948627  1.88229399
22 -1.46113560  3.33903547  1.15469987
23 -7.49300866  0.91730528  2.23224846
24 -5.58392849  2.92951885  2.15196176
25  0.44589011  2.58195085  0.47358627
26 -4.99396377  3.48267415  2.05724150
27 -1.31983472  0.66532055  0.45258449
28  3.96265018  0.28089571 -1.02683786
29 -4.25351102  2.72237331  1.60232781
30  0.71014523  0.63817659 -0.12022656
31 -4.91363349  2.69948242  1.74259233
32 -0.69346408  2.05595391  0.55661999
33 -6.31383670  1.43668103  1.88001417
34  1.76494658  1.16645642 -0.28404900
35  3.91418349  0.21509773 -1.02787118
36 -4.18294170 -0.24137541  1.04004366
37  3.43991738  0.31255141 -0.87482595
38 -5.54726909  0.57291302  1.47247315
39  4.32458838 -0.03720439 -1.19643531
40  2.81348125  0.14675098 -0.80077264
41 -6.84876891 -0.27127962  1.72808122
42  0.37761493  0.73579009 -0.13086817
43 -0.51609278  0.83620701  0.06406313
44  4.77208116 -0.10953467 -1.31376423
45  1.87331238  0.09856974 -0.62398883
46  0.19178950  0.01327570 -0.17644076
47 -0.94815012 -0.21762753  0.10008642
48 -2.72561035 -0.51200272  0.43206477
49  3.31739114 -0.14128326 -1.01469619
50  1.92110633 -0.45273833 -0.72789940
51  1.17876323 -0.50147513 -0.54482462
52  3.67428800 -0.32761189 -1.15913581
53  2.48602668 -0.87548125 -1.02767149
54 -7.02488326 -1.73205646  1.46723734
55 -5.90890081 -1.85563697  1.09944236
56 -2.17713500 -2.22267777 -0.09071530
57  0.84511900 -1.65888282 -0.76091699
58  1.45600695 -1.60553022 -0.87769558
59 -7.17941441 -1.84243213  1.47179650
60 -7.65610925 -1.32489276  1.78493910
61 -3.73239430 -1.54308405  0.61452745
62 -0.83600785 -0.85809216  0.03428158
63  4.26270958 -0.20296547 -1.19978514
64  0.06195340 -2.36590775 -0.64043005
65  3.51822180 -0.75105805 -1.12700664
66  2.43748053 -1.56573404 -1.06134530
67  1.84941966 -1.86686847 -0.96790961
68 -0.86677866 -1.91855348 -0.22108964
69  1.64326923 -0.80050831 -0.64061953
70 -3.70655428 -3.17925259  0.32340881
71  3.63464887 -1.02153073 -1.20680616
72 -3.61153868 -1.25587924  0.72843177
73 -0.50410527 -3.05492010 -0.49441142
74  4.75200666 -0.18309112 -1.31845621
75  3.84358791 -0.94737942 -1.22807777
76  1.09172998 -2.51145845 -0.76002903
77  2.40761304 -1.38682227 -0.90389231
78  1.81479749 -2.20878797 -0.87423986
79 -3.52702584 -2.12702353  0.60499951
80 -1.59644931 -1.96450253  0.14338849
81  2.33339391 -1.35363691 -0.79917737
82 -7.51107290 -1.46386339  1.82554571
83 -2.85543014 -1.44692195  0.60882165
84  4.69671157 -0.17497587 -1.30760515
85  3.33938094 -0.49644807 -0.97554135
86 -1.50372078 -1.51277684  0.23851140
87  3.17478171 -0.68753915 -0.93473319
88 -0.38429112 -0.75961321  0.10196405
89  3.63041985 -0.36931379 -0.97673257
90  2.96294401 -0.29919337 -0.76231674
91 -4.73692347 -0.78658554  1.13173222
92  1.07963956 -0.35906525 -0.31199658
93 -1.07041376 -0.40508436  0.29017108
94  3.62498284 -0.04567269 -0.91644545
95 -1.90548543 -0.19725542  0.56565983
96 -4.07300563 -0.10072984  1.21983827
97  2.27753983  0.27210472 -0.41681415
98  0.06955766  1.05132437  0.40035822
99  2.08696699  0.90153900 -0.27264993

HP Evolutionary Stack Computer Results for X

In [24]:
[rprint| predictedX <<- read.csv(file = 'paste01.csv', header=FALSE) |]
             V1          V2
1   1.967583586  1.91722730
2   0.184061967  0.23260496
3  -1.349531851 -1.20956200
4   0.460303492  0.53274115
5  -0.470423178 -0.40758297
6  -0.692009319 -0.57130696
7  -0.807577964 -0.75788250
8  -0.885254003 -0.81346742
9  -1.448396390 -1.30273622
10  1.361707391  1.18267670
11 -0.096817288 -0.07728859
12  0.415490229  0.34516248
13 -0.903047587 -0.85893738
14  0.660921239  0.61212317
15  0.615241395  0.50023070
16 -0.746647860 -0.70874320
17 -0.731379402 -0.65534474
18 -0.399388294 -0.40413144
19  0.657257843  0.54011049
20  0.561231068  0.32381517
21  2.225716834  1.88229399
22  1.440051321  1.15469987
23  2.523094183  2.23224846
24  2.554034201  2.15196176
25  0.640818223  0.47358627
26  2.542991374  2.05724150
27  0.595546582  0.45258449
28 -1.104526341 -1.02683786
29  2.092765299  1.60232781
30 -0.021590592 -0.12022656
31  2.283934775  1.74259233
32  0.824825397  0.55661999
33  2.325155318  1.88001417
34 -0.179547049 -0.28404900
35 -1.109725727 -1.02787118
36  1.182469887  1.04004366
37 -0.938209793 -0.87482595
38  1.836054631  1.47247315
39 -1.308537831 -1.19643531
40 -0.800019080 -0.80077264
41  1.973246788  1.72808122
42  0.107452546 -0.13086817
43  0.405689935  0.06406313
44 -1.464484749 -1.31376423
45 -0.532422790 -0.62398883
46 -0.053554138 -0.17644076
47  0.219156777  0.10008642
48  0.664082288  0.43206477
49 -1.037602319 -1.01469619
50 -0.712153400 -0.72789940
51 -0.504071509 -0.54482462
52 -1.200569966 -1.15913581
53 -1.008452381 -1.02767149
54  1.587848040  1.46723734
55  1.215979153  1.09944236
56 -0.013662831 -0.09071530
57 -0.751200547 -0.76091699
58 -0.918461151 -0.87769558
59  1.601094685  1.47179650
60  1.899364949  1.78493910
61  0.656793073  0.61452745
62 -0.006625292  0.03428158
63 -1.339702517 -1.19978514
64 -0.728358344 -0.64043005
65 -1.280783956 -1.12700664
66 -1.200964373 -1.06134530
67 -1.114886439 -0.96790961
68 -0.315532445 -0.22108964
69 -0.733133262 -0.64061953
70  0.158190505  0.32340881
71 -1.396853882 -1.20680616
72  0.706697832  0.72843177
73 -0.765244451 -0.49441142
74 -1.480529333 -1.31845621
75 -1.437290200 -1.22807777
76 -1.080956530 -0.76002903
77 -1.138330594 -0.90389231
78 -1.207075638 -0.87423986
79  0.420000695  0.60499951
80 -0.110415963  0.14338849
81 -1.106109245 -0.79917737
82  1.814162854  1.82554571
83  0.422552457  0.60882165
84 -1.461506230 -1.30760515
85 -1.150748700 -0.97554135
86 -0.002716820  0.23851140
87 -1.158696259 -0.93473319
88 -0.112596628  0.10196405
89 -1.199920093 -0.97673257
90 -0.978641214 -0.76231674
91  1.185101379  1.13173222
92 -0.431611441 -0.31199658
93  0.199598821  0.29017108
94 -1.101196660 -0.91644545
95  0.512469004  0.56565983
96  1.191682738  1.21983827
97 -0.601630534 -0.41681415
98  0.294530015  0.40035822
99 -0.355628398 -0.27264993
In [30]:
[rgraph|
  ggplot(predictedX, aes(x=predictedX[,2], y=predictedX[,1])) + 
  ggtitle("Actual X vs Predicted X") +
  xlab("Actual") + ylab("Predicted") +
  geom_point(size=2, shape=21) +
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(text=element_text(family="Ariel", size=12)) |]

With This Formuls (Raw)

To interpret this, it helps to know that,

  • push (0) - means put constant 1
  • push (1) - means put constant 5
  • push (2) - means put constant PC1
  • push (3) - means put constant PC2

I'll have to check this to be absolutely sure ..

Comments

  • Didn't use PC3
  • It trained on all the data, no hidden data
  • Need to get the 'round trip', i.e.generate model and test on new data
  • Try detrending?
  • Is it accurate enough .. No way to tell until the data is remapped to actual X from PCA space.
  • Need to try Y, and Z

Formula from HP Stack Machine

Converting the HP Stack Program resulted in,

$Prediction = 0.6 \cdot (P2 - P1)$

Verified below by comparing the two scatterplots (one above).

In [31]:
[rgraph| 
    pc1 = exportFrame$x
    pc2 = exportFrame$y
    actual = exportFrame$actX
    prediction = 0.6 * (pc2 - pc1)
    newFrame = data.frame (actual, prediction)
    
    ggplot(newFrame, aes(x=newFrame[,1], y=newFrame[,2])) + 
    ggtitle("Actual X vs Predicted X") +
    xlab("Actual") + ylab("Predicted") +
    geom_point(size=2, shape=21) +
    theme(plot.title = element_text(hjust = 0.5)) +
    theme(text=element_text(family="Ariel", size=12)) |]