This function reorders the latent class membership for specified latent class variables.
Usage
# S3 method for class 'slca'
reorder(x, ...)
Examples
library(magrittr)
nlsy_jlcpa %>% param
#> PI :
#> (prof)
#> class
#> 1 2 3 4
#> 0.2729 0.1762 0.3187 0.2322
#>
#> TAU :
#> (A)
#> parent
#> child 1 2 3 4
#> 1 0.2753 0.0000 0.0000 0.0770
#> 2 0.0000 0.0264 0.1894 0.0000
#> 3 0.0591 0.4030 0.1762 0.0602
#> 4 0.3077 0.3655 0.4496 0.1440
#> 5 0.3579 0.2050 0.1848 0.7188
#>
#> parent prof
#> child use98
#> (B)
#> parent
#> child 1 2 3 4
#> 1 0.9875 0.0000 0.0000 0.1110
#> 2 0.0013 0.0000 0.8876 0.0000
#> 3 0.0000 0.9749 0.0000 0.0069
#> 4 0.0112 0.0251 0.0312 0.0000
#> 5 0.0000 0.0000 0.0812 0.8821
#>
#> parent prof
#> child use03
#> (C)
#> parent
#> child 1 2 3 4
#> 1 0.9414 0.0361 0.0167 0.2579
#> 2 0.0109 0.1570 0.8165 0.0343
#> 3 0.0002 0.7507 0.0000 0.0000
#> 4 0.0107 0.0060 0.0057 0.0000
#> 5 0.0368 0.0502 0.1611 0.7077
#>
#> parent prof
#> child use08
#> (D)
#> parent
#> child 1 2 3 4 5
#> 1 0.0000 0.7675 0.6486 0.1701 0.0101
#> 2 0.7970 0.0137 0.0782 0.1233 0.9407
#> 3 0.2030 0.2188 0.2732 0.7066 0.0491
#>
#> parent use98 use03 use08
#> child smk98 smk03 smk08
#> (E)
#> parent
#> child 1 2 3 4 5
#> 1 0.2658 0.2176 0.1174 0.5843 0.2308
#> 2 0.0000 0.1910 0.0205 0.0820 0.7341
#> 3 0.7342 0.5913 0.8622 0.3337 0.0351
#>
#> parent use98 use03 use08
#> child drk98 drk03 drk08
#> (F)
#> parent
#> child 1 2 3 4 5
#> 1 0.0928 0.0520 0.7870 0.0013 0.0109
#> 2 0.1898 0.1097 0.1930 0.5129 0.0000
#> 3 0.7174 0.8383 0.0200 0.4858 0.9891
#>
#> parent use98 use03 use08
#> child mrj98 mrj03 mrj08
#>
#> RHO :
#> (a)
#> class
#> response 1 2 3
#> 1(V1) 1.0000 0.0152 1.0000
#> 2 0.0000 0.9848 0.0000
#> 1(V2) 1.0000 0.0000 0.6728
#> 2 0.0000 1.0000 0.3272
#> 1(V3) 0.8836 0.0000 0.0000
#> 2 0.1164 1.0000 1.0000
#> 1(V4) 0.6463 0.0000 0.0000
#> 2 0.3537 1.0000 1.0000
#>
#> V1 V2 V3 V4
#> smk98 ESMK_98 FSMK_98 DSMK_98 HSMK_98
#> smk03 ESMK_03 FSMK_03 DSMK_03 HSMK_03
#> smk08 ESMK_08 FSMK_08 DSMK_08 HSMK_08
#> (b)
#> class
#> response 1 2 3
#> 1(V1) 1.0000 0.0990 1.0000
#> 2 0.0000 0.9010 0.0000
#> 1(V2) 0.5928 0.0000 1.0000
#> 2 0.4072 1.0000 0.0000
#> 1(V3) 0.0000 0.0000 0.6957
#> 2 1.0000 1.0000 0.3043
#> 1(V4) 0.0000 0.0000 0.8088
#> 2 1.0000 1.0000 0.1912
#>
#> V1 V2 V3 V4
#> drk98 EDRK_98 CDRK_98 WDRK_98 BDRK_98
#> drk03 EDRK_03 CDRK_03 WDRK_03 BDRK_03
#> drk08 EDRK_08 CDRK_08 WDRK_08 BDRK_08
#> (c)
#> class
#> response 1 2 3
#> 1(V1) 1.0000 1.0000 0.0157
#> 2 0.0000 0.0000 0.9843
#> 1(V2) 1.0000 0.5016 0.0000
#> 2 0.0000 0.4984 1.0000
#> 1(V3) 0.7903 0.0000 0.0000
#> 2 0.2097 1.0000 1.0000
#> 1(V4) 0.5591 0.0000 0.0000
#> 2 0.4409 1.0000 1.0000
#>
#> V1 V2 V3 V4
#> mrj98 EMRJ_98 CMRJ_98 OMRJ_98 SMRJ_98
#> mrj03 EMRJ_03 CMRJ_03 OMRJ_03 SMRJ_03
#> mrj08 EMRJ_08 CMRJ_08 OMRJ_08 SMRJ_08
# Reorder the RHO parameters as ascending order
reordered1 <- nlsy_jlcpa %>%
reorder(smk98 = c(2, 3, 1),
drk98 = c(2, 1, 3),
mrj98 = c(3, 2, 1))
reordered1 %>% param
#> PI :
#> (prof)
#> class
#> 1 2 3 4
#> 0.2729 0.1762 0.3187 0.2322
#>
#> TAU :
#> (A)
#> parent
#> child 1 2 3 4
#> 1 0.2753 0.0000 0.0000 0.0770
#> 2 0.0000 0.0264 0.1894 0.0000
#> 3 0.0591 0.4030 0.1762 0.0602
#> 4 0.3077 0.3655 0.4496 0.1440
#> 5 0.3579 0.2050 0.1848 0.7188
#>
#> parent prof
#> child use98
#> (B)
#> parent
#> child 1 2 3 4
#> 1 0.9875 0.0000 0.0000 0.1110
#> 2 0.0013 0.0000 0.8876 0.0000
#> 3 0.0000 0.9749 0.0000 0.0069
#> 4 0.0112 0.0251 0.0312 0.0000
#> 5 0.0000 0.0000 0.0812 0.8821
#>
#> parent prof
#> child use03
#> (C)
#> parent
#> child 1 2 3 4
#> 1 0.9414 0.0361 0.0167 0.2579
#> 2 0.0109 0.1570 0.8165 0.0343
#> 3 0.0002 0.7507 0.0000 0.0000
#> 4 0.0107 0.0060 0.0057 0.0000
#> 5 0.0368 0.0502 0.1611 0.7077
#>
#> parent prof
#> child use08
#> (D)
#> parent
#> child 1 2 3 4 5
#> 1 0.7970 0.0137 0.0782 0.1233 0.9407
#> 2 0.2030 0.2188 0.2732 0.7066 0.0491
#> 3 0.0000 0.7675 0.6486 0.1701 0.0101
#>
#> parent use98 use03 use08
#> child smk98 smk03 smk08
#> (E)
#> parent
#> child 1 2 3 4 5
#> 1 0.0000 0.1910 0.0205 0.0820 0.7341
#> 2 0.2658 0.2176 0.1174 0.5843 0.2308
#> 3 0.7342 0.5913 0.8622 0.3337 0.0351
#>
#> parent use98 use03 use08
#> child drk98 drk03 drk08
#> (F)
#> parent
#> child 1 2 3 4 5
#> 1 0.7174 0.8383 0.0200 0.4858 0.9891
#> 2 0.1898 0.1097 0.1930 0.5129 0.0000
#> 3 0.0928 0.0520 0.7870 0.0013 0.0109
#>
#> parent use98 use03 use08
#> child mrj98 mrj03 mrj08
#>
#> RHO :
#> (a)
#> class
#> response 1 2 3
#> 1(V1) 0.0152 1.0000 1.0000
#> 2 0.9848 0.0000 0.0000
#> 1(V2) 0.0000 0.6728 1.0000
#> 2 1.0000 0.3272 0.0000
#> 1(V3) 0.0000 0.0000 0.8836
#> 2 1.0000 1.0000 0.1164
#> 1(V4) 0.0000 0.0000 0.6463
#> 2 1.0000 1.0000 0.3537
#>
#> V1 V2 V3 V4
#> smk98 ESMK_98 FSMK_98 DSMK_98 HSMK_98
#> smk03 ESMK_03 FSMK_03 DSMK_03 HSMK_03
#> smk08 ESMK_08 FSMK_08 DSMK_08 HSMK_08
#> (b)
#> class
#> response 1 2 3
#> 1(V1) 0.0990 1.0000 1.0000
#> 2 0.9010 0.0000 0.0000
#> 1(V2) 0.0000 0.5928 1.0000
#> 2 1.0000 0.4072 0.0000
#> 1(V3) 0.0000 0.0000 0.6957
#> 2 1.0000 1.0000 0.3043
#> 1(V4) 0.0000 0.0000 0.8088
#> 2 1.0000 1.0000 0.1912
#>
#> V1 V2 V3 V4
#> drk98 EDRK_98 CDRK_98 WDRK_98 BDRK_98
#> drk03 EDRK_03 CDRK_03 WDRK_03 BDRK_03
#> drk08 EDRK_08 CDRK_08 WDRK_08 BDRK_08
#> (c)
#> class
#> response 1 2 3
#> 1(V1) 0.0157 1.0000 1.0000
#> 2 0.9843 0.0000 0.0000
#> 1(V2) 0.0000 0.5016 1.0000
#> 2 1.0000 0.4984 0.0000
#> 1(V3) 0.0000 0.0000 0.7903
#> 2 1.0000 1.0000 0.2097
#> 1(V4) 0.0000 0.0000 0.5591
#> 2 1.0000 1.0000 0.4409
#>
#> V1 V2 V3 V4
#> mrj98 EMRJ_98 CMRJ_98 OMRJ_98 SMRJ_98
#> mrj03 EMRJ_03 CMRJ_03 OMRJ_03 SMRJ_03
#> mrj08 EMRJ_08 CMRJ_08 OMRJ_08 SMRJ_08
# Label class1: nonuse
# class2: lifetime use
# class3: current use
# Reorder the TAU parameters for joint classes as ascending order
reordered2 <- reordered1 %>%
reorder(use98 = c(5, 1, 4, 2, 3))
reordered2 %>% param
#> PI :
#> (prof)
#> class
#> 1 2 3 4
#> 0.2729 0.1762 0.3187 0.2322
#>
#> TAU :
#> (A)
#> parent
#> child 1 2 3 4
#> 1 0.3579 0.2050 0.1848 0.7188
#> 2 0.2753 0.0000 0.0000 0.0770
#> 3 0.3077 0.3655 0.4496 0.1440
#> 4 0.0000 0.0264 0.1894 0.0000
#> 5 0.0591 0.4030 0.1762 0.0602
#>
#> parent prof
#> child use98
#> (B)
#> parent
#> child 1 2 3 4
#> 1 0.0000 0.0000 0.0812 0.8821
#> 2 0.9875 0.0000 0.0000 0.1110
#> 3 0.0112 0.0251 0.0312 0.0000
#> 4 0.0013 0.0000 0.8876 0.0000
#> 5 0.0000 0.9749 0.0000 0.0069
#>
#> parent prof
#> child use03
#> (C)
#> parent
#> child 1 2 3 4
#> 1 0.0368 0.0502 0.1611 0.7077
#> 2 0.9414 0.0361 0.0167 0.2579
#> 3 0.0107 0.0060 0.0057 0.0000
#> 4 0.0109 0.1570 0.8165 0.0343
#> 5 0.0002 0.7507 0.0000 0.0000
#>
#> parent prof
#> child use08
#> (D)
#> parent
#> child 1 2 3 4 5
#> 1 0.9407 0.7970 0.1233 0.0137 0.0782
#> 2 0.0491 0.2030 0.7066 0.2188 0.2732
#> 3 0.0101 0.0000 0.1701 0.7675 0.6486
#>
#> parent use98 use03 use08
#> child smk98 smk03 smk08
#> (E)
#> parent
#> child 1 2 3 4 5
#> 1 0.7341 0.0000 0.0820 0.1910 0.0205
#> 2 0.2308 0.2658 0.5843 0.2176 0.1174
#> 3 0.0351 0.7342 0.3337 0.5913 0.8622
#>
#> parent use98 use03 use08
#> child drk98 drk03 drk08
#> (F)
#> parent
#> child 1 2 3 4 5
#> 1 0.9891 0.7174 0.4858 0.8383 0.0200
#> 2 0.0000 0.1898 0.5129 0.1097 0.1930
#> 3 0.0109 0.0928 0.0013 0.0520 0.7870
#>
#> parent use98 use03 use08
#> child mrj98 mrj03 mrj08
#>
#> RHO :
#> (a)
#> class
#> response 1 2 3
#> 1(V1) 0.0152 1.0000 1.0000
#> 2 0.9848 0.0000 0.0000
#> 1(V2) 0.0000 0.6728 1.0000
#> 2 1.0000 0.3272 0.0000
#> 1(V3) 0.0000 0.0000 0.8836
#> 2 1.0000 1.0000 0.1164
#> 1(V4) 0.0000 0.0000 0.6463
#> 2 1.0000 1.0000 0.3537
#>
#> V1 V2 V3 V4
#> smk98 ESMK_98 FSMK_98 DSMK_98 HSMK_98
#> smk03 ESMK_03 FSMK_03 DSMK_03 HSMK_03
#> smk08 ESMK_08 FSMK_08 DSMK_08 HSMK_08
#> (b)
#> class
#> response 1 2 3
#> 1(V1) 0.0990 1.0000 1.0000
#> 2 0.9010 0.0000 0.0000
#> 1(V2) 0.0000 0.5928 1.0000
#> 2 1.0000 0.4072 0.0000
#> 1(V3) 0.0000 0.0000 0.6957
#> 2 1.0000 1.0000 0.3043
#> 1(V4) 0.0000 0.0000 0.8088
#> 2 1.0000 1.0000 0.1912
#>
#> V1 V2 V3 V4
#> drk98 EDRK_98 CDRK_98 WDRK_98 BDRK_98
#> drk03 EDRK_03 CDRK_03 WDRK_03 BDRK_03
#> drk08 EDRK_08 CDRK_08 WDRK_08 BDRK_08
#> (c)
#> class
#> response 1 2 3
#> 1(V1) 0.0157 1.0000 1.0000
#> 2 0.9843 0.0000 0.0000
#> 1(V2) 0.0000 0.5016 1.0000
#> 2 1.0000 0.4984 0.0000
#> 1(V3) 0.0000 0.0000 0.7903
#> 2 1.0000 1.0000 0.2097
#> 1(V4) 0.0000 0.0000 0.5591
#> 2 1.0000 1.0000 0.4409
#>
#> V1 V2 V3 V4
#> mrj98 EMRJ_98 CMRJ_98 OMRJ_98 SMRJ_98
#> mrj03 EMRJ_03 CMRJ_03 OMRJ_03 SMRJ_03
#> mrj08 EMRJ_08 CMRJ_08 OMRJ_08 SMRJ_08
# Label class1: nonuse
# class2: heavy drinking only
# class3: not heavy use
# class4: heavy drinking & smoking
# class5: heavy use
# Reorder the TAU paramters for profiles as ascending order
reordered3 <- reordered2 %>%
reorder(prof = c(4, 1, 3, 2))
reordered3 %>% param
#> PI :
#> (prof)
#> class
#> 1 2 3 4
#> 0.2322 0.2729 0.3187 0.1762
#>
#> TAU :
#> (A)
#> parent
#> child 1 2 3 4
#> 1 0.7188 0.3579 0.1848 0.2050
#> 2 0.0770 0.2753 0.0000 0.0000
#> 3 0.1440 0.3077 0.4496 0.3655
#> 4 0.0000 0.0000 0.1894 0.0264
#> 5 0.0602 0.0591 0.1762 0.4030
#>
#> parent prof
#> child use98
#> (B)
#> parent
#> child 1 2 3 4
#> 1 0.8821 0.0000 0.0812 0.0000
#> 2 0.1110 0.9875 0.0000 0.0000
#> 3 0.0000 0.0112 0.0312 0.0251
#> 4 0.0000 0.0013 0.8876 0.0000
#> 5 0.0069 0.0000 0.0000 0.9749
#>
#> parent prof
#> child use03
#> (C)
#> parent
#> child 1 2 3 4
#> 1 0.7077 0.0368 0.1611 0.0502
#> 2 0.2579 0.9414 0.0167 0.0361
#> 3 0.0000 0.0107 0.0057 0.0060
#> 4 0.0343 0.0109 0.8165 0.1570
#> 5 0.0000 0.0002 0.0000 0.7507
#>
#> parent prof
#> child use08
#> (D)
#> parent
#> child 1 2 3 4 5
#> 1 0.9407 0.7970 0.1233 0.0137 0.0782
#> 2 0.0491 0.2030 0.7066 0.2188 0.2732
#> 3 0.0101 0.0000 0.1701 0.7675 0.6486
#>
#> parent use98 use03 use08
#> child smk98 smk03 smk08
#> (E)
#> parent
#> child 1 2 3 4 5
#> 1 0.7341 0.0000 0.0820 0.1910 0.0205
#> 2 0.2308 0.2658 0.5843 0.2176 0.1174
#> 3 0.0351 0.7342 0.3337 0.5913 0.8622
#>
#> parent use98 use03 use08
#> child drk98 drk03 drk08
#> (F)
#> parent
#> child 1 2 3 4 5
#> 1 0.9891 0.7174 0.4858 0.8383 0.0200
#> 2 0.0000 0.1898 0.5129 0.1097 0.1930
#> 3 0.0109 0.0928 0.0013 0.0520 0.7870
#>
#> parent use98 use03 use08
#> child mrj98 mrj03 mrj08
#>
#> RHO :
#> (a)
#> class
#> response 1 2 3
#> 1(V1) 0.0152 1.0000 1.0000
#> 2 0.9848 0.0000 0.0000
#> 1(V2) 0.0000 0.6728 1.0000
#> 2 1.0000 0.3272 0.0000
#> 1(V3) 0.0000 0.0000 0.8836
#> 2 1.0000 1.0000 0.1164
#> 1(V4) 0.0000 0.0000 0.6463
#> 2 1.0000 1.0000 0.3537
#>
#> V1 V2 V3 V4
#> smk98 ESMK_98 FSMK_98 DSMK_98 HSMK_98
#> smk03 ESMK_03 FSMK_03 DSMK_03 HSMK_03
#> smk08 ESMK_08 FSMK_08 DSMK_08 HSMK_08
#> (b)
#> class
#> response 1 2 3
#> 1(V1) 0.0990 1.0000 1.0000
#> 2 0.9010 0.0000 0.0000
#> 1(V2) 0.0000 0.5928 1.0000
#> 2 1.0000 0.4072 0.0000
#> 1(V3) 0.0000 0.0000 0.6957
#> 2 1.0000 1.0000 0.3043
#> 1(V4) 0.0000 0.0000 0.8088
#> 2 1.0000 1.0000 0.1912
#>
#> V1 V2 V3 V4
#> drk98 EDRK_98 CDRK_98 WDRK_98 BDRK_98
#> drk03 EDRK_03 CDRK_03 WDRK_03 BDRK_03
#> drk08 EDRK_08 CDRK_08 WDRK_08 BDRK_08
#> (c)
#> class
#> response 1 2 3
#> 1(V1) 0.0157 1.0000 1.0000
#> 2 0.9843 0.0000 0.0000
#> 1(V2) 0.0000 0.5016 1.0000
#> 2 1.0000 0.4984 0.0000
#> 1(V3) 0.0000 0.0000 0.7903
#> 2 1.0000 1.0000 0.2097
#> 1(V4) 0.0000 0.0000 0.5591
#> 2 1.0000 1.0000 0.4409
#>
#> V1 V2 V3 V4
#> mrj98 EMRJ_98 CMRJ_98 OMRJ_98 SMRJ_98
#> mrj03 EMRJ_03 CMRJ_03 OMRJ_03 SMRJ_03
#> mrj08 EMRJ_08 CMRJ_08 OMRJ_08 SMRJ_08
# Label class1: nonuse stayer
# class2: heavy drinking advancer
# class3: heavy drk & smk advancer
# class4: heavy use advancer