Compute sets of compositions and log ratio transformation for multilevel compositional data
Arguments
- data
A
data.frame
ordata.table
containing data of all variables used in the analysis. It must include a composition and a ID variable. Required.- parts
A character vector specifying the names of compositional variables to be used. For multiple compositions, a list of character vectors.
- sbp
A signary matrix indicating sequential binary partition when
transform = "ilr"
. If not supplied, a default sequential binary partition (sbp) will be built using functionbuild.sbp
. For multiple compositions, a list of sbps can be supplied.- total
A numeric value of the total amount to which the compositions should be closed. For multiple compositions, a list of numeric values. Default is
1
.- idvar
Only for multilevel data, a character string specifying the name of the variable containing participants IDs.
- transform
A character value naming a log ratio transformation to be applied on compositional data. Can be either
"ilr"
(isometric logratio),"alr"
(additive logratio), or"clr"
(centered logratio). Default is"ilr"
.
Value
A complr
object with at least the following elements.
X
A vector of class
acomp
representing one closed composition or a matrix of classacomp
representing multiple closed compositions each in one row.bX
A vector of class
acomp
representing one closed between-person composition or a matrix of classacomp
representing multiple closed between-person compositions each in one row.wX
A vector of class
acomp
representing one closed within-person composition or a matrix of classacomp
representing multiple closed within-person compositions each in one row.Z
Log ratio transform of composition.
bZ
Log ratio transform of between-person composition.
wZ
Log ratio transform of within-person composition.
data
The user's dataset or imputed dataset if the iiut data contains zeros.
transform
Type of transform applied on compositional data.
parts
Names of compositional variables.
idvar
Name of the variable containing IDs.
total
Total amount to which the compositions is closed.
Details
The ilr-transform maps the D-part compositional data from the simplex into non-overlapping subgroups in the (D-1)-dimension Euclidean space isometrically by using an orthonormal basis, thereby preserving the compositional properties and yielding a full-rank covariance matrix. ilr transformation should be preferred. However, the alr and clr are alternatives. The alr-transform maps a D-part composition in the Aitchison-simplex non-isometrically to a (D-1)-dimension Euclidian vectors, commonly treating the last part as the common denominator of the others. alr transformation does not rely on distance which breaks the constraint of compositional data. clr-transform maps a D-part composition in the Aitchison-simplex isometrically to a D-dimensional Euclidian vector subspace. clr transformation is not injetive, resulting in singular covariance matrices.
Examples
x1 <- complr(data = mcompd,
parts = c("TST", "WAKE", "MVPA", "LPA", "SB"),
idvar = "ID", total = 1440)
#> A sequential binary partition (sbp), is required for ilr transform but is not supplied.
#> A default sbp, which is a pivot balance, will be applied.
str(x1)
#> List of 5
#> $ output :List of 1
#> ..$ :List of 11
#> .. ..$ X : 'acomp' num [1:3540, 1:5] 542.4 458.3 270.8 525 651 99.1 49 41 76 86 297.2 117.1 488.7 259 112 460.3 653.5 624.6 398 436 41 162.1 15 182 155 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. ..$ bX : 'acomp' num [1:3540, 1:5] 494.2 494.2 494.2 494.2 494.2 72.3 72.3 72.3 72.3 72.3 249.3 249.3 249.3 249.3 249.3 503.9 503.9 503.9 503.9 503.| __truncated__ ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "bTST" "bWAKE" "bMVPA" "bLPA" ...
#> .. ..$ wX : 'acomp' num [1:3540, 1:5] 0.2233 0.1965 0.1234 0.1948 0.2578 0.279 0.1438 0.1277 0.1928 0.233 0.2426 0.0995 0.4416 0.1905 0.0879 0.1859 0.2| __truncated__ ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "wTST" "wWAKE" "wMVPA" "wLPA" ...
#> .. ..$ Z : 'rmult' num [1:3540, 1:4] 1.1286 0.958 0.7506 0.889 1.2567 -0.5061 -1.344 -1.2117 -1.084 -0.7149 0.6298 -0.8348 1.3223 -0.0314 -0.6875 1.70| __truncated__ ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:5] 0.3767 0.3183 0.1881 0.3646 0.4521 0.0688 0.0341 0.0285 0.0528 0.0597 0.2064 0.0813 0.3393 0.1799 0.0778 0.3197 0| __truncated__ ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:5] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. .. ..- attr(*, "V")= num [1:5, 1:4] 0.894 -0.224 -0.224 -0.224 -0.224 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:4] "z1_1" "z2_1" "z3_1" "z4_1"
#> .. ..$ bZ : 'rmult' num [1:3540, 1:4] 0.89436 0.89436 0.89436 0.89436 0.89436 -1.06558 -1.06558 -1.06558 -1.06558 -1.06558 0.00968 0.00968 0.00968 0.00| __truncated__ ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:5] 0.3432 0.3432 0.3432 0.3432 0.3432 0.0502 0.0502 0.0502 0.0502 0.0502 0.1731 0.1731 0.1731 0.1731 0.1731 0.3499 0| __truncated__ ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:5] "bTST" "bWAKE" "bMVPA" "bLPA" ...
#> .. .. ..- attr(*, "V")= num [1:5, 1:4] 0.894 -0.224 -0.224 -0.224 -0.224 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:4] "bz1_1" "bz2_1" "bz3_1" "bz4_1"
#> .. ..$ wZ : 'rmult' num [1:3540, 1:4] 0.23428 0.06364 -0.14377 -0.00539 0.36234 0.55948 -0.27846 -0.14612 -0.01842 0.35066 0.62011 -0.84448 1.31261 -0.| __truncated__ ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:5] 0.2233 0.1965 0.1234 0.1948 0.2578 0.279 0.1438 0.1277 0.1928 0.233 0.2426 0.0995 0.4416 0.1905 0.0879 0.1859 0.2| __truncated__ ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:5] "wTST" "wWAKE" "wMVPA" "wLPA" ...
#> .. .. ..- attr(*, "V")= num [1:5, 1:4] 0.894 -0.224 -0.224 -0.224 -0.224 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:4] "wz1_1" "wz2_1" "wz3_1" "wz4_1"
#> .. ..$ dataout: num [1:3540, 1:27] 542 458 271 525 651 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:27] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. ..$ parts : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. ..$ total : num 1440
#> .. ..$ sbp : num [1:4, 1:5] 1 0 0 0 -1 1 0 0 -1 -1 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. ..$ psi : num [1:5, 1:4] 0.894 -0.224 -0.224 -0.224 -0.224 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. .. .. ..$ : NULL
#> $ datain :Classes ‘data.table’ and 'data.frame': 3540 obs. of 10 variables:
#> ..$ ID : num [1:3540] 185 185 185 185 185 185 185 185 185 185 ...
#> ..$ Time : num [1:3540] 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ Stress: num [1:3540] 4 7 3 2 8 8 6 2 5 0 ...
#> ..$ TST : num [1:3540] 542 458 271 525 651 431 501 518 458 510 ...
#> ..$ WAKE : num [1:3540] 99 49 41 76 86 84 29 32 72 143 ...
#> ..$ MVPA : num [1:3540] 297 117 489 259 112 264 458 111 398 145 ...
#> ..$ LPA : num [1:3540] 460 653 625 398 436 476 283 670 466 577 ...
#> ..$ SB : num [1:3540] 41 162 15 182 155 185 169 110 47 64 ...
#> ..$ Age : num [1:3540] 30 30 30 30 30 30 30 30 30 30 ...
#> ..$ Female: num [1:3540] 0 0 0 0 0 0 0 0 0 0 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> ..- attr(*, "index")= int(0)
#> .. ..- attr(*, "__ID")= int [1:3540] 981 982 983 984 985 986 987 988 989 990 ...
#> $ dataout :Classes ‘data.table’ and 'data.frame': 3540 obs. of 37 variables:
#> ..$ ID : num [1:3540] 185 185 185 185 185 185 185 185 185 185 ...
#> ..$ Time : num [1:3540] 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ Stress: num [1:3540] 4 7 3 2 8 8 6 2 5 0 ...
#> ..$ TST : num [1:3540] 542 458 271 525 651 431 501 518 458 510 ...
#> ..$ WAKE : num [1:3540] 99 49 41 76 86 84 29 32 72 143 ...
#> ..$ MVPA : num [1:3540] 297 117 489 259 112 264 458 111 398 145 ...
#> ..$ LPA : num [1:3540] 460 653 625 398 436 476 283 670 466 577 ...
#> ..$ SB : num [1:3540] 41 162 15 182 155 185 169 110 47 64 ...
#> ..$ Age : num [1:3540] 30 30 30 30 30 30 30 30 30 30 ...
#> ..$ Female: num [1:3540] 0 0 0 0 0 0 0 0 0 0 ...
#> ..$ tTST : num [1:3540] 542 458 271 525 651 ...
#> ..$ tWAKE : num [1:3540] 99.1 49 41 76 86 ...
#> ..$ tMVPA : num [1:3540] 297 117 489 259 112 ...
#> ..$ tLPA : num [1:3540] 460 653 625 398 436 ...
#> ..$ tSB : num [1:3540] 41 162 15 182 155 ...
#> ..$ bTST : num [1:3540] 494 494 494 494 494 ...
#> ..$ bWAKE : num [1:3540] 72.3 72.3 72.3 72.3 72.3 ...
#> ..$ bMVPA : num [1:3540] 249 249 249 249 249 ...
#> ..$ bLPA : num [1:3540] 504 504 504 504 504 ...
#> ..$ bSB : num [1:3540] 120 120 120 120 120 ...
#> ..$ wTST : num [1:3540] 0.223 0.197 0.123 0.195 0.258 ...
#> ..$ wWAKE : num [1:3540] 0.279 0.144 0.128 0.193 0.233 ...
#> ..$ wMVPA : num [1:3540] 0.2426 0.0995 0.4416 0.1905 0.0879 ...
#> ..$ wLPA : num [1:3540] 0.186 0.275 0.279 0.145 0.169 ...
#> ..$ wSB : num [1:3540] 0.0693 0.2853 0.028 0.2771 0.2519 ...
#> ..$ z1_1 : num [1:3540] 1.129 0.958 0.751 0.889 1.257 ...
#> ..$ z2_1 : num [1:3540] -0.506 -1.344 -1.212 -1.084 -0.715 ...
#> ..$ z3_1 : num [1:3540] 0.6298 -0.8348 1.3223 -0.0314 -0.6875 ...
#> ..$ z4_1 : num [1:3540] 1.71 0.986 2.637 0.553 0.731 ...
#> ..$ bz1_1 : num [1:3540] 0.894 0.894 0.894 0.894 0.894 ...
#> ..$ bz2_1 : num [1:3540] -1.07 -1.07 -1.07 -1.07 -1.07 ...
#> ..$ bz3_1 : num [1:3540] 0.00968 0.00968 0.00968 0.00968 0.00968 ...
#> ..$ bz4_1 : num [1:3540] 1.01 1.01 1.01 1.01 1.01 ...
#> ..$ wz1_1 : num [1:3540] 0.23428 0.06364 -0.14377 -0.00539 0.36234 ...
#> ..$ wz2_1 : num [1:3540] 0.5595 -0.2785 -0.1461 -0.0184 0.3507 ...
#> ..$ wz3_1 : num [1:3540] 0.62 -0.844 1.313 -0.041 -0.697 ...
#> ..$ wz4_1 : num [1:3540] 0.6975 -0.0264 1.6252 -0.4588 -0.2808 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> $ transform: chr "ilr"
#> $ idvar : chr "ID"
#> - attr(*, "class")= chr "complr"
x2 <- complr(data = mcompd,
parts = list(c("TST", "WAKE"), c("MVPA", "LPA", "SB")),
total = list(c(480), c(960)),
idvar = "ID",
transform = "ilr")
#> A sequential binary partition (sbp), is required for ilr transform but is not supplied.
#> A default sbp, which is a pivot balance, will be applied.
#> A sequential binary partition (sbp), is required for ilr transform but is not supplied.
#> A default sbp, which is a pivot balance, will be applied.
str(x2)
#> List of 5
#> $ output :List of 2
#> ..$ :List of 11
#> .. ..$ X : 'acomp' num [1:3540, 1:2] 405.9 433.6 416.9 419.3 424 74.1 46.4 63.1 60.7 56 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:2] "tTST" "tWAKE"
#> .. ..$ bX : 'acomp' num [1:3540, 1:2] 418.8 418.8 418.8 418.8 418.8 61.2 61.2 61.2 61.2 61.2 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:2] "bTST" "bWAKE"
#> .. ..$ wX : 'acomp' num [1:3540, 1:2] 0.445 0.577 0.491 0.502 0.525 0.555 0.423 0.509 0.498 0.475 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:2] "wTST" "wWAKE"
#> .. ..$ Z : 'rmult' num [1:3540, 1] 1.2 1.58 1.34 1.37 1.43 ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:2] 0.8456 0.9034 0.8686 0.8735 0.8833 0.1544 0.0966 0.1314 0.1265 0.1167 ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:2] "tTST" "tWAKE"
#> .. .. ..- attr(*, "V")= num [1:2, 1] 0.707 -0.707
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr "z1_1"
#> .. ..$ bZ : 'rmult' num [1:3540, 1] 1.36 1.36 1.36 1.36 1.36 ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:2] 0.872 0.872 0.872 0.872 0.872 0.128 0.128 0.128 0.128 0.128 ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:2] "bTST" "bWAKE"
#> .. .. ..- attr(*, "V")= num [1:2, 1] 0.707 -0.707
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr "bz1_1"
#> .. ..$ wZ : 'rmult' num [1:3540, 1] -0.1574 0.22084 -0.02418 0.00702 0.07172 ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:2] 0.445 0.577 0.491 0.502 0.525 0.555 0.423 0.509 0.498 0.475 ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:2] "wTST" "wWAKE"
#> .. .. ..- attr(*, "V")= num [1:2, 1] 0.707 -0.707
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr "wz1_1"
#> .. ..$ dataout: num [1:3540, 1:9] 406 434 417 419 424 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:9] "tTST" "tWAKE" "bTST" "bWAKE" ...
#> .. ..$ parts : chr [1:2] "TST" "WAKE"
#> .. ..$ total : num 480
#> .. ..$ sbp : num [1, 1:2] 1 -1
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:2] "TST" "WAKE"
#> .. ..$ psi : num [1:2, 1] 0.707 -0.707
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : chr [1:2] "TST" "WAKE"
#> .. .. .. ..$ : NULL
#> ..$ :List of 11
#> .. ..$ X : 'acomp' num [1:3540, 1:3] 357.3 120.5 415.8 296.4 152.9 553.4 672.6 531.4 455.4 595.4 49.3 166.9 12.8 208.2 211.7 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:3] "tMVPA" "tLPA" "tSB"
#> .. ..$ bX : 'acomp' num [1:3540, 1:3] 274 274 274 274 274 554 554 554 554 554 132 132 132 132 132 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:3] "bMVPA" "bLPA" "bSB"
#> .. ..$ wX : 'acomp' num [1:3540, 1:3] 0.4873 0.1509 0.5897 0.3111 0.1727 0.3734 0.4166 0.3729 0.2365 0.3326 0.1393 0.4325 0.0374 0.4525 0.4947 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:3] "wMVPA" "wLPA" "wSB"
#> .. ..$ Z : 'rmult' num [1:3540, 1:2] 0.6298 -0.8348 1.3223 -0.0314 -0.6875 1.7095 0.9857 2.6373 0.5533 0.7313 ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:3] 0.3722 0.1255 0.4331 0.3087 0.1593 0.5764 0.7006 0.5536 0.4744 0.6202 0.0514 0.1738 0.0133 0.2169 0.2205 ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:3] "tMVPA" "tLPA" "tSB"
#> .. .. ..- attr(*, "V")= num [1:3, 1:2] 8.16e-01 -4.08e-01 -4.08e-01 -2.02e-17 7.07e-01 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:2] "z1_2" "z2_2"
#> .. ..$ bZ : 'rmult' num [1:3540, 1:2] 0.00968 0.00968 0.00968 0.00968 0.00968 1.01207 1.01207 1.01207 1.01207 1.01207 ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:3] 0.285 0.285 0.285 0.285 0.285 0.577 0.577 0.577 0.577 0.577 0.138 0.138 0.138 0.138 0.138 ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:3] "bMVPA" "bLPA" "bSB"
#> .. .. ..- attr(*, "V")= num [1:3, 1:2] 8.16e-01 -4.08e-01 -4.08e-01 -2.02e-17 7.07e-01 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:2] "bz1_2" "bz2_2"
#> .. ..$ wZ : 'rmult' num [1:3540, 1:2] 0.6201 -0.8445 1.3126 -0.041 -0.6972 0.6975 -0.0264 1.6252 -0.4588 -0.2808 ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:3] 0.4873 0.1509 0.5897 0.3111 0.1727 0.3734 0.4166 0.3729 0.2365 0.3326 0.1393 0.4325 0.0374 0.4525 0.4947 ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:3] "wMVPA" "wLPA" "wSB"
#> .. .. ..- attr(*, "V")= num [1:3, 1:2] 8.16e-01 -4.08e-01 -4.08e-01 -2.02e-17 7.07e-01 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:2] "wz1_2" "wz2_2"
#> .. ..$ dataout: num [1:3540, 1:15] 357 121 416 296 153 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:15] "tMVPA" "tLPA" "tSB" "bMVPA" ...
#> .. ..$ parts : chr [1:3] "MVPA" "LPA" "SB"
#> .. ..$ total : num 960
#> .. ..$ sbp : num [1:2, 1:3] 1 0 -1 1 -1 -1
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:3] "MVPA" "LPA" "SB"
#> .. ..$ psi : num [1:3, 1:2] 0.816 -0.408 -0.408 0 0.707 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : chr [1:3] "MVPA" "LPA" "SB"
#> .. .. .. ..$ : NULL
#> $ datain :Classes ‘data.table’ and 'data.frame': 3540 obs. of 10 variables:
#> ..$ ID : num [1:3540] 185 185 185 185 185 185 185 185 185 185 ...
#> ..$ Time : num [1:3540] 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ Stress: num [1:3540] 4 7 3 2 8 8 6 2 5 0 ...
#> ..$ TST : num [1:3540] 542 458 271 525 651 431 501 518 458 510 ...
#> ..$ WAKE : num [1:3540] 99 49 41 76 86 84 29 32 72 143 ...
#> ..$ MVPA : num [1:3540] 297 117 489 259 112 264 458 111 398 145 ...
#> ..$ LPA : num [1:3540] 460 653 625 398 436 476 283 670 466 577 ...
#> ..$ SB : num [1:3540] 41 162 15 182 155 185 169 110 47 64 ...
#> ..$ Age : num [1:3540] 30 30 30 30 30 30 30 30 30 30 ...
#> ..$ Female: num [1:3540] 0 0 0 0 0 0 0 0 0 0 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> ..- attr(*, "index")= int(0)
#> .. ..- attr(*, "__ID")= int [1:3540] 981 982 983 984 985 986 987 988 989 990 ...
#> $ dataout :Classes ‘data.table’ and 'data.frame': 3540 obs. of 34 variables:
#> ..$ ID : num [1:3540] 185 185 185 185 185 185 185 185 185 185 ...
#> ..$ Time : num [1:3540] 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ Stress: num [1:3540] 4 7 3 2 8 8 6 2 5 0 ...
#> ..$ TST : num [1:3540] 542 458 271 525 651 431 501 518 458 510 ...
#> ..$ WAKE : num [1:3540] 99 49 41 76 86 84 29 32 72 143 ...
#> ..$ MVPA : num [1:3540] 297 117 489 259 112 264 458 111 398 145 ...
#> ..$ LPA : num [1:3540] 460 653 625 398 436 476 283 670 466 577 ...
#> ..$ SB : num [1:3540] 41 162 15 182 155 185 169 110 47 64 ...
#> ..$ Age : num [1:3540] 30 30 30 30 30 30 30 30 30 30 ...
#> ..$ Female: num [1:3540] 0 0 0 0 0 0 0 0 0 0 ...
#> ..$ tTST : num [1:3540] 406 434 417 419 424 ...
#> ..$ tWAKE : num [1:3540] 74.1 46.4 63.1 60.7 56 ...
#> ..$ bTST : num [1:3540] 419 419 419 419 419 ...
#> ..$ bWAKE : num [1:3540] 61.2 61.2 61.2 61.2 61.2 ...
#> ..$ wTST : num [1:3540] 0.445 0.577 0.491 0.502 0.525 ...
#> ..$ wWAKE : num [1:3540] 0.555 0.423 0.509 0.498 0.475 ...
#> ..$ z1_1 : num [1:3540] 1.2 1.58 1.34 1.37 1.43 ...
#> ..$ bz1_1 : num [1:3540] 1.36 1.36 1.36 1.36 1.36 ...
#> ..$ wz1_1 : num [1:3540] -0.1574 0.22084 -0.02418 0.00702 0.07172 ...
#> ..$ tMVPA : num [1:3540] 357 121 416 296 153 ...
#> ..$ tLPA : num [1:3540] 553 673 531 455 595 ...
#> ..$ tSB : num [1:3540] 49.3 166.9 12.8 208.2 211.7 ...
#> ..$ bMVPA : num [1:3540] 274 274 274 274 274 ...
#> ..$ bLPA : num [1:3540] 554 554 554 554 554 ...
#> ..$ bSB : num [1:3540] 132 132 132 132 132 ...
#> ..$ wMVPA : num [1:3540] 0.487 0.151 0.59 0.311 0.173 ...
#> ..$ wLPA : num [1:3540] 0.373 0.417 0.373 0.236 0.333 ...
#> ..$ wSB : num [1:3540] 0.1393 0.4325 0.0374 0.4525 0.4947 ...
#> ..$ z1_2 : num [1:3540] 0.6298 -0.8348 1.3223 -0.0314 -0.6875 ...
#> ..$ z2_2 : num [1:3540] 1.71 0.986 2.637 0.553 0.731 ...
#> ..$ bz1_2 : num [1:3540] 0.00968 0.00968 0.00968 0.00968 0.00968 ...
#> ..$ bz2_2 : num [1:3540] 1.01 1.01 1.01 1.01 1.01 ...
#> ..$ wz1_2 : num [1:3540] 0.62 -0.844 1.313 -0.041 -0.697 ...
#> ..$ wz2_2 : num [1:3540] 0.6975 -0.0264 1.6252 -0.4588 -0.2808 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> $ transform: chr "ilr"
#> $ idvar : chr "ID"
#> - attr(*, "class")= chr "complr"
x3 <- complr(data = mcompd, sbp = sbp,
parts = c("TST", "WAKE", "MVPA", "LPA", "SB"),
idvar = "ID",
transform = "ilr")
str(x3)
#> List of 5
#> $ output :List of 1
#> ..$ :List of 11
#> .. ..$ X : 'acomp' num [1:3540, 1:5] 0.3767 0.3183 0.1881 0.3646 0.4521 0.0688 0.0341 0.0285 0.0528 0.0597 0.2064 0.0813 0.3393 0.1799 0.0778 0.3197 0| __truncated__ ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. ..$ bX : 'acomp' num [1:3540, 1:5] 0.3432 0.3432 0.3432 0.3432 0.3432 0.0502 0.0502 0.0502 0.0502 0.0502 0.1731 0.1731 0.1731 0.1731 0.1731 0.3499 0| __truncated__ ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "bTST" "bWAKE" "bMVPA" "bLPA" ...
#> .. ..$ wX : 'acomp' num [1:3540, 1:5] 0.2233 0.1965 0.1234 0.1948 0.2578 0.279 0.1438 0.1277 0.1928 0.233 0.2426 0.0995 0.4416 0.1905 0.0879 0.1859 0.2| __truncated__ ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "wTST" "wWAKE" "wMVPA" "wLPA" ...
#> .. ..$ Z : 'rmult' num [1:3540, 1:4] 0.291 -0.4759 -0.4983 -0.3126 0.2044 1.2022 1.5804 1.3354 1.3666 1.4313 0.6298 -0.8348 1.3223 -0.0314 -0.6875 1.7| __truncated__ ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:5] 0.3767 0.3183 0.1881 0.3646 0.4521 0.0688 0.0341 0.0285 0.0528 0.0597 0.2064 0.0813 0.3393 0.1799 0.0778 0.3197 0| __truncated__ ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:5] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. .. ..- attr(*, "V")= num [1:5, 1:4] 0.548 0.548 -0.365 -0.365 -0.365 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:4] "z1_1" "z2_1" "z3_1" "z4_1"
#> .. ..$ bZ : 'rmult' num [1:3540, 1:4] -0.29473 -0.29473 -0.29473 -0.29473 -0.29473 1.35958 1.35958 1.35958 1.35958 1.35958 0.00968 0.00968 0.00968 0.00| __truncated__ ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:5] 0.3432 0.3432 0.3432 0.3432 0.3432 0.0502 0.0502 0.0502 0.0502 0.0502 0.1731 0.1731 0.1731 0.1731 0.1731 0.3499 0| __truncated__ ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:5] "bTST" "bWAKE" "bMVPA" "bLPA" ...
#> .. .. ..- attr(*, "V")= num [1:5, 1:4] 0.548 0.548 -0.365 -0.365 -0.365 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:4] "bz1_1" "bz2_1" "bz3_1" "bz4_1"
#> .. ..$ wZ : 'rmult' num [1:3540, 1:4] 0.58577 -0.18117 -0.20356 -0.01787 0.49911 -0.1574 0.22084 -0.02418 0.00702 0.07172 0.62011 -0.84448 1.31261 -0.0| __truncated__ ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:3540, 1:5] 0.2233 0.1965 0.1234 0.1948 0.2578 0.279 0.1438 0.1277 0.1928 0.233 0.2426 0.0995 0.4416 0.1905 0.0879 0.1859 0.2| __truncated__ ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:5] "wTST" "wWAKE" "wMVPA" "wLPA" ...
#> .. .. ..- attr(*, "V")= num [1:5, 1:4] 0.548 0.548 -0.365 -0.365 -0.365 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:4] "wz1_1" "wz2_1" "wz3_1" "wz4_1"
#> .. ..$ dataout: num [1:3540, 1:27] 0.377 0.318 0.188 0.365 0.452 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:27] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. ..$ parts : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. ..$ total : num 1
#> .. ..$ sbp : num [1:4, 1:5] 1 1 0 0 1 -1 0 0 -1 0 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. ..$ psi : num [1:5, 1:4] 0.548 0.548 -0.365 -0.365 -0.365 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. .. .. ..$ : NULL
#> $ datain :Classes ‘data.table’ and 'data.frame': 3540 obs. of 10 variables:
#> ..$ ID : num [1:3540] 185 185 185 185 185 185 185 185 185 185 ...
#> ..$ Time : num [1:3540] 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ Stress: num [1:3540] 4 7 3 2 8 8 6 2 5 0 ...
#> ..$ TST : num [1:3540] 542 458 271 525 651 431 501 518 458 510 ...
#> ..$ WAKE : num [1:3540] 99 49 41 76 86 84 29 32 72 143 ...
#> ..$ MVPA : num [1:3540] 297 117 489 259 112 264 458 111 398 145 ...
#> ..$ LPA : num [1:3540] 460 653 625 398 436 476 283 670 466 577 ...
#> ..$ SB : num [1:3540] 41 162 15 182 155 185 169 110 47 64 ...
#> ..$ Age : num [1:3540] 30 30 30 30 30 30 30 30 30 30 ...
#> ..$ Female: num [1:3540] 0 0 0 0 0 0 0 0 0 0 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> ..- attr(*, "index")= int(0)
#> .. ..- attr(*, "__ID")= int [1:3540] 981 982 983 984 985 986 987 988 989 990 ...
#> $ dataout :Classes ‘data.table’ and 'data.frame': 3540 obs. of 37 variables:
#> ..$ ID : num [1:3540] 185 185 185 185 185 185 185 185 185 185 ...
#> ..$ Time : num [1:3540] 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ Stress: num [1:3540] 4 7 3 2 8 8 6 2 5 0 ...
#> ..$ TST : num [1:3540] 542 458 271 525 651 431 501 518 458 510 ...
#> ..$ WAKE : num [1:3540] 99 49 41 76 86 84 29 32 72 143 ...
#> ..$ MVPA : num [1:3540] 297 117 489 259 112 264 458 111 398 145 ...
#> ..$ LPA : num [1:3540] 460 653 625 398 436 476 283 670 466 577 ...
#> ..$ SB : num [1:3540] 41 162 15 182 155 185 169 110 47 64 ...
#> ..$ Age : num [1:3540] 30 30 30 30 30 30 30 30 30 30 ...
#> ..$ Female: num [1:3540] 0 0 0 0 0 0 0 0 0 0 ...
#> ..$ tTST : num [1:3540] 0.377 0.318 0.188 0.365 0.452 ...
#> ..$ tWAKE : num [1:3540] 0.0688 0.0341 0.0285 0.0528 0.0597 ...
#> ..$ tMVPA : num [1:3540] 0.2064 0.0813 0.3393 0.1799 0.0778 ...
#> ..$ tLPA : num [1:3540] 0.32 0.454 0.434 0.276 0.303 ...
#> ..$ tSB : num [1:3540] 0.0285 0.1126 0.0104 0.1264 0.1076 ...
#> ..$ bTST : num [1:3540] 0.343 0.343 0.343 0.343 0.343 ...
#> ..$ bWAKE : num [1:3540] 0.0502 0.0502 0.0502 0.0502 0.0502 ...
#> ..$ bMVPA : num [1:3540] 0.173 0.173 0.173 0.173 0.173 ...
#> ..$ bLPA : num [1:3540] 0.35 0.35 0.35 0.35 0.35 ...
#> ..$ bSB : num [1:3540] 0.0836 0.0836 0.0836 0.0836 0.0836 ...
#> ..$ wTST : num [1:3540] 0.223 0.197 0.123 0.195 0.258 ...
#> ..$ wWAKE : num [1:3540] 0.279 0.144 0.128 0.193 0.233 ...
#> ..$ wMVPA : num [1:3540] 0.2426 0.0995 0.4416 0.1905 0.0879 ...
#> ..$ wLPA : num [1:3540] 0.186 0.275 0.279 0.145 0.169 ...
#> ..$ wSB : num [1:3540] 0.0693 0.2853 0.028 0.2771 0.2519 ...
#> ..$ z1_1 : num [1:3540] 0.291 -0.476 -0.498 -0.313 0.204 ...
#> ..$ z2_1 : num [1:3540] 1.2 1.58 1.34 1.37 1.43 ...
#> ..$ z3_1 : num [1:3540] 0.6298 -0.8348 1.3223 -0.0314 -0.6875 ...
#> ..$ z4_1 : num [1:3540] 1.71 0.986 2.637 0.553 0.731 ...
#> ..$ bz1_1 : num [1:3540] -0.295 -0.295 -0.295 -0.295 -0.295 ...
#> ..$ bz2_1 : num [1:3540] 1.36 1.36 1.36 1.36 1.36 ...
#> ..$ bz3_1 : num [1:3540] 0.00968 0.00968 0.00968 0.00968 0.00968 ...
#> ..$ bz4_1 : num [1:3540] 1.01 1.01 1.01 1.01 1.01 ...
#> ..$ wz1_1 : num [1:3540] 0.5858 -0.1812 -0.2036 -0.0179 0.4991 ...
#> ..$ wz2_1 : num [1:3540] -0.1574 0.22084 -0.02418 0.00702 0.07172 ...
#> ..$ wz3_1 : num [1:3540] 0.62 -0.844 1.313 -0.041 -0.697 ...
#> ..$ wz4_1 : num [1:3540] 0.6975 -0.0264 1.6252 -0.4588 -0.2808 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> $ transform: chr "ilr"
#> $ idvar : chr "ID"
#> - attr(*, "class")= chr "complr"
x_wide <- complr(data = mcompd[!duplicated(ID)], sbp = sbp,
parts = c("TST", "WAKE", "MVPA", "LPA", "SB"))
str(x_wide)
#> List of 5
#> $ output :List of 1
#> ..$ :List of 11
#> .. ..$ X : 'acomp' num [1:266, 1:5] 0.3767 0.3569 0.2771 0.4357 0.3678 0.0688 0.0437 0.0826 0.0368 0.05 0.2064 0.0785 0.0229 0.0716 0.0749 0.3197 0.3| __truncated__ ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. ..$ bX : NULL
#> .. ..$ wX : NULL
#> .. ..$ Z : 'rmult' num [1:266, 1:4] 0.291 -0.339 0.211 -0.218 -0.232 1.202 1.484 0.855 1.747 1.412 0.63 -0.949 -2.076 -0.943 -0.985 1.71 0.386 0.484 0.108 0.228 ...
#> .. .. ..- attr(*, "orig")= 'acomp' num [1:266, 1:5] 0.3767 0.3569 0.2771 0.4357 0.3678 0.0688 0.0437 0.0826 0.0368 0.05 0.2064 0.0785 0.0229 0.0716 0.0749 0.3197 0.3| __truncated__ ...
#> .. .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. .. ..$ : NULL
#> .. .. .. .. ..$ : chr [1:5] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. .. ..- attr(*, "V")= num [1:5, 1:4] 0.548 0.548 -0.365 -0.365 -0.365 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:4] "z1_1" "z2_1" "z3_1" "z4_1"
#> .. ..$ bZ : NULL
#> .. ..$ wZ : NULL
#> .. ..$ dataout: num [1:266, 1:9] 0.377 0.357 0.277 0.436 0.368 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:9] "tTST" "tWAKE" "tMVPA" "tLPA" ...
#> .. ..$ parts : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. ..$ total : num 1
#> .. ..$ sbp : num [1:4, 1:5] 1 1 0 0 1 -1 0 0 -1 0 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : NULL
#> .. .. .. ..$ : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. ..$ psi : num [1:5, 1:4] 0.548 0.548 -0.365 -0.365 -0.365 ...
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : chr [1:5] "TST" "WAKE" "MVPA" "LPA" ...
#> .. .. .. ..$ : NULL
#> $ datain :Classes ‘data.table’ and 'data.frame': 266 obs. of 10 variables:
#> ..$ ID : num [1:266] 185 186 187 188 189 190 191 192 193 194 ...
#> ..$ Time : num [1:266] 1 1 1 1 1 1 1 1 1 1 ...
#> ..$ Stress: num [1:266] 4 3 4 0 0 2 4 4 0 2 ...
#> ..$ TST : num [1:266] 542 514 399 627 530 345 415 471 350 267 ...
#> ..$ WAKE : num [1:266] 99 63 119 53 72 204 37 179 56 50 ...
#> ..$ MVPA : num [1:266] 297 113 33 103 108 244 88 84 25 113 ...
#> ..$ LPA : num [1:266] 460 475 591 353 424 516 781 477 657 699 ...
#> ..$ SB : num [1:266] 41 275 298 303 307 131 119 229 351 311 ...
#> ..$ Age : num [1:266] 30 20 22 27 22 25 21 20 20 32 ...
#> ..$ Female: num [1:266] 0 0 0 0 0 0 0 0 0 0 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> $ dataout :Classes ‘data.table’ and 'data.frame': 266 obs. of 19 variables:
#> ..$ ID : num [1:266] 185 186 187 188 189 190 191 192 193 194 ...
#> ..$ Time : num [1:266] 1 1 1 1 1 1 1 1 1 1 ...
#> ..$ Stress: num [1:266] 4 3 4 0 0 2 4 4 0 2 ...
#> ..$ TST : num [1:266] 542 514 399 627 530 345 415 471 350 267 ...
#> ..$ WAKE : num [1:266] 99 63 119 53 72 204 37 179 56 50 ...
#> ..$ MVPA : num [1:266] 297 113 33 103 108 244 88 84 25 113 ...
#> ..$ LPA : num [1:266] 460 475 591 353 424 516 781 477 657 699 ...
#> ..$ SB : num [1:266] 41 275 298 303 307 131 119 229 351 311 ...
#> ..$ Age : num [1:266] 30 20 22 27 22 25 21 20 20 32 ...
#> ..$ Female: num [1:266] 0 0 0 0 0 0 0 0 0 0 ...
#> ..$ tTST : num [1:266] 0.377 0.357 0.277 0.436 0.368 ...
#> ..$ tWAKE : num [1:266] 0.0688 0.0437 0.0826 0.0368 0.05 ...
#> ..$ tMVPA : num [1:266] 0.2064 0.0785 0.0229 0.0716 0.0749 ...
#> ..$ tLPA : num [1:266] 0.32 0.33 0.41 0.245 0.294 ...
#> ..$ tSB : num [1:266] 0.0285 0.191 0.2069 0.2106 0.213 ...
#> ..$ z1_1 : num [1:266] 0.291 -0.339 0.211 -0.218 -0.232 ...
#> ..$ z2_1 : num [1:266] 1.202 1.484 0.855 1.747 1.412 ...
#> ..$ z3_1 : num [1:266] 0.63 -0.949 -2.076 -0.943 -0.985 ...
#> ..$ z4_1 : num [1:266] 1.71 0.386 0.484 0.108 0.228 ...
#> ..- attr(*, ".internal.selfref")=<externalptr>
#> $ transform: chr "ilr"
#> $ idvar : NULL
#> - attr(*, "class")= chr "complr"