For selecting the right amount of penalization, however, k-fold cross validation should be performed over a fine grid of (many) sensible values \(\lambda\). Due to time-consuming computation and undesireably high dimensions of outputs, we recommend to set the default CVfit = FALSE. By doing so, the function only stores VAF values for both the training set and the validation set.
In addiction, the function provides the option of both non-monotone effects and incorporating constraints enforcing monotonicity, specified by the logical argument constr. For the ehd data the assumption of monotonic effects seems reasonable.
lambda <- 10^seq(4, -4, by = -0.1)
set.seed(456)
ehd_CV_p2 <- ordPCA(H, p = 2, lambda = lambda, maxit = 100, crit = 1e-7, Ks = apply(H, 2, max),
                   qstart = NULL, constr = rep(TRUE, ncol(H)), CV = TRUE, k = 5, CVfit = FALSE)
lam_p2 <- (lambda)[which.max(apply(ehd_CV_p2$VAFtest,2,mean))]
ehd_CV_p2$VAFtest
#>           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#> [1,] 0.4562018 0.4562027 0.4562039 0.4562054 0.4562072 0.4562095 0.4562124
#> [2,] 0.4763869 0.4763883 0.4763901 0.4763923 0.4763950 0.4763985 0.4764029
#> [3,] 0.4465576 0.4465585 0.4465597 0.4465611 0.4465630 0.4465653 0.4465682
#> [4,] 0.5237630 0.5237643 0.5237659 0.5237678 0.5237703 0.5237734 0.5237774
#> [5,] 0.4730329 0.4730340 0.4730354 0.4730371 0.4730393 0.4730420 0.4730454
#>           [,8]      [,9]     [,10]     [,11]     [,12]     [,13]     [,14]
#> [1,] 0.4562161 0.4562207 0.4562264 0.4562337 0.4562428 0.4562542 0.4562685
#> [2,] 0.4764084 0.4764153 0.4764240 0.4764350 0.4764487 0.4764660 0.4764876
#> [3,] 0.4465718 0.4465764 0.4465822 0.4465894 0.4465985 0.4466099 0.4466242
#> [4,] 0.5237823 0.5237885 0.5237963 0.5238061 0.5238185 0.5238339 0.5238533
#> [5,] 0.4730497 0.4730551 0.4730619 0.4730705 0.4730812 0.4730946 0.4731114
#>          [,15]     [,16]     [,17]     [,18]     [,19]     [,20]     [,21]
#> [1,] 0.4562864 0.4563091 0.4563372 0.4563723 0.4564158 0.4564698 0.4565365
#> [2,] 0.4765147 0.4765493 0.4765920 0.4766454 0.4767121 0.4767950 0.4768978
#> [3,] 0.4466421 0.4466648 0.4466929 0.4467278 0.4467712 0.4468250 0.4468914
#> [4,] 0.5238776 0.5239084 0.5239466 0.5239943 0.5240537 0.5241275 0.5242188
#> [5,] 0.4731325 0.4731593 0.4731923 0.4732335 0.4732847 0.4733481 0.4734263
#>          [,22]     [,23]     [,24]     [,25]     [,26]     [,27]     [,28]
#> [1,] 0.4566184 0.4567184 0.4568396 0.4569852 0.4571621 0.4573675 0.4576054
#> [2,] 0.4770250 0.4771814 0.4773728 0.4776054 0.4778919 0.4782304 0.4786310
#> [3,] 0.4469728 0.4470720 0.4471919 0.4473356 0.4475094 0.4477097 0.4479398
#> [4,] 0.5243314 0.5244695 0.5246378 0.5248412 0.5250893 0.5253807 0.5257221
#> [5,] 0.4735223 0.4736394 0.4737810 0.4739507 0.4741555 0.4743926 0.4746654
#>          [,29]     [,30]     [,31]     [,32]     [,33]     [,34]     [,35]
#> [1,] 0.4578763 0.4581851 0.4585184 0.4588735 0.4592497 0.4596216 0.4599897
#> [2,] 0.4790991 0.4796486 0.4802648 0.4809508 0.4817148 0.4825217 0.4833808
#> [3,] 0.4481987 0.4484894 0.4487958 0.4491184 0.4494360 0.4497446 0.4500211
#> [4,] 0.5261160 0.5265701 0.5270712 0.5276241 0.5282098 0.5288264 0.5294480
#> [5,] 0.4749732 0.4753184 0.4756858 0.4760691 0.4764617 0.4768387 0.4771945
#>          [,36]     [,37]     [,38]     [,39]     [,40]     [,41]     [,42]
#> [1,] 0.4603319 0.4606287 0.4608768 0.4610542 0.4611597 0.4611790 0.4611137
#> [2,] 0.4842490 0.4851322 0.4859840 0.4868130 0.4875745 0.4882822 0.4888944
#> [3,] 0.4502637 0.4504552 0.4506024 0.4507030 0.4507609 0.4507931 0.4508058
#> [4,] 0.5300704 0.5306708 0.5312268 0.5317346 0.5321736 0.5325299 0.5327917
#> [5,] 0.4775075 0.4777759 0.4779887 0.4781518 0.4782675 0.4783442 0.4783922
#>          [,43]     [,44]     [,45]     [,46]     [,47]     [,48]     [,49]
#> [1,] 0.4609601 0.4607229 0.4604067 0.4600177 0.4596415 0.4592546 0.4588131
#> [2,] 0.4894113 0.4898415 0.4901455 0.4904646 0.4907380 0.4908885 0.4909116
#> [3,] 0.4508160 0.4508725 0.4510101 0.4511376 0.4512577 0.4514542 0.4517094
#> [4,] 0.5329492 0.5329946 0.5329225 0.5327305 0.5324236 0.5321435 0.5317465
#> [5,] 0.4784219 0.4784416 0.4784532 0.4784642 0.4784765 0.4784777 0.4784661
#>          [,50]     [,51]     [,52]     [,53]     [,54]     [,55]     [,56]
#> [1,] 0.4583423 0.4578553 0.4574154 0.4570382 0.4566423 0.4562782 0.4560226
#> [2,] 0.4907850 0.4905980 0.4903708 0.4901828 0.4900356 0.4899373 0.4897991
#> [3,] 0.4519462 0.4521686 0.4523213 0.4524094 0.4524397 0.4524574 0.4524645
#> [4,] 0.5312765 0.5308215 0.5304965 0.5302086 0.5299833 0.5298190 0.5297227
#> [5,] 0.4784541 0.4784108 0.4783794 0.4783348 0.4782991 0.4782673 0.4782383
#>          [,57]     [,58]     [,59]     [,60]     [,61]     [,62]     [,63]
#> [1,] 0.4557980 0.4556046 0.4554319 0.4552787 0.4551440 0.4550337 0.4549337
#> [2,] 0.4896392 0.4894830 0.4893340 0.4891949 0.4890784 0.4889671 0.4888785
#> [3,] 0.4524575 0.4525033 0.4525448 0.4525758 0.4525989 0.4526176 0.4526313
#> [4,] 0.5296651 0.5296170 0.5295830 0.5295544 0.5295282 0.5294757 0.5294374
#> [5,] 0.4782119 0.4781878 0.4781700 0.4780690 0.4779855 0.4779200 0.4778577
#>          [,64]     [,65]     [,66]     [,67]     [,68]     [,69]     [,70]
#> [1,] 0.4548553 0.4547835 0.4547215 0.4546769 0.4546356 0.4546082 0.4545815
#> [2,] 0.4887941 0.4887314 0.4886711 0.4886161 0.4885806 0.4885462 0.4885286
#> [3,] 0.4526405 0.4526480 0.4526535 0.4526577 0.4526612 0.4526633 0.4526643
#> [4,] 0.5294109 0.5293872 0.5293719 0.5293572 0.5293440 0.5293374 0.5293307
#> [5,] 0.4778105 0.4777655 0.4777335 0.4777024 0.4776740 0.4776564 0.4776394
#>          [,71]     [,72]     [,73]     [,74]     [,75]     [,76]     [,77]
#> [1,] 0.4545676 0.4545423 0.4545307 0.4545193 0.4545085 0.4544987 0.4544899
#> [2,] 0.4885104 0.4884924 0.4884752 0.4884591 0.4884442 0.4884305 0.4884182
#> [3,] 0.4526651 0.4526661 0.4526668 0.4526672 0.4526673 0.4526670 0.4526666
#> [4,] 0.5293243 0.5293183 0.5293128 0.5293078 0.5293033 0.5292992 0.5292954
#> [5,] 0.4776310 0.4776224 0.4776138 0.4776054 0.4775974 0.4775899 0.4775829
#>          [,78]     [,79]     [,80]     [,81]
#> [1,] 0.4544821 0.4544753 0.4544694 0.4544643
#> [2,] 0.4884070 0.4883971 0.4883882 0.4883804
#> [3,] 0.4526660 0.4526653 0.4526646 0.4526638
#> [4,] 0.5292921 0.5292890 0.5292863 0.5292838
#> [5,] 0.4775766 0.4775708 0.4775656 0.4775610