Simulating time series data for an individual using 5 variables. First, we define the correlation matrix for the 5 variables. We specify positive (V1 and V2, V2 and V4) and negative (V3 and V4) correlations between certain pairs of variables. V5 remains uncorrelated.

The correlation matrix is converted into a standard matrix format to be checked and eigenvalues are calculated to ensure matrix is valid. Ie., all eigenvalues are positive.

# Load necessary libraries
library(simdata)
## Warning: package 'simdata' was built under R version 4.3.3
library(GGally)
## Warning: package 'GGally' was built under R version 4.3.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.3.3
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
library(ggplot2)

# Define the correlation matrix for 5 variables
correlation_matrix <- simdata::cor_from_upper(
  5,
  rbind(
    c(1, 2, 0.6),   # Positive correlation between V1 and V2
    c(2, 4, 0.6),   # Positive correlation between V2 and V4
    c(3, 4, -0.6)   # Negative correlation between V3 and V4
                    # V5 uncorrelated
  )
)

# Check the original matrix
cor_matrix <- matrix(c(
  1,   0.6, 0,    0,    0,   # V1 correlated with V2
  0.6, 1,   0,    0.6,  0,   # V2 correlated with V1 and V4
  0,   0,   1,   -0.6,  0,   # V3 negatively correlated with V4
  0,   0.6, -0.6, 1,    0,   # V4 correlated with V2 and negatively with V3
  0,   0,   0,    0,    1    # V5 uncorrelated
), nrow = 5, byrow = TRUE)

# Check eigenvalues
eigenvalues <- eigen(cor_matrix)$values
eigenvalues
## [1] 1.97082039 1.37082039 1.00000000 0.62917961 0.02917961

Next we can use the function_list() from simdata package to transform the initial data to an exponential distribution. Or we can leave the data untransformed so that it remains linear.

# Define transformations if necessary 
transformation <- simdata::function_list(
  v1 = function(z) z[,1],  # No transformation, keeping original scale
  v2 = function(z) z[,2],  # Keeping original scale for simplicity
  v3 = function(z) z[,3],  # Keeping original scale for simplicity
  v4 = function(z) z[,4],  # Keeping original scale for simplicity
  v5 = function(z) z[,5]   # Keeping original scale for simplicity
)

# Define transformations to convert normal distribution to exponential distribution
transformation_exponential <- simdata::function_list(
  v1 = function(z) exp(z[,1]),  # Apply exponential transformation
  v2 = function(z) exp(z[,2]),
  v3 = function(z) exp(z[,3]),
  v4 = function(z) exp(z[,4]),
  v5 = function(z) exp(z[,5])
)

Next, we define the simulation using the correlation matrix and any transformations we created previously. Simulated data is then generated and converted to a dataframe.

# Define the simulation design
sim_design <- simdata::simdesign_mvtnorm(
  relations = correlation_matrix,    # Use the defined correlation matrix
  transform_initial = transformation_exponential # Use the defined transformations
)

# Generate the simulated data
set.seed(12345) # For reproducibility
simulated_data <- simulate_data(sim_design, n = 100)

# Convert to a dataframe for easier handling
simulated_df <- as.data.frame(simulated_data)

# Print the first few rows of the data to check
head(simulated_df)
##          v1        v2        v3        v4        v5
## 1 2.3214281 1.8579634 1.1094445 0.8926270 1.8328781
## 2 0.2401623 0.7704960 0.9629567 1.3059599 0.3987893
## 3 1.6303531 5.6066669 1.3754853 2.8013891 0.4721153
## 4 1.4228461 0.9620104 0.4421249 1.8999287 1.3481371
## 5 4.0752791 2.3103138 1.0636453 0.5662312 0.2023595
## 6 4.1694743 1.7162143 1.2872056 0.9460722 0.8501768
print(simulated_df)
##            v1          v2          v3          v4          v5
## 1   2.3214281  1.85796343  1.10944449  0.89262697  1.83287809
## 2   0.2401623  0.77049596  0.96295666  1.30595987  0.39878933
## 3   1.6303531  5.60666691  1.37548526  2.80138912  0.47211532
## 4   1.4228461  0.96201042  0.44212492  1.89992872  1.34813708
## 5   4.0752791  2.31031380  1.06364531  0.56623122  0.20235949
## 6   4.1694743  1.71621426  1.28720564  0.94607221  0.85017678
## 7   3.7940599 19.33150009  4.38407339  4.17797821  1.28952147
## 8   1.2730913  1.57769810  0.10815506  6.78750086  1.02613678
## 9   1.1553789  0.26742092  0.20866642  1.14359738  2.35008552
## 10  2.1749140  0.68153870  1.15518610  0.67190097  0.27068518
## 11  1.1822853  4.88842764  1.11729829  2.97667281  0.51120912
## 12  1.3395661  4.94419555  1.04382045  5.78748704  0.09566106
## 13  0.6054530  0.66973052  0.83444831  1.81525736  0.55605971
## 14  0.2276860  1.53642337  4.18774639  1.44809365  0.27371395
## 15  0.6707571  1.20487080  0.15205480  7.57137631  4.06618569
## 16  3.1850238  3.16274551  0.41283529  2.55052514  2.77668677
## 17  2.1583883  7.83961416  0.33099919 12.78117315  2.64116649
## 18  6.9503077  4.14652267  0.61653653  1.94331066  2.28158429
## 19  0.2916239  0.34768030  6.36433580  0.28306101  0.37507362
## 20  1.5456191  0.79795931  8.59897097  0.21429132  0.49930073
## 21  0.8980746  0.25233584  2.14037171  0.17527170  1.15152173
## 22  0.5361457  0.60884977  4.93687399  0.36298954  1.37867589
## 23  0.1692840  0.39562722  1.86237383  1.27244162  0.92242080
## 24  0.4972570  1.98922651  0.82787068  5.10716466  0.93331053
## 25  5.8457169  9.96482737  0.82737872  4.74836190  0.65623279
## 26  0.2030188  0.06684656  5.57072656  0.05906640  0.30239187
## 27  6.8754209  2.49363812  2.54800239  0.37516942 14.23620364
## 28  0.2539336  0.32667595  1.68496401  0.64446253  0.65535588
## 29  0.2531977  0.11743524  0.91796521  0.23256475  1.01598206
## 30  0.8499472  0.50660940  1.36751718  0.81148999  1.14876907
## 31  0.2888210  0.65532324  1.77565689  0.67590569  0.89706744
## 32  1.4693550  3.80282063  0.82897534  2.39236535  0.52174844
## 33  0.7457724  0.87680835  0.99179459  0.85540063  0.37090739
## 34  0.8656804  2.76894175  0.17877286  9.06454104  0.97659828
## 35  1.8180326  4.63278679  0.85816708  3.29992532  0.18219607
## 36  3.7009383 10.82603100  1.64054333  2.64566639  0.16272195
## 37  0.3872576  1.04120858  0.46913513  3.17997951  2.26022583
## 38  1.8161940  3.37225998  1.70369099  1.33313052  0.60519001
## 39  1.3096738  0.95874379  1.74993686  0.75839347  3.70700364
## 40  3.0084725  2.20040035  0.81569830  1.05087000  1.01339395
## 41  0.1901315  0.54421770  0.85094875  1.97324452  2.29641410
## 42  0.5712807  0.26376016  1.50495233  0.42913387  0.92613646
## 43  1.5541006  1.52797882  0.32829446  4.11476102  0.54250771
## 44  2.1701153  0.72486911  0.45705739  0.38959632  1.07137792
## 45  1.0092704  0.17681129  0.76239181  0.31674103  5.99743598
## 46  1.5138416  1.95710394  0.55870171  3.14259986  1.08035730
## 47  0.7893287  0.60157606  0.98861693  0.86017839  2.43703152
## 48  0.8235469  1.93630835  0.47716560  2.99987455  1.28188305
## 49  0.4710864  0.30997660  1.12163024  0.38162750  0.89909313
## 50  5.2632053 16.37090211  0.94126345  4.49339619  2.12306587
## 51  0.7553305  1.02587772  2.87006941  0.40418407  0.76697213
## 52  1.7001974  0.62490264  0.81957081  0.48653333  0.31394448
## 53  3.2093169  3.02502035  1.14907778  1.05738680  4.40566487
## 54  0.9517350  0.63998523  2.41696009  0.32108736  0.51500754
## 55  0.5079259  0.20165134  3.51413375  0.11009218  1.29811042
## 56  3.2023293  1.02200542  1.01771007  0.45563197  1.60546552
## 57  0.2333274  1.15581848  0.26800663  6.36224811  1.90903432
## 58  1.3590289  1.71426069  0.37529448  2.91563575  2.12946320
## 59  0.5050786  0.54128000  0.69182955  1.17463887  0.37612080
## 60  0.5967784  0.12266223  0.60897218  0.27732696  1.59091515
## 61  1.4899846  1.87855876  0.42414108  3.08326965  0.88916853
## 62  1.6206206  2.50698457  1.71688504  1.06894336  5.31672715
## 63  0.3399159  1.48032281  1.86923212  2.78897656  8.69367785
## 64  0.5219817  1.18945321  0.11514432  9.16181077  0.46261786
## 65  1.6407595  2.51393689  2.25974982  1.26811445  0.11237133
## 66  2.9670360  1.62167919  1.88528626  0.52397803  2.68198166
## 67  4.0945162  3.63212079  1.00852258  1.94388741  1.49871960
## 68  0.7390996  0.44315771  3.04604419  0.46388895  1.58545725
## 69  5.6874402  2.18573095  1.81335061  0.82132192  0.90887500
## 70  0.7035786  0.13320524  3.81077906  0.05949988  2.17907403
## 71  1.4689069  0.59345501  0.37216390  0.64232526  2.87984757
## 72  0.7785485  1.42466931  0.90353032  1.74578828  0.39885604
## 73  0.3697312  0.18090464  1.21051036  0.38873566  1.01802066
## 74  1.8231339  2.47301495  3.71128231  1.03096669  0.75766194
## 75  1.5078214  5.20047224  1.46386288  2.72507925  1.94647627
## 76  0.7374106  2.29324820  0.13904863  6.55746878  9.58090441
## 77  0.6403171  0.64597041  1.71988223  0.55876718  1.65964204
## 78  1.2389064  1.53844754 13.40076659  0.23611666  0.65801828
## 79  2.5812952  1.77231000  1.29645266  0.79837133  1.29995687
## 80  1.5953901  1.91028727  1.41041497  1.09534674  0.25290268
## 81  1.9372391  0.86770026  1.82892519  0.36828835  0.53944096
## 82  2.3578920  0.75160811  0.99506504  0.38197735  0.36034734
## 83  0.3656928  0.70189792  3.04335398  0.70008021  0.41376476
## 84  1.2580786  0.77260495  0.65239547  0.61534828  2.96308332
## 85  1.7929843  1.59108801  0.55504214  1.56454813  3.41465840
## 86  0.9990460  3.99266926  0.35994302  6.51152136  1.83869975
## 87  0.5067395  0.44751038  1.86502514  0.35377522  1.47304676
## 88  3.1968724 11.61794797  2.05194206  3.28719380  6.92711049
## 89  1.6525743  2.94739097  0.79703714  2.79444688  3.36921030
## 90  1.1893505  0.54709103  0.10091185  2.13471926  0.35721593
## 91  2.9721319  2.46228815  0.73497246  1.20133963  2.73277469
## 92  5.7131768  3.70469740  1.32493169  0.78166744  1.42267464
## 93  0.2950741  0.35837708  1.62086265  0.45220226  0.88523881
## 94  0.3889678  0.12844683  0.85340093  0.17540331  0.86879584
## 95  3.4002860  1.58938416  0.09839132  3.12444812  2.29525065
## 96  0.5165483  0.48128676  0.60099587  0.98696153  0.90742178
## 97  0.9019123  1.05279817  0.74370380  1.46385292  0.24503951
## 98  1.5654398  2.18965239  1.13804254  1.43689224  1.25663224
## 99  0.5555457  0.59742265  1.84972570  0.31016692  0.79637070
## 100 0.9811920  0.51857774  0.44153296  0.90611925  0.73227317

The generated data can be plotted. The plot displays pairwise relationships between the variables in the simulated data set. All variables follow an exponential distribution and positive and negative correlations of the correlation matrix can be observed (eg., V1 and V2 plot shows positive correlation).

# Plot simulated data to inspect data
p <- GGally::ggpairs(simulated_df, 
                     upper = list(continuous = "points"), 
                     progress = FALSE) +
  theme_bw()
print(p)

Simulated the above data for 20 individuals. The previous simulated data was for one individual across 100 time points (n=100). Now we create a new dataframe and run a loop 20 times to create simulated data with the same parameters as the first individual to create simulated data for 20 individuals.

# Initialize a list to store data frames for each individual
individual_data_list <- vector("list", 20)

# Repeat the simulation process for each individual
for (i in 1:20) {
  set.seed(12345 + i)  # Set a unique seed for reproducibility for each individual
  simulated_data <- simulate_data(sim_design, n = 100)
  
  # Convert to a dataframe and store it in the list
  individual_data_list[[i]] <- as.data.frame(simulated_data)
}

names(individual_data_list) <- paste("Individual", 1:20)

# Print the data for the first individual to check
print(individual_data_list[[1]])
##             v1         v2          v3         v4          v5
## 1   3.83390228 0.70978736  4.18962538 0.12289948  0.33840256
## 2   3.76888163 0.73293691  0.64731602 0.83391827  4.06173759
## 3   0.86804724 2.40258485  0.77515144 2.22366994  1.88573687
## 4   0.44078152 0.28055510  1.41325977 0.38414086  2.63390815
## 5   1.15594971 0.55063879  0.95751868 0.39294938  0.58437530
## 6   0.53016606 6.40815019  8.33757065 1.78957180  2.72639863
## 7   1.53726113 1.12720130  0.84698995 0.89601613  0.48620438
## 8   1.56018687 3.61414924  0.36621722 7.28646732  0.52316433
## 9   0.23318965 0.33745396  0.21793264 1.31041014  2.87850052
## 10  0.62283501 3.27147548  0.50461883 5.95826488  0.11760288
## 11  1.07548321 2.33248043  1.10621132 3.06169404  0.46821722
## 12  2.13042252 4.31754342  6.04566735 0.63766930  0.29461458
## 13  0.68403225 0.56984451  0.58040213 1.39009201  0.05975240
## 14  2.59195455 0.55175394  0.27399611 0.73659607  1.05301231
## 15  1.36072765 0.20692882  1.49671524 0.12407516  0.21473179
## 16  0.35315452 1.39241390  1.59748633 2.41597209  0.38208150
## 17  1.22118556 1.29451462  0.61180681 1.96314776  0.89005822
## 18  4.89635395 1.81975252  2.43477504 0.23261280  1.44498928
## 19  4.36385987 4.03138724  1.11231670 1.54572578  0.31606732
## 20  0.52295230 0.71687794  1.23149797 1.63697086  0.22631984
## 21  1.40347334 4.14976601  0.98708313 4.16235345  9.64570396
## 22  3.15133302 0.95780880  0.43622936 1.53012950  2.33940977
## 23  2.22945702 3.91462903  1.67171950 1.81453370  0.77730035
## 24  1.52139678 1.14649301  6.83064275 0.34376518  0.97329548
## 25  6.15007639 1.10057848  0.58752991 0.40841008  2.62548541
## 26  0.53306827 0.58092509  0.43946613 1.12722326  0.07963231
## 27  1.07934272 4.48689882  0.73055305 2.64194327 10.69088234
## 28  2.41964845 2.74236015  0.84249229 1.60275352  0.14697654
## 29  1.01872026 7.19465934  1.02881151 6.18748303  0.78556473
## 30  1.72603112 3.29098794  2.00959566 1.79535395  1.01183553
## 31  0.20564295 0.68480401  0.34303556 2.40241768  0.56597441
## 32  0.42977691 0.34772274  2.29300442 0.36364934  2.21692639
## 33  0.12565041 0.11933054  2.44138507 0.33315060  1.32185353
## 34  1.37171187 1.23441037  5.91445445 0.40614242  1.09819986
## 35  1.40585631 1.05873401  3.67317322 0.24846179  2.40602040
## 36  1.97978874 0.44657571  5.26502581 0.13698302  0.77565636
## 37  0.63874916 0.23331784  0.65277515 0.44478170  3.07586769
## 38  1.08844132 0.35647979  5.04813451 0.09987797  1.03151651
## 39  2.29940370 0.18887929  0.34332898 0.22661797  0.77800117
## 40  0.26483410 2.29797757 12.62168122 1.04123254  0.31811105
## 41  0.43302902 0.63755748  1.45831300 0.79714033  0.45021615
## 42  0.08884380 0.68170346  0.35829844 6.14956787  3.67170090
## 43  0.84807031 2.11013292  0.75103348 1.46478489  0.25976141
## 44  4.35487843 1.14045844  2.05673591 0.41208888  2.60820434
## 45  0.39936108 0.33362669  3.16627643 0.19401089  1.87190191
## 46  0.91742554 0.18216314  1.81652914 0.15906189  0.38624567
## 47  0.24227314 0.21750816  1.86231461 0.51136535  0.13199748
## 48  1.71660959 0.34637413  4.42274846 0.14823922  0.26659050
## 49  3.42966192 5.28054932  2.04786808 1.49165451  2.29087639
## 50  1.55239247 1.05432314  0.53997634 1.06324576  0.57510052
## 51  2.23912160 0.33027884  0.35719030 0.38110883  0.47960135
## 52  0.36970408 0.55307562  0.92264773 1.10760932  0.38527314
## 53  0.39939675 0.99792672  2.64319217 1.04657047  1.18174959
## 54  1.46824596 2.13251315  0.23042724 4.57031735  1.68927682
## 55  0.62686401 0.54090109  1.72103198 0.59169807  0.34261318
## 56  0.51002925 1.91219574  0.36867026 6.65412988  0.64066612
## 57  1.54529306 1.81882022  1.58085767 0.80841370  0.85108155
## 58  0.79205875 1.18300770  0.77842692 2.23260149  0.38451489
## 59  7.58437953 2.18181560  0.67553929 0.76524055  1.41697788
## 60  3.97388368 5.19089498  1.07132620 1.17384775  1.25960206
## 61  0.25869695 2.21293510  1.58558871 3.58260566  2.68365880
## 62  0.51008122 0.57784188  1.52826153 0.81614522  0.35014099
## 63  0.43037646 0.56239397  0.98235194 0.65586091  1.07499549
## 64  3.19575797 3.60603509  0.93054846 1.84907768  0.79506204
## 65  0.62328139 1.86111485  1.89770025 0.88955890  0.85311817
## 66  0.28463396 1.58695369  0.35888002 4.65579577  0.14525475
## 67  0.63680036 2.69750065  1.49674738 2.07432675  2.42739865
## 68  2.50197811 3.72731815  2.44743170 1.53496375  1.12097038
## 69  0.51996171 1.24901628  0.47045961 3.93144762  1.60712905
## 70  1.21931957 1.49967939  0.06278152 6.60232462  5.80175421
## 71  0.99711180 4.36893597  0.59932030 5.52937599  0.70039947
## 72  8.18706390 2.33475421  0.26611713 2.32800401  1.53131950
## 73  0.81465526 0.25270307  0.20562353 0.61814279  2.59903032
## 74  0.35577331 0.07044937  3.56964738 0.07903719  1.62470926
## 75  1.26925841 0.61109846  1.13141325 0.56279930  0.89731198
## 76  0.88275754 0.52924093  0.41913886 1.21868525  1.99540715
## 77  0.54337381 2.41792606  7.45834142 0.99944789  1.85428849
## 78  0.77058587 0.44515197  3.01817961 0.27480976  0.17327977
## 79  3.77747755 1.20011824  1.64643702 0.56049598  0.41022688
## 80  0.57353533 0.82044077  0.70069568 1.05254385  3.15278028
## 81  5.58836376 0.42645860  1.12455932 0.18289540  0.91675713
## 82  3.05638975 2.05700302  4.30978142 0.58257801  2.32261356
## 83  5.27202423 4.16995009  2.12302852 0.98677268  0.46047235
## 84  4.34103995 5.66492597  1.53849403 1.55829428  0.32685898
## 85  1.51398803 1.68827259  0.14859127 5.80585825  0.76511580
## 86  2.53724567 5.93441489  3.92804618 1.65302009  0.71491704
## 87  0.71432898 1.40600083  0.96572894 2.01071234  3.13034829
## 88  0.46726995 0.42785457  0.95030240 0.67247832  2.00377466
## 89  0.23794374 0.41871390  1.47202360 0.65634468  0.64210236
## 90  0.80190280 3.66460305  0.20841582 9.70177876  2.54368218
## 91  1.06575926 0.91230184  0.22853972 2.23972139  2.61924639
## 92  1.13239149 0.47020459  0.27003545 0.57218937  7.67822839
## 93  0.07134614 0.36386432  0.55278862 2.43127932  1.22264648
## 94  0.52700389 1.23276947  0.51234368 2.25176860  2.17512934
## 95  1.18765987 1.01452132  0.84232773 1.11883627  0.37732709
## 96  0.77176767 0.64482129  1.35601250 0.70482922  4.19633919
## 97  2.21421558 2.15581881  0.76257712 1.43539320  0.14429117
## 98  2.41320231 1.84893261  0.59719127 1.36542595  0.34628296
## 99  1.39880682 3.15591600  1.92636148 2.55830528  0.36561402
## 100 0.45767380 0.44931088  0.08104381 2.85900838  0.15757112

Plots for the first 5 individuals show differing values for each individual but the general distribution of variables and correlations remain the same across individuals.

# Plot the first five individuals to check their data distributions
for (i in 1:min(5, length(individual_data_list))) {
  print(ggpairs(individual_data_list[[i]], 
                upper = list(continuous = "points"), 
                lower = list(continuous = "smooth"), 
                diag = list(continuous = "densityDiag"),
                progress = FALSE) +
          theme_bw() +
          ggtitle(paste("Data for", names(individual_data_list)[i])))
}

Simulation of mixed distributions for 20 individuals Now we want to create a dataset of 20 individuals with mixture of distributions across two groups. We will create half of individuals with linear data and half with exponential data. To do this we use the process of discussed previously to create 2 simulated data sets. The first will have data that is not transformed allowing it to remain linear. The second group will have the data transformed to exponential data. Data is simulated based on the same correlation matrix. The simulated data for the two groups is then combined into one dataframe.

# Define the correlation matrix
correlation_matrix <- simdata::cor_from_upper(
  5,
  rbind(
    c(1, 2, 0.5),
    c(2, 4, 0.6),
    c(3, 4, -0.7)
  )
)

# Define transformations for Group 1 (Linear Data)
transformation_linear <- simdata::function_list(
  v1 = function(z) z[,1],
  v2 = function(z) z[,2],
  v3 = function(z) z[,3],
  v4 = function(z) z[,4],
  v5 = function(z) z[,5]
)

# Define transformations for Group 2 (Exponential Data)
transformation_exponential <- simdata::function_list(
  v1 = function(z) exp(z[,1]),
  v2 = function(z) exp(z[,2]),
  v3 = function(z) exp(z[,3]),
  v4 = function(z) exp(z[,4]),
  v5 = function(z) exp(z[,5])
)

# Simulation design for each group
sim_design_linear <- simdata::simdesign_mvtnorm(
  relations = correlation_matrix,
  transform_initial = transformation_linear
)

sim_design_exponential <- simdata::simdesign_mvtnorm(
  relations = correlation_matrix,
  transform_initial = transformation_exponential
)

# Initialize lists to store each individual's data
data_list_linear <- vector("list", 10)
data_list_exponential <- vector("list", 10)

# Generate data for each individual in both groups
for (i in 1:10) {
  set.seed(12345 + i)
  # Generate linear data
  individual_data_linear <- simulate_data(sim_design_linear, n = 100)  # 100 time points
  data_list_linear[[i]] <- as.data.frame(individual_data_linear)
  
  # Generate exponential data
  individual_data_exponential <- simulate_data(sim_design_exponential, n = 100)  # 100 time points
  data_list_exponential[[i]] <- as.data.frame(individual_data_exponential)
}

# Label the lists 
names(data_list_linear) <- paste("Individual_Linear", 1:10)
names(data_list_exponential) <- paste("Individual_Exponential", 1:10)

# Combine the lists into one list for all individuals
combined_data_list <- c(data_list_linear, data_list_exponential)

# Print or plot data for the first individual in each group to check
print(combined_data_list[[1]])  # First individual with linear data
##              v1           v2          v3          v4          v5
## 1    1.37163724 -0.439145891  1.54435821 -2.07528291 -1.08351909
## 2    1.49304962 -0.463114611 -0.55649445 -0.23427928  1.40161086
## 3   -0.23950107  0.932796585 -0.21505998  0.83886012  0.63431866
## 4   -0.77466839 -1.255604480  0.37144672 -0.96057969  0.96846873
## 5    0.13852553 -0.629169060  0.08919813 -0.82541958 -0.53721187
## 6   -0.83980506  2.049500523  2.08505227  0.41904443  1.00298155
## 7    0.42727631  0.088282919 -0.12797930 -0.06673069 -0.72112621
## 8    0.45841814  1.276663583 -1.17293955  1.91307687 -0.64785965
## 9   -1.49036557 -1.033530758 -1.38701731  0.45024524  1.05726950
## 10  -0.55828815  1.268411130 -0.74859688  1.76359754 -2.14044174
## 11   0.08719256  0.871169810 -0.06798538  0.98048316 -0.75882294
## 12   0.61877079  1.514272890  1.85973063 -0.50337936 -1.22208729
## 13  -0.30118996 -0.577415265 -0.63344889  0.28957986 -2.81754595
## 14   1.04188351 -0.729500468 -1.22932154 -0.16869718  0.05165492
## 15   0.38406727 -1.663247361  0.54202416 -1.99292017 -1.53836552
## 16  -1.06299417  0.436164452  0.32614827  0.73291983 -0.96212135
## 17   0.23579867  0.236684854 -0.57160007  0.64185642 -0.11646840
## 18   1.50353466  0.528592491  1.11157744 -1.32301602  0.36810190
## 19   1.43942516  1.338537536  0.09863477  0.43409214 -1.15180005
## 20  -0.56400298 -0.306412990  0.01601264  0.32721819 -1.48580605
## 21   0.30373643  1.454638259 -0.14699531  1.32151401  2.26651263
## 22   1.29830381 -0.176038238 -0.97365004  0.37467937  0.84989866
## 23   0.74922378  1.370817535  0.46150552  0.52959366 -0.25192846
## 24   0.43309420  0.140741243  1.86207043 -1.21852081 -0.02706756
## 25   1.83760928 -0.054901030 -0.37173060 -0.72208722  0.96526580
## 26  -0.64144215 -0.526371973 -0.75097742  0.21651452 -2.53033542
## 27  -0.10420994  1.577283768 -0.18809030  1.08075593  2.36939126
## 28   0.84055619  0.981753199 -0.15287210  0.50137873 -1.91748232
## 29  -0.10697242  2.067055647 -0.05431540  1.74915993 -0.24135242
## 30   0.51157162  1.210750444  0.60425839  0.47456203  0.01176604
## 31  -1.64854858 -0.276383483 -1.01613289  0.96252199 -0.56920641
## 32  -0.81723404 -1.019459734  0.83672715 -1.05846472  0.79612173
## 33  -1.98271425 -2.043077235  0.81270860 -1.22565337  0.27903494
## 34   0.31541420  0.225376019  1.72650049 -1.03856185  0.09367235
## 35   0.25905544  0.070779385  1.45673761 -1.34300777  0.87797410
## 36   0.76223737 -0.873450291  1.66722429 -2.06651169 -0.25404569
## 37  -0.35912560 -1.497324790 -0.39551510 -0.76097580  1.12358704
## 38   0.08406121 -1.046634019  1.75948387 -2.28241548  0.03103006
## 39   0.96682338 -1.835311137 -0.93062031 -1.30084558 -0.25102725
## 40  -1.45470298  1.033403874  2.42518885 -0.20689676 -1.14535473
## 41  -0.85060399 -0.392326869  0.37708124 -0.25580868 -0.79802749
## 42  -2.43988696 -0.224008284 -1.16418169  1.74312498  1.30065502
## 43  -0.30649377  0.807557755 -0.13774221  0.50731759 -1.34799171
## 44   1.54644525  0.021080742  0.69078924 -0.93488735  0.95866199
## 45  -0.96324960 -1.037600238  1.29575654 -1.60080505  0.62695498
## 46   0.02273154 -1.767363731  0.64117253 -1.83213310 -0.95128167
## 47  -1.32617237 -1.476678216  0.52076286 -0.79325693 -2.02497247
## 48   0.65358859 -1.135027626  1.45671344 -2.00601420 -1.32204150
## 49   1.15617644  1.655540620  0.70368091  0.35587944  0.82893445
## 50   0.44228372  0.009314604 -0.56307022  0.14196301 -0.55321043
## 51   0.90392928 -1.246771274 -0.91737053 -0.80618745 -0.73480004
## 52  -0.98429105 -0.539974899 -0.11019447  0.07526499 -0.95380274
## 53  -0.94440721  0.091169504  0.89494171 -0.07929031  0.16699605
## 54   0.39009891  0.727843926 -1.52394239  1.56092006  0.52430052
## 55  -0.43319397 -0.597170395  0.51153491 -0.58241813 -1.07115322
## 56  -0.67801742  0.707167077 -1.14583613  1.82777608 -0.44524682
## 57   0.36725749  0.606735582  0.52853090 -0.18203688 -0.16124733
## 58  -0.19193672  0.180240481 -0.38142502  0.71330695 -0.95577276
## 59   2.03899756  0.641984646 -0.31317091 -0.16498349  0.34852635
## 60   1.23444770  1.627538477  0.23362105  0.29168378  0.23079584
## 61  -1.44944569  0.954069164  0.35674499  1.15119282  0.98718109
## 62  -0.63815390 -0.515045561  0.35932217 -0.28238098 -1.04941937
## 63  -0.89418054 -0.521986027  0.08995789 -0.34489599  0.07231646
## 64   1.12619197  1.244300100 -0.08703868  0.61482229 -0.22933513
## 65  -0.62841528  0.720321264  0.77745363 -0.05606247 -0.15885721
## 66  -1.35279694  0.575522869 -1.02041661  1.58365654 -1.92926621
## 67  -0.56908045  1.092115094  0.40926326  0.70207674  0.88682017
## 68   0.89428375  1.312367947  0.79281727  0.30372872  0.11419472
## 69  -0.62907965  0.263203120 -0.89399872  1.29588007  0.47444939
## 70   0.20645349  0.353965187 -2.75134055  2.05812732  1.75816032
## 71  -0.08786859  1.534767881 -0.57799182  1.68211231 -0.35610444
## 72   2.20895149  0.672576796 -1.40978607  0.87408954  0.42612978
## 73  -0.14572972 -1.448501189 -1.44313888 -0.28102848  0.95513842
## 74  -0.89614168 -2.671598609  1.29599369 -2.59246509  0.48532888
## 75   0.29186074 -0.536479379  0.12289654 -0.57754116 -0.10835167
## 76  -0.04627618 -0.679552670 -0.90797513  0.21889392  0.69084811
## 77  -0.70708129  1.015741166  1.92781246 -0.18802215  0.61750106
## 78  -0.23433255 -0.803719036  1.12875668 -1.33541497 -1.75284783
## 79   1.40580468  0.080712731  0.44681908 -0.63298828 -0.89104492
## 80  -0.60447672 -0.159377517 -0.27568119  0.12758551  1.14828469
## 81   1.85720167 -1.039607455  0.17686854 -1.63685559 -0.08691269
## 82   1.13907661  0.682678285  1.37617696 -0.67900125  0.84269309
## 83   1.62746064  1.370549642  0.74375745 -0.05045164 -0.77550247
## 84   1.38964909  1.705400875  0.44481240  0.43905997 -1.11822645
## 85   0.47545039  0.465573906 -2.01707524  1.78459969 -0.26772808
## 86   0.86237602  1.810058878  1.26697140  0.34995147 -0.33558877
## 87  -0.34325980  0.379848685 -0.11609322  0.63275805  1.14114427
## 88  -0.74277091 -0.824988191 -0.02608718 -0.37969640  0.69503273
## 89  -1.46483620 -0.778594628  0.42223080 -0.42808660 -0.44300754
## 90  -0.29419609  1.348627468 -1.62128514  2.31264307  0.93361271
## 91   0.09636315 -0.132241660 -1.47640540  0.89104916  0.96288664
## 92   0.10370046 -0.811061463 -1.08632360 -0.30779995  2.03838884
## 93  -2.66415505 -0.848995157 -0.65032240  0.85246171  0.20101776
## 94  -0.69177919  0.264078745 -0.65342693  0.85345276  0.77708813
## 95   0.19386859 -0.005460528 -0.19403118  0.10663420 -0.97464286
## 96  -0.22858558 -0.434801763  0.28009646 -0.38698220  1.43421252
## 97   0.76607871  0.734870568 -0.24720881  0.40087244 -1.93592199
## 98   0.86730135  0.561939380 -0.47930253  0.37592436 -1.06049905
## 99   0.33626696  1.176470667  0.47619084  0.76292312 -1.00617709
## 100 -0.75136826 -0.818581692 -2.45167123  1.23487689 -1.84787836
print(combined_data_list[[11]]) # First individual with exponential data
##             v1         v2         v3          v4         v5
## 1   0.33844230 0.93230054  0.1955768  4.12516143 4.16388413
## 2   1.35153465 0.92513715  0.4981485  1.34226746 0.23813500
## 3   0.35524878 2.04732362  4.9810589  0.90736574 0.42978089
## 4   0.20402825 1.64348740  0.6074994  3.69295019 2.49599342
## 5   0.87069511 0.39826301  1.6397509  0.31208944 1.33375232
## 6   0.82784254 0.53262152  0.4222806  1.30446608 2.12420345
## 7   0.72250416 1.17590098  0.5485478  2.01032900 0.04552915
## 8   0.63303348 0.52333657  0.3192973  1.32176592 1.68323027
## 9   1.36970392 1.29607611  3.2205989  0.39647784 0.77312060
## 10  2.75363333 1.84696387  1.5058393  0.81955304 0.21107008
## 11  1.08291408 2.19296656  2.3736433  1.01141591 0.61368271
## 12  2.51671955 2.96504493  0.7868686  1.60555707 1.14796948
## 13  0.40654061 0.41400818  2.4327286  0.31944502 3.37074536
## 14  2.65176790 1.51296639  2.4130774  0.49685790 1.57883485
## 15  1.08318961 0.33540441  0.5252182  0.67282235 1.32651638
## 16  0.76383678 0.49238573  1.0456549  0.56837770 1.00973351
## 17  0.72158507 0.63101078  2.5328706  0.45668292 2.87734150
## 18  0.47541574 0.36479583  1.3246418  0.36599004 1.70944268
## 19  7.74925299 4.04600295  0.5663769  2.13088250 2.57936429
## 20  0.52506184 1.61714055  0.9062930  3.00946919 0.53647197
## 21  0.43944402 1.23677470  0.1220396  6.73712851 1.10703333
## 22  0.51196011 0.19969082 10.8798838  0.07002309 0.73071218
## 23  2.77052645 2.49059487  0.5180900  2.25344012 0.14192705
## 24  0.09424206 0.40728515  0.8587220  1.36346579 0.43694387
## 25  0.65786409 1.25043244  0.4917991  2.69787515 0.64275469
## 26  0.52165033 0.65877960  0.6739146  1.30189329 0.49237118
## 27  2.05257458 1.24992200  0.4643762  1.77210942 4.56414139
## 28  1.60079588 5.04714655  0.7066342  3.80144266 2.58339509
## 29  1.75351219 0.73886236  1.6814362  0.53176544 0.24809320
## 30  0.48972887 1.06502220  0.6563979  2.27741451 1.35723782
## 31  0.16129346 0.21790881  1.2393394  0.34930846 1.38033213
## 32  9.11446221 4.60873305  0.6347801  1.87761699 0.42730482
## 33  1.01493642 0.77329745  1.2929472  0.65888438 0.62694871
## 34  2.88197614 0.65137482  5.5576426  0.12770071 0.86516346
## 35  2.67884825 9.33985509  4.6460047  1.46661631 1.33091545
## 36  2.64743014 5.60374907  0.4161985  4.64750370 4.62036265
## 37  2.59680596 2.03940045  0.4542794  1.98098968 1.77359093
## 38  0.61253762 0.66731146  0.2430417  2.61481553 6.69571577
## 39  4.26788437 4.64781217  0.6303853  2.63233188 0.10570557
## 40  0.81681455 3.26395813  1.2391147  2.41924420 2.93687411
## 41  1.93380385 0.76846624  1.0007566  0.65636623 0.09533545
## 42  0.74996780 0.43118821  1.5610517  0.40049836 0.46479528
## 43  0.67786223 1.34679305  0.3254084  4.40993230 3.89960573
## 44  0.92384349 0.76699336  0.4337565  1.46220965 4.55853664
## 45  0.50457713 0.35901680  0.6188851  1.02159349 1.64680145
## 46  0.66831434 1.55045470  3.1425567  0.82118361 0.19537303
## 47  0.57756582 1.18293927  0.1091756  6.83949001 2.97962253
## 48  0.20211033 1.03982221  0.2250588  5.20108361 0.77866666
## 49  1.25315560 3.62187577  2.1889932  1.34469407 2.09265191
## 50  2.20893471 1.00171257  3.4151001  0.40783706 2.55455090
## 51  0.31393466 0.84595835  1.1556361  1.23624667 0.37875861
## 52  1.56561255 0.37566995  1.5122373  0.45702284 0.14868468
## 53  1.07083101 0.86875348  0.7253438  1.13165153 0.64784876
## 54  0.88672858 0.77186953  1.9251608  0.60910490 6.44126544
## 55  0.81819232 0.38180007  4.2623239  0.14864466 4.67860882
## 56  0.91793877 1.38391783 18.8042293  0.14412552 0.37899966
## 57  0.57004145 0.40382805  2.3871408  0.26062622 2.14771526
## 58  0.27952438 0.55557597  5.4274203  0.30610601 0.35874804
## 59  0.10293177 0.53508167  1.6109120  0.92194069 1.23816340
## 60  2.95052094 1.69900893  1.7253743  0.66939482 3.12415233
## 61  1.61984628 1.04265618  0.2260999  2.63184051 0.49448024
## 62  2.34527842 0.82761091  2.5281744  0.44052123 5.80336207
## 63  2.84210012 0.77173663  0.9152264  0.52449301 1.79494123
## 64  0.09430305 0.44675297  4.0583998  0.58124929 0.90229263
## 65  6.43850740 1.30422831  4.5490324  0.20679699 0.68306357
## 66  1.08585064 0.96747244  0.2253753  3.56411074 1.21881337
## 67  0.79042949 1.15440919  0.1865555  2.66755739 2.55312214
## 68  2.88244323 1.93326154  0.2823559  3.32441331 1.27423034
## 69  2.48576731 2.45984746  0.7172916  1.60010876 1.93453714
## 70  0.84605585 0.89104013  2.6193525  0.55520243 2.39583359
## 71  0.29317809 0.34539407  0.3471538  1.43010467 0.56401352
## 72  0.21150096 0.63144566  1.4014016  1.05962210 0.45009840
## 73  0.28113734 0.97580503  1.2240525  1.61031796 0.95769783
## 74  0.88573095 2.11262888  4.3184967  0.58581755 0.20038606
## 75  1.55582995 5.47293140  0.2036935 10.57106320 0.77023940
## 76  0.24721802 0.08143522  4.3620868  0.05154442 3.21705303
## 77  1.02425321 0.84488702  2.1133280  0.48614585 3.37842014
## 78  0.42271325 0.16958423  1.0523163  0.35035559 0.38593524
## 79  0.52909842 3.11094919  1.0935732  3.25421324 1.56124377
## 80  1.93589063 2.67354753  0.4639961  2.19115415 0.38942553
## 81  2.89765237 0.70350071  1.4778931  0.31400057 0.22308740
## 82  0.25415231 0.23470197  0.4284418  0.90741737 4.13901826
## 83  3.13252974 5.01080472  1.3689538  2.34442274 0.12138767
## 84  3.38291089 4.81687471  0.1957939  8.68206843 0.41943743
## 85  1.59302979 0.88858148  9.3671941  0.16818052 0.85802800
## 86  2.84829579 5.68248115  2.6274416  1.71400311 2.36534184
## 87  0.93052417 0.82370905  0.3890214  1.58804683 1.69524665
## 88  0.46597059 0.47420747  2.2285272  0.41876921 2.44755817
## 89  4.46518609 1.39765526  0.1981105  2.28215584 0.16762385
## 90  0.20651533 0.08240967  0.6377915  0.40830461 0.63711617
## 91  0.42801503 1.44818730  0.3717473  3.33801042 1.72034224
## 92  0.47005008 1.22387989  0.5579741  2.80292053 1.22300815
## 93  1.23047805 2.53564159  2.0015707  1.18834044 1.67564841
## 94  0.73822368 0.81950405  1.1018867  0.83649220 0.30422397
## 95  0.24122184 0.48477753  0.3272695  1.44088347 0.24016254
## 96  2.13252658 1.03876632  1.1002893  0.67761314 1.93421279
## 97  0.35631885 0.42950057  0.2717512  1.59565130 0.84580134
## 98  1.39538747 0.52538233  0.5004822  1.19288596 0.50099687
## 99  5.00124077 4.25889530  4.7199071  0.39117334 0.10380081
## 100 1.31637298 1.00657845  1.3525127  0.75748295 0.23112318

Finally, we plot the data for the first 5 individuals of each group (linear and exponential). As seen in the plot.

# Plot first 5 linear and first 5 exponential
indices <- c(1:5, 11:15)
for (i in indices) {
  if (i <= length(combined_data_list)) {
    print(ggpairs(combined_data_list[[i]], 
                  upper = list(continuous = "points"), 
                  lower = list(continuous = "smooth"), 
                  diag = list(continuous = "densityDiag"),
                  progress = FALSE) +
            theme_bw() +
            ggtitle(paste("Data for", names(combined_data_list)[i])))
  }
}