This function provides a predict method for the class "plsRmodel"

# S3 method for plsRmodel
predict(
  object,
  newdata,
  comps = object$computed_nt,
  type = c("response", "scores"),
  weights,
  methodNA = "adaptative",
  verbose = TRUE,
  ...
)

Arguments

object

An object of the class "plsRmodel".

newdata

An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used.

comps

A value with a single value of component to use for prediction.

type

Type of predicted value. Available choices are the response values ("response") or the scores ("scores").

weights

Vector of case weights. If weights is a vector of integers, then the estimated coefficients are equivalent to estimating the model from data with the individual cases replicated as many times as indicated by weights.

methodNA

Selects the way of predicting the response or the scores of the new data. For complete rows, without any missing value, there are two different ways of computing the prediction. As a consequence, for mixed datasets, with complete and incomplete rows, there are two ways of computing prediction : either predicts any row as if there were missing values in it (missingdata) or selects the prediction method accordingly to the completeness of the row (adaptative).

verbose

should info messages be displayed ?

...

Arguments to be passed on to plsRglm::plsR.

Value

When type is "response", a matrix of predicted response values is returned.
When type is "scores", a score matrix is returned.

References

Nicolas Meyer, Myriam Maumy-Bertrand et Frédéric Bertrand (2010). Comparing the linear and the logistic PLS regression with qualitative predictors: application to allelotyping data. Journal de la Societe Francaise de Statistique, 151(2), pages 1-18. http://publications-sfds.math.cnrs.fr/index.php/J-SFdS/article/view/47

Examples


data(pine)
Xpine<-pine[,1:10]
ypine<-pine[,11]
data(pine_sup)
Xpine_sup<-pine_sup[,1:10]
Xpine_supNA<-Xpine_sup
Xpine_supNA[1,1]<-NA

modpls=plsR(object=ypine,dataX=Xpine,nt=6,modele="pls", verbose=FALSE)
modplsform=plsR(x11~.,data=pine,nt=6,modele="pls", verbose=FALSE)
modpls2=plsR(object=ypine,dataX=Xpine,nt=6,modele="pls",dataPredictY=Xpine_sup, verbose=FALSE)
modpls2NA=plsR(object=ypine,dataX=Xpine,nt=6,modele="pls",dataPredictY=Xpine_supNA, verbose=FALSE)

#Identical to predict(modpls,type="response") or modpls$ValsPredictY
cbind(predict(modpls),predict(modplsform))
#>           [,1]        [,2]
#> 1   1.88550891  1.88550891
#> 2   1.20179188  1.20179188
#> 3   1.51671911  1.51671911
#> 4   1.04125064  1.04125064
#> 5   0.57134580  0.57134580
#> 6   1.39997555  1.39997555
#> 7  -0.11535438 -0.11535438
#> 8   0.32418945  0.32418945
#> 9   1.65007715  1.65007715
#> 10  0.94847153  0.94847153
#> 11  0.63882421  0.63882421
#> 12  0.98380367  0.98380367
#> 13  2.19486369  2.19486369
#> 14  1.90455582  1.90455582
#> 15  1.51027552  1.51027552
#> 16 -0.51351160 -0.51351160
#> 17  0.10574381  0.10574381
#> 18  0.78377367  0.78377367
#> 19  0.88040097  0.88040097
#> 20 -0.07763891 -0.07763891
#> 21  0.61594736  0.61594736
#> 22  0.71165796  0.71165796
#> 23  0.71111241  0.71111241
#> 24  0.27266379  0.27266379
#> 25 -0.04249364 -0.04249364
#> 26  0.67364464  0.67364464
#> 27  0.15754257  0.15754257
#> 28  0.90956750  0.90956750
#> 29  1.51049933  1.51049933
#> 30  0.42326984  0.42326984
#> 31  1.39942166  1.39942166
#> 32  0.55048739  0.55048739
#> 33  0.04161271  0.04161271

#Identical to modpls$ttPredictY
predict(modpls,type="scores")
#>        Comp_1      Comp_2       Comp_3       Comp_4      Comp_5       Comp_6
#> 1   2.9096976  1.64928263 -0.009483345  0.057956125 -1.46934378 -0.489598560
#> 2   0.7632932  0.53986261 -0.159129490  0.437277302 -0.17706329 -0.321853358
#> 3   2.5797729 -0.95827084  0.555733674  0.564062003 -0.87910500  0.284035643
#> 4   0.0443116 -0.73426297  1.346922821  0.343331779 -0.61503115  0.321925722
#> 5   0.8636609 -1.16804390 -0.764622885  0.093269712 -1.08357804  0.406014752
#> 6   2.0735510  0.19497416 -0.670208952  0.413100157 -0.18688067  0.313358700
#> 7  -1.8665241 -2.48962433  0.797691352 -0.120816072  0.24965976  0.473848359
#> 8  -0.3528084  0.04861907 -1.852562297  0.290984465  0.31452397 -0.838090240
#> 9   2.5760644  0.15055738  0.648675543 -0.250529134  0.91785586 -0.024983347
#> 10  0.7101307 -0.41831551  0.377690029 -0.377341589  1.50934893  0.005287361
#> 11 -1.4335481  1.66638440  0.456378669 -1.104406098 -0.44664111  0.207883485
#> 12 -3.3502270  1.31224504  1.417402888  1.104955312  1.55029102 -0.231379510
#> 13  3.6223851  0.52711545  0.931982918  0.263506207 -0.45209584  0.269206095
#> 14  2.1481736  1.27179987 -0.531059123  0.880856701  0.19746452  0.441259500
#> 15  1.8241923  0.37179819 -0.148615856  0.272375958  0.74396025  0.322278940
#> 16 -4.2769308 -0.60364703 -0.145483587  0.061124443 -0.07065661 -0.227489941
#> 17 -2.7842661  0.07795936 -0.502459829  0.582930183 -1.32991074  0.212595330
#> 18  0.8485036  0.40742891 -0.193547055 -0.711084310 -0.56678414 -0.654095817
#> 19  1.0268524 -1.55540630  0.267743180  0.304546989  0.88466538  0.011898270
#> 20 -2.0252326 -0.95493184 -0.296655275 -0.083369174  0.12999791 -0.220552715
#> 21 -2.9034527  0.76785147  1.198603055  0.659329630 -1.11470720 -0.353608888
#> 22 -0.6130182  0.01002519  0.509344060 -0.005358532 -0.61128002 -0.200778587
#> 23  0.3973956  0.13794708 -1.064862116 -0.089851072  0.79543645 -0.145976068
#> 24 -1.9919455 -0.11442060  0.306396644  0.130362294 -0.45181618 -0.644950290
#> 25 -0.9692387 -1.33933413 -1.514216201  0.419166401 -0.31389894 -0.126098495
#> 26  0.4320999  0.08330600 -0.734286784 -0.465917039  0.54059199  0.026669076
#> 27 -3.0186366  1.40703110 -0.783174430 -0.415481000 -1.00237524  1.266343581
#> 28  2.7834585 -1.59488217  0.077656351 -0.549262658 -0.86934018 -0.248831094
#> 29  2.4348733 -0.09247079  0.513378875 -0.284383041  0.63256561  0.139995140
#> 30 -0.3039968 -0.25883732  0.796456033 -1.182848400 -0.21148979 -0.558234302
#> 31  0.6490525  1.01235432 -0.442700445  0.584228984  1.60266786 -0.069695249
#> 32 -0.5424034  1.07847208 -0.113667400 -1.404961066  0.47606589  0.182674243
#> 33 -2.2552401 -0.43256657 -0.275321019 -0.417755460  1.30690250  0.470942265
predict(modplsform,type="scores")
#>        Comp_1      Comp_2       Comp_3       Comp_4      Comp_5       Comp_6
#> 1   2.9096976  1.64928263 -0.009483345  0.057956125 -1.46934378 -0.489598560
#> 2   0.7632932  0.53986261 -0.159129490  0.437277302 -0.17706329 -0.321853358
#> 3   2.5797729 -0.95827084  0.555733674  0.564062003 -0.87910500  0.284035643
#> 4   0.0443116 -0.73426297  1.346922821  0.343331779 -0.61503115  0.321925722
#> 5   0.8636609 -1.16804390 -0.764622885  0.093269712 -1.08357804  0.406014752
#> 6   2.0735510  0.19497416 -0.670208952  0.413100157 -0.18688067  0.313358700
#> 7  -1.8665241 -2.48962433  0.797691352 -0.120816072  0.24965976  0.473848359
#> 8  -0.3528084  0.04861907 -1.852562297  0.290984465  0.31452397 -0.838090240
#> 9   2.5760644  0.15055738  0.648675543 -0.250529134  0.91785586 -0.024983347
#> 10  0.7101307 -0.41831551  0.377690029 -0.377341589  1.50934893  0.005287361
#> 11 -1.4335481  1.66638440  0.456378669 -1.104406098 -0.44664111  0.207883485
#> 12 -3.3502270  1.31224504  1.417402888  1.104955312  1.55029102 -0.231379510
#> 13  3.6223851  0.52711545  0.931982918  0.263506207 -0.45209584  0.269206095
#> 14  2.1481736  1.27179987 -0.531059123  0.880856701  0.19746452  0.441259500
#> 15  1.8241923  0.37179819 -0.148615856  0.272375958  0.74396025  0.322278940
#> 16 -4.2769308 -0.60364703 -0.145483587  0.061124443 -0.07065661 -0.227489941
#> 17 -2.7842661  0.07795936 -0.502459829  0.582930183 -1.32991074  0.212595330
#> 18  0.8485036  0.40742891 -0.193547055 -0.711084310 -0.56678414 -0.654095817
#> 19  1.0268524 -1.55540630  0.267743180  0.304546989  0.88466538  0.011898270
#> 20 -2.0252326 -0.95493184 -0.296655275 -0.083369174  0.12999791 -0.220552715
#> 21 -2.9034527  0.76785147  1.198603055  0.659329630 -1.11470720 -0.353608888
#> 22 -0.6130182  0.01002519  0.509344060 -0.005358532 -0.61128002 -0.200778587
#> 23  0.3973956  0.13794708 -1.064862116 -0.089851072  0.79543645 -0.145976068
#> 24 -1.9919455 -0.11442060  0.306396644  0.130362294 -0.45181618 -0.644950290
#> 25 -0.9692387 -1.33933413 -1.514216201  0.419166401 -0.31389894 -0.126098495
#> 26  0.4320999  0.08330600 -0.734286784 -0.465917039  0.54059199  0.026669076
#> 27 -3.0186366  1.40703110 -0.783174430 -0.415481000 -1.00237524  1.266343581
#> 28  2.7834585 -1.59488217  0.077656351 -0.549262658 -0.86934018 -0.248831094
#> 29  2.4348733 -0.09247079  0.513378875 -0.284383041  0.63256561  0.139995140
#> 30 -0.3039968 -0.25883732  0.796456033 -1.182848400 -0.21148979 -0.558234302
#> 31  0.6490525  1.01235432 -0.442700445  0.584228984  1.60266786 -0.069695249
#> 32 -0.5424034  1.07847208 -0.113667400 -1.404961066  0.47606589  0.182674243
#> 33 -2.2552401 -0.43256657 -0.275321019 -0.417755460  1.30690250  0.470942265

# \donttest{
#Identical to modpls2$ValsPredictY
cbind(predict(modpls,newdata=Xpine_sup,type="response"),
predict(modplsform,newdata=Xpine_sup,type="response"))
#>            [,1]      [,2]
#>  [1,] 1.3129638 1.3129638
#>  [2,] 1.7388475 1.7388475
#>  [3,] 1.6763518 1.6763518
#>  [4,] 1.8099257 1.8099257
#>  [5,] 1.6200619 1.6200619
#>  [6,] 3.0575985 3.0575985
#>  [7,] 1.9649911 1.9649911
#>  [8,] 1.9619642 1.9619642
#>  [9,] 1.4752241 1.4752241
#> [10,] 2.0924149 2.0924149
#> [11,] 2.0100323 2.0100323
#> [12,] 2.3735435 2.3735435
#> [13,] 1.1905470 1.1905470
#> [14,] 0.9390483 0.9390483
#> [15,] 0.3599746 0.3599746
#> [16,] 0.5024583 0.5024583
#> [17,] 1.2330826 1.2330826
#> [18,] 1.2011370 1.2011370
#> [19,] 0.2350173 0.2350173
#> [20,] 0.8460029 0.8460029
#> [21,] 1.2946902 1.2946902
#> [22,] 0.3957882 0.3957882
#> [23,] 1.2468234 1.2468234
#> [24,] 0.4951827 0.4951827
#> [25,] 0.5538154 0.5538154

#Select the number of components to use to derive the prediction
predict(modpls,newdata=Xpine_sup,type="response",comps=1)    
#>            [,1]
#>  [1,] 0.4529386
#>  [2,] 1.5275250
#>  [3,] 0.8653393
#>  [4,] 1.2623019
#>  [5,] 1.2181767
#>  [6,] 0.5365724
#>  [7,] 1.8005533
#>  [8,] 1.4130804
#>  [9,] 1.3482246
#> [10,] 0.8525246
#> [11,] 1.4451515
#> [12,] 1.0083162
#> [13,] 0.1933256
#> [14,] 0.4868117
#> [15,] 0.2004471
#> [16,] 0.1145533
#> [17,] 0.6559225
#> [18,] 1.0049792
#> [19,] 0.4994408
#> [20,] 0.4326020
#> [21,] 0.8987432
#> [22,] 0.4734407
#> [23,] 1.0680659
#> [24,] 0.1914079
#> [25,] 0.6558292
predict(modpls,newdata=Xpine_sup,type="response",comps=3)    
#>            [,1]
#>  [1,] 1.3964152
#>  [2,] 1.3235411
#>  [3,] 1.1864009
#>  [4,] 1.5145135
#>  [5,] 1.1423259
#>  [6,] 2.1104660
#>  [7,] 2.1399449
#>  [8,] 1.6900978
#>  [9,] 1.3301024
#> [10,] 1.5686734
#> [11,] 2.0696493
#> [12,] 1.4845725
#> [13,] 0.9158598
#> [14,] 0.6998484
#> [15,] 0.4447477
#> [16,] 0.3612035
#> [17,] 1.2314589
#> [18,] 1.3030724
#> [19,] 0.6100443
#> [20,] 0.6747087
#> [21,] 1.5231209
#> [22,] 0.3475253
#> [23,] 1.4135977
#> [24,] 0.1426153
#> [25,] 0.3905439
predict(modpls,newdata=Xpine_sup,type="response",comps=6)    
#>            [,1]
#>  [1,] 1.3129638
#>  [2,] 1.7388475
#>  [3,] 1.6763518
#>  [4,] 1.8099257
#>  [5,] 1.6200619
#>  [6,] 3.0575985
#>  [7,] 1.9649911
#>  [8,] 1.9619642
#>  [9,] 1.4752241
#> [10,] 2.0924149
#> [11,] 2.0100323
#> [12,] 2.3735435
#> [13,] 1.1905470
#> [14,] 0.9390483
#> [15,] 0.3599746
#> [16,] 0.5024583
#> [17,] 1.2330826
#> [18,] 1.2011370
#> [19,] 0.2350173
#> [20,] 0.8460029
#> [21,] 1.2946902
#> [22,] 0.3957882
#> [23,] 1.2468234
#> [24,] 0.4951827
#> [25,] 0.5538154
try(predict(modpls,newdata=Xpine_sup,type="response",comps=8))
#> Error in predict.plsRmodel(modpls, newdata = Xpine_sup, type = "response",  : 
#>   Cannot predict using more components than extracted.

#Identical to modpls2$ttValsPredictY
predict(modpls,newdata=Xpine_sup,type="scores")    
#>           Comp_1       Comp_2      Comp_3       Comp_4      Comp_5       Comp_6
#>  [1,] -1.3617679  2.993459769  0.73427739  0.452953573 -1.11579015 -1.473542293
#>  [2,]  2.7226457 -1.448207417  0.75220272  1.097297569  0.53631331  0.559682133
#>  [3,]  0.2057330 -0.065699548  1.48307730  1.608813107  0.19908226  0.005584384
#>  [4,]  1.7145547  0.999997451 -0.03091563  0.968262496 -0.09309405  0.121080636
#>  [5,]  1.5468388 -0.962223763  0.76157621  1.426096569  0.06539057  0.474713635
#>  [6,] -1.0438828  5.067110560  1.14136095  2.864592446  1.68207458  0.014847912
#>  [7,]  3.7604036  1.284021688  0.02849577  0.004909657 -3.03776558 -0.062192479
#>  [8,]  2.2876515  0.199824399  0.98790364  0.944924320 -0.59601659  0.230003786
#>  [9,]  2.0411399  0.238406080 -0.35062475  0.558516943  0.19675157 -0.301893947
#> [10,]  0.1570251  1.504717841  1.43017861  1.564536266  0.14708601  0.477418245
#> [11,]  2.4095509  1.155533043  1.42525994  0.452142174 -2.83846498 -0.334252057
#> [12,]  0.7491762  3.052072375 -1.38187603  2.282056699  2.18543478  0.836814768
#> [13,] -2.3485356  0.216703031  2.92300006  0.685183103  0.15356406  0.590760027
#> [14,] -1.2330191  0.008574545  0.92474943  0.312313976  1.39640033  0.646248390
#> [15,] -2.3214673  0.108405764  0.94835654  0.484159548  0.27324060 -2.308760250
#> [16,] -2.6479422  0.291815002  0.75007834  0.717778190  0.67224455 -1.038074446
#> [17,] -0.5902429  1.554635840  0.75660189  0.131428359 -0.44100984 -0.121010721
#> [18,]  0.7364927  0.699547511  0.51203773 -0.265761130 -0.22924277 -0.095761547
#> [19,] -1.1850170  0.300466200  0.14346126 -1.526977483  0.06869875  0.710089752
#> [20,] -1.4390656 -0.147557539  1.22983008  0.341807486  0.21492515  0.545779712
#> [21,]  0.3326983  1.459383292  1.07917521 -0.766536942 -0.26974278  0.137300450
#> [22,] -1.2838413  0.228232572 -0.81189728  0.112113284  1.24971859 -0.519868578
#> [23,]  0.9762797  0.792728055  0.61416007 -0.026280577 -1.58598821 -0.665173114
#> [24,] -2.3558246 -1.146802277  1.09018353  0.784478257  1.20560305  0.491817441
#> [25,] -0.5905978 -0.284407470 -0.84024689  0.182976076  1.35912630  0.311267458

#Select the number of components in the scores matrix
predict(modpls,newdata=Xpine_sup,type="scores",comps=1)    
#>           Comp_1
#>  [1,] -1.3617679
#>  [2,]  2.7226457
#>  [3,]  0.2057330
#>  [4,]  1.7145547
#>  [5,]  1.5468388
#>  [6,] -1.0438828
#>  [7,]  3.7604036
#>  [8,]  2.2876515
#>  [9,]  2.0411399
#> [10,]  0.1570251
#> [11,]  2.4095509
#> [12,]  0.7491762
#> [13,] -2.3485356
#> [14,] -1.2330191
#> [15,] -2.3214673
#> [16,] -2.6479422
#> [17,] -0.5902429
#> [18,]  0.7364927
#> [19,] -1.1850170
#> [20,] -1.4390656
#> [21,]  0.3326983
#> [22,] -1.2838413
#> [23,]  0.9762797
#> [24,] -2.3558246
#> [25,] -0.5905978
predict(modpls,newdata=Xpine_sup,type="scores",comps=3)    
#>           Comp_1       Comp_2      Comp_3
#>  [1,] -1.3617679  2.993459769  0.73427739
#>  [2,]  2.7226457 -1.448207417  0.75220272
#>  [3,]  0.2057330 -0.065699548  1.48307730
#>  [4,]  1.7145547  0.999997451 -0.03091563
#>  [5,]  1.5468388 -0.962223763  0.76157621
#>  [6,] -1.0438828  5.067110560  1.14136095
#>  [7,]  3.7604036  1.284021688  0.02849577
#>  [8,]  2.2876515  0.199824399  0.98790364
#>  [9,]  2.0411399  0.238406080 -0.35062475
#> [10,]  0.1570251  1.504717841  1.43017861
#> [11,]  2.4095509  1.155533043  1.42525994
#> [12,]  0.7491762  3.052072375 -1.38187603
#> [13,] -2.3485356  0.216703031  2.92300006
#> [14,] -1.2330191  0.008574545  0.92474943
#> [15,] -2.3214673  0.108405764  0.94835654
#> [16,] -2.6479422  0.291815002  0.75007834
#> [17,] -0.5902429  1.554635840  0.75660189
#> [18,]  0.7364927  0.699547511  0.51203773
#> [19,] -1.1850170  0.300466200  0.14346126
#> [20,] -1.4390656 -0.147557539  1.22983008
#> [21,]  0.3326983  1.459383292  1.07917521
#> [22,] -1.2838413  0.228232572 -0.81189728
#> [23,]  0.9762797  0.792728055  0.61416007
#> [24,] -2.3558246 -1.146802277  1.09018353
#> [25,] -0.5905978 -0.284407470 -0.84024689
predict(modpls,newdata=Xpine_sup,type="scores",comps=6)    
#>           Comp_1       Comp_2      Comp_3       Comp_4      Comp_5       Comp_6
#>  [1,] -1.3617679  2.993459769  0.73427739  0.452953573 -1.11579015 -1.473542293
#>  [2,]  2.7226457 -1.448207417  0.75220272  1.097297569  0.53631331  0.559682133
#>  [3,]  0.2057330 -0.065699548  1.48307730  1.608813107  0.19908226  0.005584384
#>  [4,]  1.7145547  0.999997451 -0.03091563  0.968262496 -0.09309405  0.121080636
#>  [5,]  1.5468388 -0.962223763  0.76157621  1.426096569  0.06539057  0.474713635
#>  [6,] -1.0438828  5.067110560  1.14136095  2.864592446  1.68207458  0.014847912
#>  [7,]  3.7604036  1.284021688  0.02849577  0.004909657 -3.03776558 -0.062192479
#>  [8,]  2.2876515  0.199824399  0.98790364  0.944924320 -0.59601659  0.230003786
#>  [9,]  2.0411399  0.238406080 -0.35062475  0.558516943  0.19675157 -0.301893947
#> [10,]  0.1570251  1.504717841  1.43017861  1.564536266  0.14708601  0.477418245
#> [11,]  2.4095509  1.155533043  1.42525994  0.452142174 -2.83846498 -0.334252057
#> [12,]  0.7491762  3.052072375 -1.38187603  2.282056699  2.18543478  0.836814768
#> [13,] -2.3485356  0.216703031  2.92300006  0.685183103  0.15356406  0.590760027
#> [14,] -1.2330191  0.008574545  0.92474943  0.312313976  1.39640033  0.646248390
#> [15,] -2.3214673  0.108405764  0.94835654  0.484159548  0.27324060 -2.308760250
#> [16,] -2.6479422  0.291815002  0.75007834  0.717778190  0.67224455 -1.038074446
#> [17,] -0.5902429  1.554635840  0.75660189  0.131428359 -0.44100984 -0.121010721
#> [18,]  0.7364927  0.699547511  0.51203773 -0.265761130 -0.22924277 -0.095761547
#> [19,] -1.1850170  0.300466200  0.14346126 -1.526977483  0.06869875  0.710089752
#> [20,] -1.4390656 -0.147557539  1.22983008  0.341807486  0.21492515  0.545779712
#> [21,]  0.3326983  1.459383292  1.07917521 -0.766536942 -0.26974278  0.137300450
#> [22,] -1.2838413  0.228232572 -0.81189728  0.112113284  1.24971859 -0.519868578
#> [23,]  0.9762797  0.792728055  0.61416007 -0.026280577 -1.58598821 -0.665173114
#> [24,] -2.3558246 -1.146802277  1.09018353  0.784478257  1.20560305  0.491817441
#> [25,] -0.5905978 -0.284407470 -0.84024689  0.182976076  1.35912630  0.311267458
try(predict(modpls,newdata=Xpine_sup,type="scores",comps=8))
#> Error in predict.plsRmodel(modpls, newdata = Xpine_sup, type = "scores",  : 
#>   Cannot predict using more components than extracted.

#Identical to modpls2NA$ValsPredictY
predict(modpls,newdata=Xpine_supNA,type="response",methodNA="missingdata")    
#> Prediction as if missing values in every row.
#>             [,1]
#>  [1,] -0.4380246
#>  [2,]  1.7274179
#>  [3,]  1.7531622
#>  [4,]  1.8064674
#>  [5,]  1.6641257
#>  [6,]  3.1037177
#>  [7,]  1.8996680
#>  [8,]  1.9915726
#>  [9,]  1.3431573
#> [10,]  2.0567726
#> [11,]  1.9113526
#> [12,]  2.5555213
#> [13,]  1.1747931
#> [14,]  0.9143911
#> [15,]  0.6401136
#> [16,]  0.5709883
#> [17,]  1.4171363
#> [18,]  1.3099823
#> [19,]  0.1209765
#> [20,]  0.8630320
#> [21,]  1.3182253
#> [22,]  0.3658273
#> [23,]  1.2252369
#> [24,]  0.5737034
#> [25,]  0.6736099

cbind(predict(modpls,newdata=Xpine_supNA,type="response"),
predict(modplsform,newdata=Xpine_supNA,type="response"))
#> Missing value in row  1 .
#> Missing value in row  1 .
#>             [,1]       [,2]
#>  [1,] -0.4380246 -0.4380246
#>  [2,]  1.7388475  1.7388475
#>  [3,]  1.6763518  1.6763518
#>  [4,]  1.8099257  1.8099257
#>  [5,]  1.6200619  1.6200619
#>  [6,]  3.0575985  3.0575985
#>  [7,]  1.9649911  1.9649911
#>  [8,]  1.9619642  1.9619642
#>  [9,]  1.4752241  1.4752241
#> [10,]  2.0924149  2.0924149
#> [11,]  2.0100323  2.0100323
#> [12,]  2.3735435  2.3735435
#> [13,]  1.1905470  1.1905470
#> [14,]  0.9390483  0.9390483
#> [15,]  0.3599746  0.3599746
#> [16,]  0.5024583  0.5024583
#> [17,]  1.2330826  1.2330826
#> [18,]  1.2011370  1.2011370
#> [19,]  0.2350173  0.2350173
#> [20,]  0.8460029  0.8460029
#> [21,]  1.2946902  1.2946902
#> [22,]  0.3957882  0.3957882
#> [23,]  1.2468234  1.2468234
#> [24,]  0.4951827  0.4951827
#> [25,]  0.5538154  0.5538154

predict(modpls,newdata=Xpine_supNA,type="response",comps=1)    
#> Missing value in row  1 .
#>             [,1]
#>  [1,] 0.01262359
#>  [2,] 1.52752498
#>  [3,] 0.86533931
#>  [4,] 1.26230188
#>  [5,] 1.21817675
#>  [6,] 0.53657240
#>  [7,] 1.80055327
#>  [8,] 1.41308042
#>  [9,] 1.34822461
#> [10,] 0.85252455
#> [11,] 1.44515149
#> [12,] 1.00831620
#> [13,] 0.19332555
#> [14,] 0.48681169
#> [15,] 0.20044706
#> [16,] 0.11455334
#> [17,] 0.65592253
#> [18,] 1.00497922
#> [19,] 0.49944077
#> [20,] 0.43260202
#> [21,] 0.89874319
#> [22,] 0.47344065
#> [23,] 1.06806585
#> [24,] 0.19140786
#> [25,] 0.65582915
predict(modpls,newdata=Xpine_supNA,type="response",comps=3)    
#> Missing value in row  1 .
#>                [,1]
#>  [1,] -0.0001503207
#>  [2,]  1.3235411249
#>  [3,]  1.1864008651
#>  [4,]  1.5145134877
#>  [5,]  1.1423259016
#>  [6,]  2.1104660488
#>  [7,]  2.1399449414
#>  [8,]  1.6900977631
#>  [9,]  1.3301024082
#> [10,]  1.5686733743
#> [11,]  2.0696493364
#> [12,]  1.4845725327
#> [13,]  0.9158597617
#> [14,]  0.6998484111
#> [15,]  0.4447477116
#> [16,]  0.3612034996
#> [17,]  1.2314588588
#> [18,]  1.3030723893
#> [19,]  0.6100442895
#> [20,]  0.6747086944
#> [21,]  1.5231208749
#> [22,]  0.3475252821
#> [23,]  1.4135976883
#> [24,]  0.1426152740
#> [25,]  0.3905438807
predict(modpls,newdata=Xpine_supNA,type="response",comps=6)    
#> Missing value in row  1 .
#>             [,1]
#>  [1,] -0.4380246
#>  [2,]  1.7388475
#>  [3,]  1.6763518
#>  [4,]  1.8099257
#>  [5,]  1.6200619
#>  [6,]  3.0575985
#>  [7,]  1.9649911
#>  [8,]  1.9619642
#>  [9,]  1.4752241
#> [10,]  2.0924149
#> [11,]  2.0100323
#> [12,]  2.3735435
#> [13,]  1.1905470
#> [14,]  0.9390483
#> [15,]  0.3599746
#> [16,]  0.5024583
#> [17,]  1.2330826
#> [18,]  1.2011370
#> [19,]  0.2350173
#> [20,]  0.8460029
#> [21,]  1.2946902
#> [22,]  0.3957882
#> [23,]  1.2468234
#> [24,]  0.4951827
#> [25,]  0.5538154
try(predict(modpls,newdata=Xpine_supNA,type="response",comps=8))
#> Error in predict.plsRmodel(modpls, newdata = Xpine_supNA, type = "response",  : 
#>   Cannot predict using more components than extracted.

#Identical to modpls2NA$ttPredictY
predict(modpls,newdata=Xpine_supNA,type="scores",methodNA="missingdata")
#> Prediction as if missing values in every row.
#>           Comp_1       Comp_2       Comp_3      Comp_4      Comp_5     Comp_6
#>  [1,] -3.0353687  0.987755634 -1.179371542 -0.19743715 -3.30898182 -1.8375844
#>  [2,]  2.7220756 -1.450870839  0.745991000  1.08616889  0.51576986  0.5150498
#>  [3,]  0.2095646 -0.047800552  1.524821925  1.68360118  0.33714044  0.3055271
#>  [4,]  1.7143822  0.999191584 -0.032795102  0.96489531 -0.09930985  0.1075763
#>  [5,]  1.5490368 -0.951955668  0.785523797  1.46900015  0.14459023  0.6467814
#>  [6,] -1.0415822  5.077857636  1.166425636  2.90949737  1.76496872  0.1949422
#>  [7,]  3.7571450  1.268799569 -0.007005749 -0.05869351 -3.15517652 -0.3172774
#>  [8,]  2.2891284  0.206724001  1.003995120  0.97375319 -0.54279872  0.3456240
#>  [9,]  2.0345518  0.207630787 -0.422399890  0.42992734 -0.04062381 -0.8176114
#> [10,]  0.1552471  1.496412167  1.410807841  1.52983235  0.08302285  0.3382358
#> [11,]  2.4046283  1.132537890  1.371629890  0.35606063 -3.01583074 -0.7195937
#> [12,]  0.7582541  3.094478343 -1.282975446  2.45924320  2.51251965  1.5474334
#> [13,] -2.3493214  0.213031935  2.914438207  0.66984402  0.12524823  0.5292416
#> [14,] -1.2342491  0.002828718  0.911348819  0.28830596  1.35208173  0.5499626
#> [15,] -2.3074928  0.173686077  1.100605419  0.75692282  0.77675941 -1.2148245
#> [16,] -2.6445236  0.307784429  0.787322756  0.78450387  0.79541961 -0.7704665
#> [17,] -0.5810615  1.597525542  0.856630655  0.31063607 -0.11019384  0.5977141
#> [18,]  0.7419223  0.724911543  0.571192552 -0.15978161 -0.03360542  0.3292766
#> [19,] -1.1907059  0.273891474  0.081482816 -1.63801569 -0.13627690  0.2647634
#> [20,] -1.4382161 -0.143589272  1.239085007  0.35838825  0.24553311  0.6122780
#> [21,]  0.3338724  1.464867644  1.091965992 -0.74362146 -0.22744099  0.2292046
#> [22,] -1.2853359  0.221250834 -0.828180315  0.08294122  1.19586719 -0.6368651
#> [23,]  0.9752029  0.787697790  0.602428320 -0.04729873 -1.62478755 -0.7494679
#> [24,] -2.3519076 -1.128504742  1.132857643  0.86093156  1.34673523  0.7984386
#> [25,] -0.5846219 -0.256491971 -0.775141451  0.29961649  1.57444357  0.7790618
predict(modplsform,newdata=Xpine_supNA,type="scores",methodNA="missingdata")
#> Prediction as if missing values in every row.
#>           Comp_1       Comp_2       Comp_3      Comp_4      Comp_5     Comp_6
#>  [1,] -3.0353687  0.987755634 -1.179371542 -0.19743715 -3.30898182 -1.8375844
#>  [2,]  2.7220756 -1.450870839  0.745991000  1.08616889  0.51576986  0.5150498
#>  [3,]  0.2095646 -0.047800552  1.524821925  1.68360118  0.33714044  0.3055271
#>  [4,]  1.7143822  0.999191584 -0.032795102  0.96489531 -0.09930985  0.1075763
#>  [5,]  1.5490368 -0.951955668  0.785523797  1.46900015  0.14459023  0.6467814
#>  [6,] -1.0415822  5.077857636  1.166425636  2.90949737  1.76496872  0.1949422
#>  [7,]  3.7571450  1.268799569 -0.007005749 -0.05869351 -3.15517652 -0.3172774
#>  [8,]  2.2891284  0.206724001  1.003995120  0.97375319 -0.54279872  0.3456240
#>  [9,]  2.0345518  0.207630787 -0.422399890  0.42992734 -0.04062381 -0.8176114
#> [10,]  0.1552471  1.496412167  1.410807841  1.52983235  0.08302285  0.3382358
#> [11,]  2.4046283  1.132537890  1.371629890  0.35606063 -3.01583074 -0.7195937
#> [12,]  0.7582541  3.094478343 -1.282975446  2.45924320  2.51251965  1.5474334
#> [13,] -2.3493214  0.213031935  2.914438207  0.66984402  0.12524823  0.5292416
#> [14,] -1.2342491  0.002828718  0.911348819  0.28830596  1.35208173  0.5499626
#> [15,] -2.3074928  0.173686077  1.100605419  0.75692282  0.77675941 -1.2148245
#> [16,] -2.6445236  0.307784429  0.787322756  0.78450387  0.79541961 -0.7704665
#> [17,] -0.5810615  1.597525542  0.856630655  0.31063607 -0.11019384  0.5977141
#> [18,]  0.7419223  0.724911543  0.571192552 -0.15978161 -0.03360542  0.3292766
#> [19,] -1.1907059  0.273891474  0.081482816 -1.63801569 -0.13627690  0.2647634
#> [20,] -1.4382161 -0.143589272  1.239085007  0.35838825  0.24553311  0.6122780
#> [21,]  0.3338724  1.464867644  1.091965992 -0.74362146 -0.22744099  0.2292046
#> [22,] -1.2853359  0.221250834 -0.828180315  0.08294122  1.19586719 -0.6368651
#> [23,]  0.9752029  0.787697790  0.602428320 -0.04729873 -1.62478755 -0.7494679
#> [24,] -2.3519076 -1.128504742  1.132857643  0.86093156  1.34673523  0.7984386
#> [25,] -0.5846219 -0.256491971 -0.775141451  0.29961649  1.57444357  0.7790618

predict(modpls,newdata=Xpine_supNA,type="scores")    
#> Missing value in row  1 .
#>           Comp_1       Comp_2      Comp_3       Comp_4      Comp_5       Comp_6
#>  [1,] -3.0353687  0.987755634 -1.17937154 -0.197437151 -3.30898182 -1.837584434
#>  [2,]  2.7226457 -1.448207417  0.75220272  1.097297569  0.53631331  0.559682133
#>  [3,]  0.2057330 -0.065699548  1.48307730  1.608813107  0.19908226  0.005584384
#>  [4,]  1.7145547  0.999997451 -0.03091563  0.968262496 -0.09309405  0.121080636
#>  [5,]  1.5468388 -0.962223763  0.76157621  1.426096569  0.06539057  0.474713635
#>  [6,] -1.0438828  5.067110560  1.14136095  2.864592446  1.68207458  0.014847912
#>  [7,]  3.7604036  1.284021688  0.02849577  0.004909657 -3.03776558 -0.062192479
#>  [8,]  2.2876515  0.199824399  0.98790364  0.944924320 -0.59601659  0.230003786
#>  [9,]  2.0411399  0.238406080 -0.35062475  0.558516943  0.19675157 -0.301893947
#> [10,]  0.1570251  1.504717841  1.43017861  1.564536266  0.14708601  0.477418245
#> [11,]  2.4095509  1.155533043  1.42525994  0.452142174 -2.83846498 -0.334252057
#> [12,]  0.7491762  3.052072375 -1.38187603  2.282056699  2.18543478  0.836814768
#> [13,] -2.3485356  0.216703031  2.92300006  0.685183103  0.15356406  0.590760027
#> [14,] -1.2330191  0.008574545  0.92474943  0.312313976  1.39640033  0.646248390
#> [15,] -2.3214673  0.108405764  0.94835654  0.484159548  0.27324060 -2.308760250
#> [16,] -2.6479422  0.291815002  0.75007834  0.717778190  0.67224455 -1.038074446
#> [17,] -0.5902429  1.554635840  0.75660189  0.131428359 -0.44100984 -0.121010721
#> [18,]  0.7364927  0.699547511  0.51203773 -0.265761130 -0.22924277 -0.095761547
#> [19,] -1.1850170  0.300466200  0.14346126 -1.526977483  0.06869875  0.710089752
#> [20,] -1.4390656 -0.147557539  1.22983008  0.341807486  0.21492515  0.545779712
#> [21,]  0.3326983  1.459383292  1.07917521 -0.766536942 -0.26974278  0.137300450
#> [22,] -1.2838413  0.228232572 -0.81189728  0.112113284  1.24971859 -0.519868578
#> [23,]  0.9762797  0.792728055  0.61416007 -0.026280577 -1.58598821 -0.665173114
#> [24,] -2.3558246 -1.146802277  1.09018353  0.784478257  1.20560305  0.491817441
#> [25,] -0.5905978 -0.284407470 -0.84024689  0.182976076  1.35912630  0.311267458
predict(modplsform,newdata=Xpine_supNA,type="scores")    
#> Missing value in row  1 .
#>           Comp_1       Comp_2      Comp_3       Comp_4      Comp_5       Comp_6
#>  [1,] -3.0353687  0.987755634 -1.17937154 -0.197437151 -3.30898182 -1.837584434
#>  [2,]  2.7226457 -1.448207417  0.75220272  1.097297569  0.53631331  0.559682133
#>  [3,]  0.2057330 -0.065699548  1.48307730  1.608813107  0.19908226  0.005584384
#>  [4,]  1.7145547  0.999997451 -0.03091563  0.968262496 -0.09309405  0.121080636
#>  [5,]  1.5468388 -0.962223763  0.76157621  1.426096569  0.06539057  0.474713635
#>  [6,] -1.0438828  5.067110560  1.14136095  2.864592446  1.68207458  0.014847912
#>  [7,]  3.7604036  1.284021688  0.02849577  0.004909657 -3.03776558 -0.062192479
#>  [8,]  2.2876515  0.199824399  0.98790364  0.944924320 -0.59601659  0.230003786
#>  [9,]  2.0411399  0.238406080 -0.35062475  0.558516943  0.19675157 -0.301893947
#> [10,]  0.1570251  1.504717841  1.43017861  1.564536266  0.14708601  0.477418245
#> [11,]  2.4095509  1.155533043  1.42525994  0.452142174 -2.83846498 -0.334252057
#> [12,]  0.7491762  3.052072375 -1.38187603  2.282056699  2.18543478  0.836814768
#> [13,] -2.3485356  0.216703031  2.92300006  0.685183103  0.15356406  0.590760027
#> [14,] -1.2330191  0.008574545  0.92474943  0.312313976  1.39640033  0.646248390
#> [15,] -2.3214673  0.108405764  0.94835654  0.484159548  0.27324060 -2.308760250
#> [16,] -2.6479422  0.291815002  0.75007834  0.717778190  0.67224455 -1.038074446
#> [17,] -0.5902429  1.554635840  0.75660189  0.131428359 -0.44100984 -0.121010721
#> [18,]  0.7364927  0.699547511  0.51203773 -0.265761130 -0.22924277 -0.095761547
#> [19,] -1.1850170  0.300466200  0.14346126 -1.526977483  0.06869875  0.710089752
#> [20,] -1.4390656 -0.147557539  1.22983008  0.341807486  0.21492515  0.545779712
#> [21,]  0.3326983  1.459383292  1.07917521 -0.766536942 -0.26974278  0.137300450
#> [22,] -1.2838413  0.228232572 -0.81189728  0.112113284  1.24971859 -0.519868578
#> [23,]  0.9762797  0.792728055  0.61416007 -0.026280577 -1.58598821 -0.665173114
#> [24,] -2.3558246 -1.146802277  1.09018353  0.784478257  1.20560305  0.491817441
#> [25,] -0.5905978 -0.284407470 -0.84024689  0.182976076  1.35912630  0.311267458
predict(modpls,newdata=Xpine_supNA,type="scores",comps=1)    
#> Missing value in row  1 .
#>           Comp_1
#>  [1,] -3.0353687
#>  [2,]  2.7226457
#>  [3,]  0.2057330
#>  [4,]  1.7145547
#>  [5,]  1.5468388
#>  [6,] -1.0438828
#>  [7,]  3.7604036
#>  [8,]  2.2876515
#>  [9,]  2.0411399
#> [10,]  0.1570251
#> [11,]  2.4095509
#> [12,]  0.7491762
#> [13,] -2.3485356
#> [14,] -1.2330191
#> [15,] -2.3214673
#> [16,] -2.6479422
#> [17,] -0.5902429
#> [18,]  0.7364927
#> [19,] -1.1850170
#> [20,] -1.4390656
#> [21,]  0.3326983
#> [22,] -1.2838413
#> [23,]  0.9762797
#> [24,] -2.3558246
#> [25,] -0.5905978
predict(modpls,newdata=Xpine_supNA,type="scores",comps=3)    
#> Missing value in row  1 .
#>           Comp_1       Comp_2      Comp_3
#>  [1,] -3.0353687  0.987755634 -1.17937154
#>  [2,]  2.7226457 -1.448207417  0.75220272
#>  [3,]  0.2057330 -0.065699548  1.48307730
#>  [4,]  1.7145547  0.999997451 -0.03091563
#>  [5,]  1.5468388 -0.962223763  0.76157621
#>  [6,] -1.0438828  5.067110560  1.14136095
#>  [7,]  3.7604036  1.284021688  0.02849577
#>  [8,]  2.2876515  0.199824399  0.98790364
#>  [9,]  2.0411399  0.238406080 -0.35062475
#> [10,]  0.1570251  1.504717841  1.43017861
#> [11,]  2.4095509  1.155533043  1.42525994
#> [12,]  0.7491762  3.052072375 -1.38187603
#> [13,] -2.3485356  0.216703031  2.92300006
#> [14,] -1.2330191  0.008574545  0.92474943
#> [15,] -2.3214673  0.108405764  0.94835654
#> [16,] -2.6479422  0.291815002  0.75007834
#> [17,] -0.5902429  1.554635840  0.75660189
#> [18,]  0.7364927  0.699547511  0.51203773
#> [19,] -1.1850170  0.300466200  0.14346126
#> [20,] -1.4390656 -0.147557539  1.22983008
#> [21,]  0.3326983  1.459383292  1.07917521
#> [22,] -1.2838413  0.228232572 -0.81189728
#> [23,]  0.9762797  0.792728055  0.61416007
#> [24,] -2.3558246 -1.146802277  1.09018353
#> [25,] -0.5905978 -0.284407470 -0.84024689
predict(modpls,newdata=Xpine_supNA,type="scores",comps=6)    
#> Missing value in row  1 .
#>           Comp_1       Comp_2      Comp_3       Comp_4      Comp_5       Comp_6
#>  [1,] -3.0353687  0.987755634 -1.17937154 -0.197437151 -3.30898182 -1.837584434
#>  [2,]  2.7226457 -1.448207417  0.75220272  1.097297569  0.53631331  0.559682133
#>  [3,]  0.2057330 -0.065699548  1.48307730  1.608813107  0.19908226  0.005584384
#>  [4,]  1.7145547  0.999997451 -0.03091563  0.968262496 -0.09309405  0.121080636
#>  [5,]  1.5468388 -0.962223763  0.76157621  1.426096569  0.06539057  0.474713635
#>  [6,] -1.0438828  5.067110560  1.14136095  2.864592446  1.68207458  0.014847912
#>  [7,]  3.7604036  1.284021688  0.02849577  0.004909657 -3.03776558 -0.062192479
#>  [8,]  2.2876515  0.199824399  0.98790364  0.944924320 -0.59601659  0.230003786
#>  [9,]  2.0411399  0.238406080 -0.35062475  0.558516943  0.19675157 -0.301893947
#> [10,]  0.1570251  1.504717841  1.43017861  1.564536266  0.14708601  0.477418245
#> [11,]  2.4095509  1.155533043  1.42525994  0.452142174 -2.83846498 -0.334252057
#> [12,]  0.7491762  3.052072375 -1.38187603  2.282056699  2.18543478  0.836814768
#> [13,] -2.3485356  0.216703031  2.92300006  0.685183103  0.15356406  0.590760027
#> [14,] -1.2330191  0.008574545  0.92474943  0.312313976  1.39640033  0.646248390
#> [15,] -2.3214673  0.108405764  0.94835654  0.484159548  0.27324060 -2.308760250
#> [16,] -2.6479422  0.291815002  0.75007834  0.717778190  0.67224455 -1.038074446
#> [17,] -0.5902429  1.554635840  0.75660189  0.131428359 -0.44100984 -0.121010721
#> [18,]  0.7364927  0.699547511  0.51203773 -0.265761130 -0.22924277 -0.095761547
#> [19,] -1.1850170  0.300466200  0.14346126 -1.526977483  0.06869875  0.710089752
#> [20,] -1.4390656 -0.147557539  1.22983008  0.341807486  0.21492515  0.545779712
#> [21,]  0.3326983  1.459383292  1.07917521 -0.766536942 -0.26974278  0.137300450
#> [22,] -1.2838413  0.228232572 -0.81189728  0.112113284  1.24971859 -0.519868578
#> [23,]  0.9762797  0.792728055  0.61416007 -0.026280577 -1.58598821 -0.665173114
#> [24,] -2.3558246 -1.146802277  1.09018353  0.784478257  1.20560305  0.491817441
#> [25,] -0.5905978 -0.284407470 -0.84024689  0.182976076  1.35912630  0.311267458
try(predict(modpls,newdata=Xpine_supNA,type="scores",comps=8))
#> Error in predict.plsRmodel(modpls, newdata = Xpine_supNA, type = "scores",  : 
#>   Cannot predict using more components than extracted.
# }