mod.PCR: Principal Component Regression (PCR)

Description Usage Arguments Value Author(s) Examples

View source: R/AllFunctions.R

Description

Takes in a set of predictor variables and a set of response variables and gives the PCR parameters.

Usage

1
mod.PCR(X, Y, r, ...)

Arguments

X

A (NxP) predictor matrix

Y

A (NxM) response matrix

r

The number of PCA components

...

Other arguments. Currently ignored

Value

The PCR parameters

Author(s)

Opeoluwa F. Oyedele and Sugnet Gardner-Lubbe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
if(require(pls))
data(oliveoil, package="pls")
X = as.matrix(oliveoil$chemical, ncol=5)
dimnames(X) = list(paste(c("G1","G2","G3","G4","G5","I1","I2","I3","I4","I5",
"S1","S2","S3","S4","S5","S6")),
paste(c("Acidity","Peroxide","K232","K270","DK")))
Y = as.matrix(oliveoil$sensory, ncol=6)
dimnames(Y) = list(paste(c("G1","G2","G3","G4","G5","I1","I2","I3","I4","I5",
"S1","S2","S3","S4","S5","S6")),
paste(c("Yellow","Green","Brown","Glossy","Transp","Syrup")))
mod.PCR(X, Y, r=2)

Example output

Loading required package: pls

Attaching package: 'pls'

The following object is masked from 'package:stats':

    loadings

$X.scores
      Comp 1      Comp 2      Comp 3        Comp 4        Comp 5 
G1 -0.5377559 -0.45273220  0.15110902 -0.0181234339  3.327619e-04
G2 -0.9527554  0.11197297  0.05218071  0.0054812158 -8.891897e-04
G3 -2.9515213  0.02392505  0.11908207  0.0027781310 -2.140415e-03
G4  0.4471644 -0.34795249 -0.09490618  0.0318420220 -8.168654e-05
G5 -2.0586159 -0.20412820 -0.07177192  0.0003710875  2.434112e-04
I1  5.4624517  0.05489562  0.06484282  0.0014137736  1.329699e-03
I2  2.0548371  0.06789561  0.06131180 -0.0101388237  6.497384e-04
I3  5.2493376  0.04956186 -0.13545262 -0.0009542367  1.538358e-03
I4  2.3500761 -0.02387787 -0.04358019 -0.0219788021 -7.617512e-04
I5  6.1676725  0.11443053  0.13662089  0.0138601166 -1.702620e-03
S1 -2.7591660  0.15303854  0.02082993  0.0174828166  9.364276e-04
S2 -5.1138479  0.11043068  0.17339195  0.0031756663  2.072856e-03
S3 -0.7610574  0.05857255 -0.09673180 -0.0114601768 -3.204016e-04
S4 -2.2569762  0.14287958  0.03568940 -0.0083220594 -2.799926e-04
S5 -2.4721025  0.10331464 -0.20339687 -0.0021925741  4.204842e-04
S6 -1.8677409  0.03777313 -0.16921900 -0.0032347226 -1.347681e-03

$X.loadings
              Comp 1       Comp 2       Comp 3       Comp 4        Comp 5 
Acidity  0.0024821826 -0.982994981 -0.175555237 -0.052842114 -1.013788e-02
Peroxide 0.9978787778  0.013796830 -0.063602443  0.001523618 -6.597458e-06
K232     0.0649329859 -0.170385073  0.979855056 -0.080964283 -9.027094e-03
K270     0.0039224095 -0.066760251  0.070824063  0.992419845  7.492988e-02
DK       0.0003249415 -0.006520073  0.001763347 -0.075848699  9.970964e-01

$Y.hat
, , 1 Comps

     Yellow    Green     Brown   Glossy   Transp    Syrup
G1 52.16962 32.23309 11.691410 81.47764 78.98996 47.60187
G2 53.16871 31.24574 11.197630 81.99094 79.60442 47.31392
G3 57.98063 26.49035  8.819432 84.46318 82.56383 45.92705
G4 49.79847 34.57638 12.863301 80.25941 77.53167 48.28527
G5 55.83101 28.61472  9.881840 83.35876 81.24178 46.54660
I1 37.72443 46.50856 18.830657 74.05610 70.10593 51.76520
I2 45.92809 38.40129 14.776164 78.27091 75.15132 49.40078
I3 38.23749 46.00153 18.577087 74.31970 70.42148 51.61732
I4 45.21731 39.10371 15.127449 77.90574 74.71418 49.60563
I5 36.02665 48.18640 19.669752 73.18383 69.06177 52.25452
S1 57.51755 26.94799  9.048302 84.22526 82.27903 46.06052
S2 63.18632 21.34582  6.246623 87.13772 85.76542 44.42669
S3 52.70721 31.70182 11.425719 81.75384 79.32059 47.44693
S4 56.30855 28.14279  9.645825 83.60411 81.53547 46.40897
S5 56.82646 27.63097  9.389860 83.87020 81.85399 46.25970
S6 55.37149 29.06884 10.108950 83.12267 80.95916 46.67904

, , 2 Comps

     Yellow    Green     Brown   Glossy   Transp    Syrup
G1 27.35531 63.86887  8.938287 77.93588 72.71375 48.45234
G2 59.30596 23.42135 11.878552 82.86692 81.15670 47.10357
G3 59.29197 24.81853  8.964923 84.65035 82.89550 45.88210
G4 30.72715 58.89042 10.747357 77.53735 72.70802 48.93891
G5 44.64272 42.87868  8.640510 81.76185 78.41196 46.93006
I1 40.73327 42.67260 19.164484 74.48555 70.86695 51.66207
I2 49.64945 33.65692 15.189046 78.80207 76.09255 49.27323
I3 40.95398 42.53827 18.878479 74.70742 71.10855 51.52422
I4 43.90856 40.77224 14.982244 77.71894 74.38316 49.65049
I5 42.29860 40.19028 20.365619 74.07903 70.64812 52.03956
S1 65.90561 16.25405  9.978950 85.42249 84.40059 45.77303
S2 69.23904 13.62920  6.918167 88.00163 87.29631 44.21924
S3 55.91758 27.60892 11.781906 82.21206 80.13258 47.33690
S4 64.13980 18.15872 10.514694 84.72187 83.51621 46.14056
S5 62.48915 20.41160 10.018130 84.67844 83.28624 46.06562
S6 57.44184 26.42935 10.338653 83.41817 81.48281 46.60809


$B.pcr
, , 1 Comps

                Yellow        Green        Brown        Glossy       Transp
Acidity  -0.0059757255 0.0059055171 0.0029533835 -0.0030701635 -0.003675169
Peroxide -2.4023412894 2.3741163352 1.1873094083 -1.2342568911 -1.477479363
K232     -0.1563227885 0.1544861621 0.0772594295 -0.0803143499 -0.096141083
K270     -0.0094429970 0.0093320518 0.0046670135 -0.0048515522 -0.005807598
DK       -0.0007822799 0.0007730889 0.0003866263 -0.0004019139 -0.000481115
                Syrup
Acidity  0.0017222958
Peroxide 0.6923916080
K232     0.0450546254
K270     0.0027216166
DK       0.0002254651

, , 2 Comps

              Yellow      Green       Brown      Glossy       Transp      Syrup
Acidity  -53.8840610 68.6951139 -5.97476670 -7.69312592 -13.63090211 1.84830435
Peroxide  -1.6461352  1.4100286  1.27120972 -1.12632308  -1.28621436 0.66647390
K232      -9.4951512 12.0605650 -0.95887432 -1.41325169  -2.45818372 0.36512749
K270      -3.6685812  4.6743699 -0.40131074 -0.52712284  -0.93130276 0.12813251
DK        -0.3581483  0.4563793 -0.03926278 -0.05140901  -0.09086867 0.01247359

PLSbiplot1 documentation built on May 2, 2019, 9:41 a.m.