This function generates a single univariate response value \(Y\) and a vector of explanatory variables \((X_1,\ldots,X_{totdim})\) drawn from a model with a given number of latent components.

simul_data_UniYX(totdim, ncomp)

Arguments

totdim

Number of columns of the X vector (from ncomp to hardware limits)

ncomp

Number of latent components in the model (from 2 to 6)

Value

vector

\((Y,X_1,\ldots,X_{totdim})\)

Details

This function should be combined with the replicate function to give rise to a larger dataset. The algorithm used is a port of the one described in the article of Li which is a multivariate generalization of the algorithm of Naes and Martens.

References

T. Naes, H. Martens, Comparison of prediction methods for multicollinear data, Commun. Stat., Simul. 14 (1985) 545-576.
Morris, Elaine B. Martin, Model selection for partial least squares regression, Chemometrics and Intelligent Laboratory Systems 64 (2002) 79-89, doi: 10.1016/S0169-7439(02)00051-5 .

See also

simul_data_YX and simul_data_complete for generating multivariate data

Author

Frédéric Bertrand
frederic.bertrand@utt.fr
https://fbertran.github.io/homepage/

Examples

simul_data_UniYX(20,6)
#> Y X1 X2 X3 X4 X5 X6 #> -5.0845940 -2.0283323 -6.7362672 -3.3100088 -5.1476176 -0.6794538 -5.6005351 #> X7 X8 X9 X10 X11 X12 X13 #> -1.9725262 -3.9952421 -3.3466745 -3.6213504 -1.9200845 -5.5309980 -5.5844386 #> X14 X15 X16 X17 X18 X19 X20 #> -2.0899928 -3.3650301 -3.6175759 -1.9002841 -5.5163292 -5.5791753 -2.0879278
# \donttest{ dimX <- 6 Astar <- 2 simul_data_UniYX(dimX,Astar)
#> Y X1 X2 X3 X4 X5 X6 #> 3.405154 -9.219318 -9.206206 5.151362 -9.223586 -9.222478 5.171035
(dataAstar2 <- data.frame(t(replicate(50,simul_data_UniYX(dimX,Astar)))))
#> Y X1 X2 X3 X4 X5 #> 1 -5.4667852 -4.6368328 -4.6633727 -3.8169525 -4.6492866 -4.6343097 #> 2 2.5611245 4.4882903 4.4834136 0.7940228 4.4865642 4.4646325 #> 3 5.8534434 2.1600274 2.1642386 4.4565923 2.1785280 2.1725729 #> 4 -7.2685172 -2.9284924 -2.9155321 -5.7429226 -2.9388173 -2.8998562 #> 5 15.7429002 8.4686086 8.4947916 11.9159934 8.4771044 8.4726148 #> 6 3.7344067 -2.7395944 -2.7146311 3.9311366 -2.7377429 -2.7428695 #> 7 8.3220039 -3.5079464 -3.4918852 8.1026183 -3.4977322 -3.4983252 #> 8 0.9494198 -4.2032146 -4.1983074 1.6417675 -4.1764409 -4.2048811 #> 9 -14.9267216 -2.8222037 -2.8181578 -12.5035209 -2.7979519 -2.8153492 #> 10 12.7602184 10.4981129 10.4741489 8.9435314 10.5008709 10.4958755 #> 11 -7.1831458 -7.2682429 -7.2616761 -4.4726100 -7.2711886 -7.2758669 #> 12 -6.8634182 4.9443571 4.9398128 -6.9835797 4.9373878 4.9593859 #> 13 3.6898544 -6.7960138 -6.8062212 4.8938195 -6.8159262 -6.8215547 #> 14 1.0245038 -0.8001555 -0.8217277 1.1709703 -0.8181114 -0.8103901 #> 15 -1.9356491 -2.4355237 -2.4491487 -1.2550267 -2.4562047 -2.4410910 #> 16 9.5511311 2.4434726 2.4601161 7.8979152 2.4509083 2.4600142 #> 17 2.3699577 3.9373881 3.9325800 1.2903720 3.9270690 3.9198469 #> 18 3.0787230 1.7702339 1.7590052 2.3511337 1.7740213 1.7685472 #> 19 -5.9158249 -4.8695095 -4.8551184 -4.0128074 -4.8757767 -4.8818083 #> 20 -4.2512179 2.2564203 2.2304770 -4.3865768 2.2263642 2.2372684 #> 21 2.9481516 0.7101294 0.7239348 2.4468113 0.7359318 0.7222038 #> 22 6.9365803 4.8017027 4.8047261 5.0208553 4.7972377 4.7974923 #> 23 0.6756597 -0.6555612 -0.6596367 0.8949284 -0.6303841 -0.6422226 #> 24 -13.1447165 -5.9889274 -6.0008032 -10.1544315 -5.9949115 -6.0037904 #> 25 -1.8552695 2.2777843 2.3059150 -2.1900221 2.2958622 2.2914878 #> 26 5.2401381 3.2957539 3.3189881 3.5224658 3.3185833 3.3045925 #> 27 2.2010546 -1.9017223 -1.9024361 2.1356018 -1.9068453 -1.8923967 #> 28 13.0510899 3.6415330 3.6356619 10.6251511 3.6282661 3.6231769 #> 29 -2.4193309 -0.4165742 -0.4239745 -1.7547497 -0.4103461 -0.4345485 #> 30 6.4620509 -8.4380830 -8.4237091 7.8145126 -8.4264293 -8.4455333 #> 31 -5.7784618 -0.9027898 -0.9080020 -4.8233568 -0.9074618 -0.9041069 #> 32 1.4509866 2.0958031 2.0749671 0.9419409 2.1068536 2.0964665 #> 33 7.9214112 9.8516726 9.8565220 4.7489091 9.8680162 9.8801174 #> 34 -3.3029994 1.6935832 1.6725352 -3.2169203 1.6810599 1.6941970 #> 35 6.0773737 2.4787094 2.4617545 4.9182408 2.4543583 2.4586245 #> 36 -10.6780025 -1.5617825 -1.5663286 -9.1746997 -1.5711859 -1.5613791 #> 37 9.0285613 -1.4414365 -1.4255375 8.2122272 -1.4459823 -1.4371005 #> 38 -6.4695242 -2.9467627 -2.9357047 -5.0402549 -2.9297071 -2.9397697 #> 39 1.4662987 -1.3090126 -1.3083322 1.6270797 -1.3020824 -1.3165576 #> 40 -3.3371261 -2.5063990 -2.4953270 -2.4546657 -2.5039430 -2.4770483 #> 41 -1.4539051 -5.2468572 -5.2650928 -0.2295093 -5.2591658 -5.2512687 #> 42 6.3184639 -5.4198403 -5.4601561 6.7624950 -5.4054132 -5.4264303 #> 43 2.8317073 1.7682700 1.7577297 2.3103366 1.7716436 1.7854530 #> 44 10.6902298 5.4850914 5.4955988 8.0465319 5.5062763 5.4957139 #> 45 -0.6419986 -3.1803137 -3.1653965 0.1487841 -3.1717620 -3.1859978 #> 46 2.8169097 -7.9217699 -7.9159526 4.3848788 -7.9391640 -7.9150733 #> 47 11.1281255 3.9571348 3.9691447 9.0758530 3.9628487 3.9511548 #> 48 4.5841800 1.0845161 1.0807621 3.7481882 1.0838256 1.0968055 #> 49 -5.8178230 -5.1147009 -5.0984231 -3.9547834 -5.1007076 -5.1156178 #> 50 2.7833737 -2.0400129 -2.0192960 2.9955890 -2.0100177 -2.0300712 #> X6 #> 1 -3.8203893 #> 2 0.7856648 #> 3 4.4714926 #> 4 -5.7694441 #> 5 11.9243584 #> 6 3.9193597 #> 7 8.1102868 #> 8 1.6474534 #> 9 -12.5035281 #> 10 8.9555033 #> 11 -4.5048317 #> 12 -7.0006527 #> 13 4.8932628 #> 14 1.1970988 #> 15 -1.2538425 #> 16 7.9037518 #> 17 1.2928187 #> 18 2.3677084 #> 19 -4.0024864 #> 20 -4.3827118 #> 21 2.4544227 #> 22 5.0210339 #> 23 0.8928215 #> 24 -10.1946654 #> 25 -2.1779188 #> 26 3.5185891 #> 27 2.1512452 #> 28 10.6244721 #> 29 -1.7780853 #> 30 7.8340958 #> 31 -4.8215752 #> 32 0.9283044 #> 33 4.7265777 #> 34 -3.2171668 #> 35 4.9220532 #> 36 -9.1730249 #> 37 8.1929077 #> 38 -5.0085114 #> 39 1.6473875 #> 40 -2.4636988 #> 41 -0.2537657 #> 42 6.7611795 #> 43 2.3123757 #> 44 8.0443681 #> 45 0.1289411 #> 46 4.4004104 #> 47 9.0678227 #> 48 3.7400793 #> 49 -3.9620494 #> 50 2.9866173
cvtable(summary(cv.plsR(Y~.,data=dataAstar2,5,NK=100, verbose=FALSE)))
#> ____************************************************____
#> Error in is.data.frame(data): objet 'dataAstar2' introuvable
dimX <- 6 Astar <- 3 simul_data_UniYX(dimX,Astar)
#> Y X1 X2 X3 X4 X5 X6 #> 6.053029 3.689110 5.648481 3.172013 3.670531 5.644560 3.157390
(dataAstar3 <- data.frame(t(replicate(50,simul_data_UniYX(dimX,Astar)))))
#> Y X1 X2 X3 X4 X5 #> 1 -1.2631029 8.62015665 6.04550745 -1.49610045 8.6160142 6.05222905 #> 2 -12.3698859 -0.48149600 -4.65999133 -8.29663001 -0.4840979 -4.65283898 #> 3 -13.3752100 -6.97607422 -2.68919756 -12.85550026 -6.9666058 -2.69496482 #> 4 14.2908966 -3.62743325 1.43095860 10.48074941 -3.6419478 1.42740649 #> 5 2.4915184 -0.59570169 3.04622831 0.03618188 -0.5690905 3.05831672 #> 6 -5.4694637 -2.77612155 -1.43404561 -4.99781690 -2.7602286 -1.43484884 #> 7 1.7861353 2.16944238 4.04352277 -0.02322489 2.1749004 4.05232934 #> 8 2.3985486 6.26214976 5.96461765 0.65653362 6.2437259 5.95757890 #> 9 -6.0663365 -4.39230852 -15.66552289 2.88280042 -4.4049851 -15.65584589 #> 10 -15.6835317 0.19271747 -4.10346903 -11.22824331 0.1826909 -4.09846771 #> 11 -0.4386717 -5.33677744 -5.26431305 1.17388905 -5.3167378 -5.24378213 #> 12 4.3304125 6.35930562 5.89927537 2.64391214 6.3656704 5.90267001 #> 13 0.1274229 -0.10746146 1.07272349 -0.80201933 -0.1117411 1.06870638 #> 14 2.4091915 -2.63053475 -5.41727258 4.45902327 -2.6294751 -5.39713624 #> 15 -10.7028579 -4.33248793 -2.37373200 -9.50593652 -4.3263525 -2.37293718 #> 16 6.1543136 0.66106856 1.45416854 4.82886012 0.6601333 1.43686959 #> 17 10.4264607 -2.96023385 10.55086507 1.32669810 -2.9635919 10.56579664 #> 18 16.0744100 7.86199101 7.13609641 12.56368148 7.8605900 7.12647545 #> 19 -3.6138262 -0.02355808 -2.47788102 -1.50647583 -0.0203125 -2.47837657 #> 20 9.3973883 4.50813781 8.22232139 4.83660938 4.5237641 8.19718909 #> 21 18.2721088 0.89258367 5.49504693 13.06479204 0.8844241 5.48651201 #> 22 -3.2215266 6.41564713 0.14303933 -0.59247563 6.3904457 0.12424621 #> 23 -3.9488421 -7.27075522 -0.14128497 -6.06273021 -7.2647811 -0.14521253 #> 24 -4.7866183 -5.78671556 -0.32164800 -6.17099344 -5.7999207 -0.31957270 #> 25 -7.0728021 -0.90612814 -14.92094368 2.88273912 -0.9096703 -14.94422828 #> 26 5.6918581 4.81284500 -0.08035738 6.88998112 4.8037946 -0.07958272 #> 27 -1.2880336 -15.13225525 -9.14634162 -1.13436363 -15.1413876 -9.14017794 #> 28 3.6608278 -4.91671305 -4.70634163 4.16494827 -4.9210192 -4.73362385 #> 29 -3.6655422 2.66036687 1.76746287 -3.35407991 2.6724442 1.77644851 #> 30 3.6261631 0.13638598 -3.53965032 5.61811174 0.1329447 -3.53582833 #> 31 -4.5235299 -1.34526120 -4.49217504 -1.68546591 -1.3631599 -4.46227885 #> 32 0.5336358 -4.80599611 -2.89209085 0.20148673 -4.8028437 -2.91002282 #> 33 2.7720865 -1.31651928 -1.63071326 2.95885467 -1.3167790 -1.63173290 #> 34 -1.3689187 5.01480278 -0.87924751 1.14393219 4.9787169 -0.88435741 #> 35 1.1236208 -1.97113906 -3.67058364 2.53246112 -1.9808060 -3.66871834 #> 36 -8.0788317 -6.85527676 -8.90216766 -4.04987639 -6.8605611 -8.92140282 #> 37 10.8330856 6.73874440 6.31953696 7.94135761 6.7247610 6.31102728 #> 38 -6.7092777 4.54326509 3.68547090 -6.44612867 4.5694655 3.67870490 #> 39 17.8047903 -3.64214154 6.75758963 10.26631932 -3.6456385 6.75897518 #> 40 1.7188822 -0.66164125 -2.12005974 2.72266937 -0.6751113 -2.13097620 #> 41 2.0740758 8.64534352 7.75893962 0.09814661 8.6705006 7.75768112 #> 42 2.1918392 10.12305454 7.81187451 0.81836595 10.1390035 7.79293651 #> 43 -8.9227240 4.28635751 -2.57562809 -4.76351301 4.2976642 -2.59746949 #> 44 -11.2815228 3.50930834 -2.77125713 -6.95490126 3.5206084 -2.77651025 #> 45 6.8816529 0.63782974 8.82733953 0.84597403 0.6535855 8.84792883 #> 46 16.1412754 -10.99838112 -0.79792407 10.22086356 -11.0001737 -0.78112049 #> 47 -1.2611036 0.72047062 -5.29236306 2.26971048 0.7138796 -5.28629422 #> 48 2.8611984 3.81337089 5.61122467 0.22487215 3.8227395 5.62362256 #> 49 -10.0928842 -5.97677779 -16.09687820 -1.02309093 -5.9752951 -16.10369720 #> 50 -8.8170314 -6.24581075 -1.37996681 -8.98467137 -6.2564990 -1.35358203 #> X6 #> 1 -1.48515137 #> 2 -8.28858160 #> 3 -12.82380723 #> 4 10.47335101 #> 5 0.01861043 #> 6 -5.03323849 #> 7 -0.02389704 #> 8 0.65396427 #> 9 2.89431774 #> 10 -11.22803875 #> 11 1.16691778 #> 12 2.62803467 #> 13 -0.78829971 #> 14 4.45073685 #> 15 -9.50750556 #> 16 4.83696488 #> 17 1.30877531 #> 18 12.54138664 #> 19 -1.52207372 #> 20 4.82644495 #> 21 13.06699614 #> 22 -0.57938774 #> 23 -6.05199059 #> 24 -6.17072102 #> 25 2.90496499 #> 26 6.88111811 #> 27 -1.14813428 #> 28 4.17677628 #> 29 -3.35299545 #> 30 5.62432629 #> 31 -1.68738207 #> 32 0.19618725 #> 33 2.95462372 #> 34 1.14520928 #> 35 2.52270998 #> 36 -4.06258119 #> 37 7.89446223 #> 38 -6.46647250 #> 39 10.27335078 #> 40 2.69709957 #> 41 0.11457280 #> 42 0.80744420 #> 43 -4.76265500 #> 44 -6.95500441 #> 45 0.83309667 #> 46 10.22908306 #> 47 2.25425415 #> 48 0.22155741 #> 49 -1.03060202 #> 50 -8.97960486
cvtable(summary(cv.plsR(Y~.,data=dataAstar3,5,NK=100, verbose=FALSE)))
#> ____************************************************____
#> Error in is.data.frame(data): objet 'dataAstar3' introuvable
dimX <- 6 Astar <- 4 simul_data_UniYX(dimX,Astar)
#> Y X1 X2 X3 X4 X5 X6 #> 0.4059092 -4.0821333 -1.8371446 0.0473401 3.7340274 5.9658261 7.8456856
(dataAstar4 <- data.frame(t(replicate(50,simul_data_UniYX(dimX,Astar)))))
#> Y X1 X2 X3 X4 X5 #> 1 7.0860363 4.0077909 4.06328324 6.3135785 3.3732500 3.41441693 #> 2 3.2681636 3.8055202 2.88710074 3.1131039 4.8430419 3.90157594 #> 3 -5.5916689 4.1398696 2.09025553 -5.5012952 5.1036469 3.05082740 #> 4 -3.4812368 1.0812169 -3.56726928 -0.8844031 2.7101705 -1.91881738 #> 5 8.6998880 5.3209857 -1.57912545 11.7385645 5.1918862 -1.70338527 #> 6 -1.8177046 0.5288969 0.09212778 -1.4624162 1.1020394 0.67115647 #> 7 1.3130510 1.8923981 2.10155047 0.6735591 -1.9498672 -1.74709353 #> 8 -4.3528103 4.8175512 0.99410090 -3.3312504 8.5083742 4.71271220 #> 9 -6.6671333 5.4931079 -4.98381888 -1.3392754 7.0428168 -3.42019505 #> 10 -14.1121061 -4.4194137 -8.54532906 -10.4867272 -0.2922796 -4.41798755 #> 11 0.7893536 -2.5107756 2.55473097 -1.5876833 1.9294318 6.96547630 #> 12 -14.6659334 -13.4754624 -14.90632084 -10.6617973 -9.3796285 -10.83554464 #> 13 -4.8847046 -5.4799913 -7.34615481 -2.4885477 -12.3439363 -14.18168328 #> 14 -24.8442962 -1.4454725 -10.07022847 -19.5121917 7.4572480 -1.17494720 #> 15 -12.9907409 8.2072337 0.61655987 -10.5130039 9.4398693 1.83828922 #> 16 -7.9234206 6.5872042 6.95069928 -9.9410551 7.8117832 8.19090233 #> 17 -4.2994817 5.2259581 9.09634220 -8.2222844 6.0090566 9.87140088 #> 18 1.6788246 -3.6292430 5.70844721 -3.5083969 -4.3953353 4.89685271 #> 19 5.3021566 -7.0752056 2.38187759 1.3895094 -6.9567767 2.49787517 #> 20 -1.6790057 3.9200279 0.05154530 -0.3589290 3.7403832 -0.11499637 #> 21 -10.8000504 6.4974959 -0.92296670 -7.7566747 8.4503062 1.02867665 #> 22 -0.4863779 -4.4441857 2.87496170 -3.9959782 -7.3146995 0.02180724 #> 23 -3.4001711 1.7879384 8.15605900 -7.9657665 5.5112933 11.88189282 #> 24 -5.3414180 8.5248892 -0.67177546 -1.7274359 12.6155492 3.41984167 #> 25 -6.3438209 -2.5733347 0.62345602 -8.0413668 -4.7518035 -1.55507143 #> 26 -6.4234839 -1.6636694 -1.56350839 -6.2522811 -3.5514117 -3.49728423 #> 27 3.4144158 -3.5859721 -4.38209947 4.8260256 -6.6334912 -7.43415878 #> 28 -0.7504636 7.2490796 5.26112976 -1.2329636 0.4842377 -1.53521244 #> 29 7.4083635 -9.7439560 -1.97081900 4.9855246 -9.7335145 -1.98420476 #> 30 5.7853092 -1.6532324 3.57872694 2.8154206 -3.2990248 1.97155943 #> 31 -6.9793358 7.9468889 3.73835668 -5.9855478 3.7810241 -0.43252565 #> 32 5.2515916 2.6148493 0.12630245 6.2152971 6.6018613 4.12486101 #> 33 2.9752351 6.4926577 2.09436511 4.4754807 2.6936139 -1.71428669 #> 34 0.4066783 0.5076861 -5.16077721 3.9753799 0.4040819 -5.25373158 #> 35 -10.4071769 -5.4812078 -0.19262102 -12.4536746 3.9826979 9.24336478 #> 36 -9.7794709 -6.4040239 -7.26107489 -7.9502710 -7.2702174 -8.10474474 #> 37 -2.0201677 -13.2442964 -8.93150993 -1.3866178 -12.6631673 -8.31700198 #> 38 3.6619746 0.3415699 -2.81462956 5.4965395 -1.2137836 -4.37407399 #> 39 -6.9419179 2.2302566 -3.13643196 -4.2791230 1.1430958 -4.23543725 #> 40 2.3037179 -3.2868051 3.38500646 -1.2059138 -5.3003900 1.36300313 #> 41 3.6031236 6.3998541 4.93581611 2.9612245 6.9695118 5.46054133 #> 42 5.9014586 1.2349944 9.02842983 0.8490823 7.0163082 14.82390162 #> 43 -10.5298275 1.9760547 -4.80487417 -7.0049679 2.2800038 -4.53197233 #> 44 10.1265270 3.2538745 5.90448127 8.0841510 2.1753411 4.75239423 #> 45 11.7102146 0.1374255 2.16258534 10.7257386 -7.9401930 -5.88978411 #> 46 -3.2704082 -0.8205507 -4.74192894 -0.7030350 2.2991397 -1.63150303 #> 47 -6.2444004 8.9693756 3.93758579 -5.2276113 9.1272766 4.09124436 #> 48 -2.9445481 9.4963015 4.65220369 -2.4615317 6.9488980 2.10959746 #> 49 6.0849343 -6.2542975 -8.32715839 8.8008016 -7.9973740 -10.08662071 #> 50 5.2883991 2.0531857 1.49476346 5.4397378 -2.8415246 -3.41788867 #> X6 #> 1 5.6699687 #> 2 4.1530111 #> 3 -4.5505915 #> 4 0.7741691 #> 5 11.6260502 #> 6 -0.8787134 #> 7 -3.1763859 #> 8 0.3632350 #> 9 0.2103480 #> 10 -6.3657143 #> 11 2.8151935 #> 12 -6.5670103 #> 13 -9.3192052 #> 14 -10.5774788 #> 15 -9.2731471 #> 16 -8.7195966 #> 17 -7.4680694 #> 18 -4.3051505 #> 19 1.4770180 #> 20 -0.5422467 #> 21 -5.8153162 #> 22 -6.8549195 #> 23 -4.2340823 #> 24 2.3557439 #> 25 -10.2299941 #> 26 -8.1407991 #> 27 1.7575952 #> 28 -8.0136838 #> 29 4.9526456 #> 30 1.2158937 #> 31 -10.1443635 #> 32 10.1624363 #> 33 0.6592251 #> 34 3.9106523 #> 35 -2.9754729 #> 36 -8.8201143 #> 37 -0.7951902 #> 38 3.9645935 #> 39 -5.3811771 #> 40 -3.2334664 #> 41 3.5009140 #> 42 6.6509663 #> 43 -6.7620323 #> 44 6.9603385 #> 45 2.6636970 #> 46 2.4322911 #> 47 -5.0789155 #> 48 -5.0192015 #> 49 7.0272046 #> 50 0.5318266
cvtable(summary(cv.plsR(Y~.,data=dataAstar4,5,NK=100, verbose=FALSE)))
#> ____************************************************____
#> Error in is.data.frame(data): objet 'dataAstar4' introuvable
rm(list=c("dimX","Astar","dataAstar2","dataAstar3","dataAstar4")) # }