assoc.domains.RdComputes various measures of association between dimensions of multidimensional sequence data.
assoc.domains(dlist, names, djsa)A list of dissimilarity matrices or dist objects (see dist), with one element per dimension of the multidimensional sequence data
A character vector of the names of the dimensions of the multidimensional sequence data
A dissimilarity matrix or a dist object (see dist), corresponding to the distances between the multimdimensional sequences
Piccarreta R. (2017). Joint Sequence Analysis: Association and Clustering, Sociological Methods and Research, Vol. 46(2), 252-287.
# \donttest{
library(TraMineR)
data(biofam)
## Building one channel per type of event (left, children or married)
bf <- as.matrix(biofam[, 10:25])
children <- bf==4 | bf==5 | bf==6
married <- bf == 2 | bf== 3 | bf==6
left <- bf==1 | bf==3 | bf==5 | bf==6
## Building sequence objects
child.seq <- seqdef(children)
#> [>] 2 distinct states appear in the data:
#> 1 = FALSE
#> 2 = TRUE
#> [>] state coding:
#> [alphabet] [label] [long label]
#> 1 FALSE FALSE FALSE
#> 2 TRUE TRUE TRUE
#> [>] 2000 sequences in the data set
#> [>] min/max sequence length: 16/16
marr.seq <- seqdef(married)
#> [>] 2 distinct states appear in the data:
#> 1 = FALSE
#> 2 = TRUE
#> [>] state coding:
#> [alphabet] [label] [long label]
#> 1 FALSE FALSE FALSE
#> 2 TRUE TRUE TRUE
#> [>] 2000 sequences in the data set
#> [>] min/max sequence length: 16/16
left.seq <- seqdef(left)
#> [>] 2 distinct states appear in the data:
#> 1 = FALSE
#> 2 = TRUE
#> [>] state coding:
#> [alphabet] [label] [long label]
#> 1 FALSE FALSE FALSE
#> 2 TRUE TRUE TRUE
#> [>] 2000 sequences in the data set
#> [>] min/max sequence length: 16/16
## Using Hamming distance
mcdist <- seqdistmc(channels=list(child.seq, marr.seq, left.seq),
method="HAM")
#> [!!] 3 domains with 2000 sequences
#> [>] building MD sequences of combined states...
#> OK
#> [>] computing substitution cost matrix for domain 1
#> [>] computing substitution cost matrix for domain 2
#> [>] computing substitution cost matrix for domain 3
#> [>] computing MD substitution and indel costs with additive trick...
#> OK
#> [>] computing distances using additive trick ...
#> [>] 2000 sequences with 7 distinct states
#> [>] checking 'sm' (size and triangle inequality)
#> [>] 537 distinct sequences
#> [>] min/max sequence lengths: 16/16
#> [>] computing distances using the HAM metric
#> [>] elapsed time: 0.499 secs
child.dist <- seqdist(child.seq, method="HAM")
#> [>] 2000 sequences with 2 distinct states
#> [>] creating a 'sm' with a single substitution cost of 1
#> [>] creating 2x2 substitution-cost matrix using 1 as constant value
#> [>] 38 distinct sequences
#> [>] min/max sequence lengths: 16/16
#> [>] computing distances using the HAM metric
#> [>] elapsed time: 0.321 secs
marr.dist <- seqdist(marr.seq, method="HAM")
#> [>] 2000 sequences with 2 distinct states
#> [>] creating a 'sm' with a single substitution cost of 1
#> [>] creating 2x2 substitution-cost matrix using 1 as constant value
#> [>] 58 distinct sequences
#> [>] min/max sequence lengths: 16/16
#> [>] computing distances using the HAM metric
#> [>] elapsed time: 0.459 secs
left.dist <- seqdist(left.seq, method="HAM")
#> [>] 2000 sequences with 2 distinct states
#> [>] creating a 'sm' with a single substitution cost of 1
#> [>] creating 2x2 substitution-cost matrix using 1 as constant value
#> [>] 64 distinct sequences
#> [>] min/max sequence lengths: 16/16
#> [>] computing distances using the HAM metric
#> [>] elapsed time: 0.237 secs
## Association between domains
asso <- assoc.domains(list(child.dist,marr.dist,left.dist), c('child','marr','left'), mcdist)
asso
#> $correlations
#> $correlations$pearson
#> child marr left jsa
#> child 1.000 0.339 0.067 0.673
#> marr 0.339 1.000 0.117 0.679
#> left 0.067 0.117 1.000 0.653
#> jsa 0.673 0.679 0.653 1.000
#>
#> $correlations$spearman
#> child marr left jsa
#> child 1.000 0.283 0.052 0.605
#> marr 0.283 1.000 0.119 0.658
#> left 0.052 0.119 1.000 0.653
#> jsa 0.605 0.658 0.653 1.000
#>
#>
#> $`mean squared correlations`
#> $`mean squared correlations`$pearson
#> [1] 0.447
#>
#> $`mean squared correlations`$spearman
#> [1] 0.408
#>
#>
#> $`Cronbach's alpha`
#> $`Cronbach's alpha`$`(child,marr,left)`
#> [1] 0.388
#>
#> $`Cronbach's alpha`$`(child,marr)`
#> [1] 0.506
#>
#> $`Cronbach's alpha`$`(child,left)`
#> [1] 0.126
#>
#> $`Cronbach's alpha`$`(marr,left)`
#> [1] 0.209
#>
#>
# }