Skip to contents

Estimate crosswalk between cognitive measures

Usage

crosswalk(
  cog1,
  cog2,
  data,
  niter = NULL,
  condition_by = NULL,
  condition_loop = FALSE,
  control = NULL
)

est_cw_coef(cog1, cog2, data, method = "lm")

Arguments

cog1

The name of the first cognitive measure column

cog2

The name of the second cognitive measure column

data

A data.table, data.frame, matrix, or list containing the cognitive measure data

niter

Number of iterations to conduct for an unconditional split routine

condition_by

The name of a conditioning variable by which splits will be conducted. If not conducted, the function will use unconditional splits.

condition_loop

Whether to conduct conditional splitting sequentially. Defaults to FALSE to maximize speed. Unused if condition_by is NULL. See documentation for make_conditional_splits() for details.

control

A list of settings passed to bootstrap_crosswalk(). See boot_control() for more information.

method

Either 'lm' (recommended) or 'manual'. The former will fit a linear regression model and return the fit object, while the latter will return a table containing the covariance between the cognitive measures (cov), the variance of the measure input as cog1 (var), and the estimated sloped (coef).

Details

Unlike crosswalk(), which uses splitting to estimate the sample coefficient, est_cw_coef() calculates the coefficient based on summary statistics from the input data: cov(cog1, cog2) / var(cog1).

Examples

# linear model estimate of slope (no splitting)
crosswalk(cog1 = "mmse", cog2 = "moca", data = cogsim) # linear model
#> $cog1
#> [1] "mmse"
#> 
#> $cog2
#> [1] "moca"
#> 
#> $fit
#> 
#> Call:
#> lm(formula = moca ~ mmse)
#> 
#> Coefficients:
#> (Intercept)         mmse  
#>     -11.070        1.247  
#> 
#> 
#> $diffs
#> NULL
#> 
#> $condition_var
#> NULL
#> 
#> attr(,"class")
#> [1] "cogxwalkr" "list"     

# unconditional split method
crosswalk(cog1 = "mmse", cog2 = "moca", data = cogsim, niter = 500)
#> $cog1
#> [1] "mmse"
#> 
#> $cog2
#> [1] "moca"
#> 
#> $fit
#> 
#> Call:
#> lm(formula = moca ~ mmse - 1)
#> 
#> Coefficients:
#>  mmse  
#> 1.154  
#> 
#> 
#> $diffs
#> Key: <iteration>
#>      iteration         mmse        moca
#>          <int>        <num>       <num>
#>   1:         1  0.006113236 -0.10336236
#>   2:         2 -0.068389043  0.08417786
#>   3:         3  0.026665589  0.23575146
#>   4:         4 -0.112062792  0.29997756
#>   5:         5  0.016389412 -0.01087677
#>  ---                                   
#> 496:       496  0.021527500  0.05848742
#> 497:       497 -0.096648528 -0.26521214
#> 498:       498  0.126858308  0.14583491
#> 499:       499 -0.153167498 -0.07253383
#> 500:       500  0.316967571  0.39503219
#> 
#> $condition_var
#> NULL
#> 
#> attr(,"class")
#> [1] "cogxwalkr" "list"     

# conditional split method
crosswalk(cog1 = "mmse", cog2 = "moca", data = cogsim, condition_by = "dementia")
#> $cog1
#> [1] "mmse"
#> 
#> $cog2
#> [1] "moca"
#> 
#> $fit
#> 
#> Call:
#> lm(formula = moca ~ mmse - 1)
#> 
#> Coefficients:
#>  mmse  
#> 1.391  
#> 
#> 
#> $diffs
#> Key: <iteration>
#>      iteration      mmse      moca
#>          <int>     <num>     <num>
#>   1:         1  1.413949  2.095739
#>   2:         2  1.365138  2.131706
#>   3:         3  1.547540  1.933890
#>   4:         4  1.401104  2.010961
#>   5:         5  1.354861  1.743780
#>  ---                              
#> 200:       200 -1.494209 -1.963350
#> 201:       201 -1.322083 -1.732136
#> 202:       202 -1.437690 -2.073819
#> 203:       203 -1.442828 -1.876003
#> 204:       204 -1.532744 -2.202271
#> 
#> $condition_var
#> [1] "dementia"
#> 
#> attr(,"class")
#> [1] "cogxwalkr" "list"     

# regardless of the method, request bootstrap via `control`
crosswalk(cog1 = "mmse", cog2 = "moca", data = cogsim,
          control = list(nboot = 1000, seed = 999, ncores = 4))
#> Running bootstraps over 4 cores ...
#> $cog1
#> [1] "mmse"
#> 
#> $cog2
#> [1] "moca"
#> 
#> $fit
#> 
#> Call:
#> lm(formula = moca ~ mmse)
#> 
#> Coefficients:
#> (Intercept)         mmse  
#>     -11.070        1.247  
#> 
#> 
#> $diffs
#> NULL
#> 
#> $condition_var
#> NULL
#> 
#> $boot
#> $boot$dist
#>    [1] 1.274596 1.221208 1.264444 1.245859 1.180395 1.190440 1.215705 1.232131
#>    [9] 1.234169 1.241227 1.249037 1.320811 1.298295 1.167544 1.260856 1.257423
#>   [17] 1.253188 1.244445 1.312177 1.280707 1.208502 1.247405 1.161740 1.219044
#>   [25] 1.280191 1.254177 1.193916 1.225698 1.267886 1.271820 1.210074 1.258036
#>   [33] 1.275335 1.208713 1.231616 1.219710 1.253975 1.221223 1.217089 1.226039
#>   [41] 1.288247 1.304841 1.271135 1.292803 1.189331 1.181546 1.194043 1.239775
#>   [49] 1.175737 1.278502 1.246735 1.241104 1.172560 1.287866 1.235662 1.263956
#>   [57] 1.278280 1.239022 1.282405 1.281332 1.270828 1.239372 1.298912 1.236554
#>   [65] 1.255027 1.309107 1.322183 1.187105 1.241612 1.285918 1.307393 1.261218
#>   [73] 1.259388 1.239004 1.266679 1.219131 1.200702 1.242076 1.190152 1.228391
#>   [81] 1.181724 1.280380 1.289674 1.282001 1.333064 1.279781 1.201367 1.259975
#>   [89] 1.303235 1.177036 1.242619 1.299629 1.227152 1.208487 1.285746 1.250272
#>   [97] 1.237970 1.230404 1.248566 1.223779 1.304132 1.265994 1.239268 1.251651
#>  [105] 1.255432 1.247587 1.188457 1.217352 1.260511 1.192856 1.278955 1.202642
#>  [113] 1.304210 1.280963 1.247507 1.291098 1.280711 1.261394 1.227956 1.264638
#>  [121] 1.219283 1.211812 1.281027 1.214233 1.233483 1.269039 1.201769 1.265329
#>  [129] 1.178396 1.192874 1.234480 1.219597 1.214962 1.251873 1.217415 1.143466
#>  [137] 1.250688 1.315937 1.284652 1.176314 1.221997 1.233034 1.229308 1.192408
#>  [145] 1.200482 1.190200 1.232120 1.231574 1.195226 1.278550 1.268043 1.238569
#>  [153] 1.211288 1.270294 1.170375 1.255144 1.257842 1.236024 1.265442 1.241731
#>  [161] 1.275988 1.205412 1.292042 1.177728 1.197894 1.279427 1.241724 1.267943
#>  [169] 1.232379 1.266117 1.237867 1.259539 1.208754 1.231989 1.299182 1.245394
#>  [177] 1.226480 1.272591 1.212434 1.233650 1.293750 1.232095 1.226421 1.240184
#>  [185] 1.248459 1.231287 1.292210 1.271151 1.249428 1.225004 1.181242 1.236167
#>  [193] 1.299299 1.268002 1.287079 1.221381 1.255498 1.268002 1.189178 1.229027
#>  [201] 1.262700 1.283952 1.194663 1.193272 1.255389 1.188322 1.247203 1.240663
#>  [209] 1.256527 1.289594 1.267170 1.241816 1.232800 1.258068 1.245468 1.245134
#>  [217] 1.244342 1.272440 1.236955 1.279088 1.217975 1.285589 1.226803 1.213793
#>  [225] 1.144694 1.231896 1.246768 1.288800 1.299916 1.227153 1.270757 1.233335
#>  [233] 1.241779 1.265645 1.228998 1.318920 1.199850 1.241856 1.283544 1.255696
#>  [241] 1.239879 1.265980 1.212010 1.311619 1.242234 1.279702 1.233622 1.316913
#>  [249] 1.230757 1.204561 1.210166 1.206142 1.243695 1.254966 1.215963 1.216444
#>  [257] 1.252611 1.225399 1.242516 1.286689 1.235912 1.234006 1.192926 1.214778
#>  [265] 1.206994 1.250026 1.235012 1.246841 1.261648 1.209852 1.241408 1.259078
#>  [273] 1.290130 1.274229 1.223499 1.250500 1.255657 1.183735 1.211867 1.286013
#>  [281] 1.182313 1.215466 1.196930 1.198744 1.245337 1.195750 1.260821 1.304825
#>  [289] 1.209727 1.246712 1.261280 1.226564 1.238671 1.259143 1.264251 1.295984
#>  [297] 1.264779 1.243914 1.261951 1.258404 1.233801 1.243167 1.288866 1.217997
#>  [305] 1.269397 1.268674 1.251033 1.235547 1.202926 1.271941 1.213950 1.243080
#>  [313] 1.216089 1.208329 1.224127 1.298320 1.272521 1.252306 1.262030 1.310934
#>  [321] 1.231898 1.203642 1.239215 1.252252 1.233146 1.161089 1.239469 1.219930
#>  [329] 1.156362 1.311342 1.238372 1.219447 1.211123 1.282591 1.207641 1.253076
#>  [337] 1.362464 1.210510 1.219459 1.262245 1.263135 1.250633 1.221064 1.234950
#>  [345] 1.259507 1.258352 1.268740 1.241981 1.246890 1.331443 1.232709 1.248417
#>  [353] 1.250070 1.201798 1.234855 1.285382 1.277998 1.251479 1.226967 1.259958
#>  [361] 1.269810 1.242627 1.189820 1.250327 1.218764 1.257074 1.255982 1.171719
#>  [369] 1.299892 1.229929 1.257017 1.182153 1.284651 1.266629 1.235882 1.205512
#>  [377] 1.210366 1.247493 1.197540 1.221919 1.187035 1.318176 1.255846 1.260150
#>  [385] 1.228517 1.269967 1.303741 1.241027 1.206452 1.265104 1.263017 1.252010
#>  [393] 1.271454 1.258537 1.277884 1.220849 1.203265 1.233557 1.239546 1.262477
#>  [401] 1.222780 1.288306 1.282150 1.203410 1.264697 1.267740 1.247644 1.251547
#>  [409] 1.268866 1.298260 1.242979 1.309857 1.228181 1.363755 1.244732 1.207169
#>  [417] 1.293631 1.243792 1.225039 1.201803 1.233154 1.217391 1.323769 1.260173
#>  [425] 1.241498 1.193782 1.243495 1.254227 1.214588 1.174696 1.190989 1.209200
#>  [433] 1.257855 1.256555 1.230672 1.215460 1.245353 1.225159 1.203792 1.269385
#>  [441] 1.295232 1.283026 1.265252 1.241295 1.221425 1.248946 1.291653 1.293147
#>  [449] 1.226511 1.229579 1.249316 1.312001 1.221061 1.228345 1.263175 1.217301
#>  [457] 1.195103 1.280082 1.250678 1.260830 1.156355 1.248977 1.268785 1.237767
#>  [465] 1.257374 1.238753 1.221668 1.208967 1.183161 1.211201 1.223256 1.322702
#>  [473] 1.238788 1.265141 1.234353 1.241151 1.201498 1.254436 1.231309 1.227766
#>  [481] 1.300803 1.209924 1.286740 1.218073 1.222739 1.218927 1.239384 1.226833
#>  [489] 1.301310 1.178972 1.255159 1.235621 1.320903 1.254979 1.267707 1.201685
#>  [497] 1.257792 1.201786 1.237752 1.244138 1.252237 1.251006 1.271490 1.235624
#>  [505] 1.205925 1.185394 1.245847 1.225617 1.287032 1.246468 1.264962 1.251186
#>  [513] 1.317972 1.262458 1.212683 1.278743 1.226663 1.254832 1.227140 1.215002
#>  [521] 1.316874 1.273206 1.259260 1.229622 1.282708 1.216401 1.264431 1.289008
#>  [529] 1.230914 1.240666 1.186763 1.285260 1.250040 1.250542 1.215819 1.240163
#>  [537] 1.247345 1.264415 1.249590 1.186216 1.253117 1.268090 1.271882 1.239552
#>  [545] 1.320945 1.222936 1.221014 1.191449 1.204341 1.252500 1.263631 1.233672
#>  [553] 1.204560 1.280748 1.239224 1.263918 1.249107 1.274722 1.269231 1.220509
#>  [561] 1.252781 1.294338 1.238728 1.222418 1.225264 1.199420 1.280851 1.210418
#>  [569] 1.257673 1.175920 1.210494 1.218332 1.263801 1.257171 1.232490 1.291196
#>  [577] 1.258885 1.263697 1.216502 1.228347 1.270656 1.274686 1.244263 1.253024
#>  [585] 1.238986 1.247004 1.261779 1.168214 1.271599 1.205493 1.270105 1.217943
#>  [593] 1.208215 1.259520 1.239500 1.287854 1.287261 1.240207 1.246957 1.281775
#>  [601] 1.290724 1.299552 1.220926 1.257597 1.314764 1.214511 1.258288 1.257949
#>  [609] 1.245335 1.222206 1.262766 1.263947 1.217225 1.280631 1.239364 1.213604
#>  [617] 1.308563 1.279451 1.249608 1.222276 1.244684 1.253285 1.243972 1.236974
#>  [625] 1.276509 1.258001 1.209129 1.228395 1.272710 1.262572 1.262437 1.219342
#>  [633] 1.249795 1.236677 1.227620 1.282915 1.247135 1.242227 1.218776 1.221471
#>  [641] 1.313544 1.280433 1.231491 1.191716 1.235071 1.281538 1.301906 1.266510
#>  [649] 1.227619 1.232029 1.238632 1.207711 1.339490 1.281932 1.227339 1.239257
#>  [657] 1.220275 1.219547 1.265884 1.254320 1.253298 1.258763 1.269385 1.297690
#>  [665] 1.203908 1.211166 1.268436 1.181921 1.249066 1.261866 1.250701 1.285410
#>  [673] 1.201406 1.220100 1.262617 1.289723 1.223464 1.274698 1.221670 1.280084
#>  [681] 1.233760 1.228923 1.260727 1.262743 1.226423 1.219082 1.271763 1.268282
#>  [689] 1.237770 1.240299 1.232185 1.257823 1.222281 1.223527 1.253385 1.256216
#>  [697] 1.236543 1.204826 1.254672 1.191135 1.211901 1.249701 1.289589 1.255077
#>  [705] 1.243034 1.244403 1.174905 1.247132 1.180587 1.244566 1.244748 1.233480
#>  [713] 1.333537 1.296036 1.264200 1.242617 1.200213 1.298223 1.244460 1.173555
#>  [721] 1.253842 1.214076 1.199526 1.244108 1.193035 1.258349 1.220271 1.228449
#>  [729] 1.305692 1.189133 1.268411 1.179981 1.225565 1.224030 1.278415 1.236635
#>  [737] 1.280044 1.214668 1.241991 1.249968 1.238408 1.292161 1.231794 1.216158
#>  [745] 1.263998 1.274351 1.236440 1.222036 1.284773 1.334296 1.230915 1.227357
#>  [753] 1.256894 1.240276 1.307467 1.297989 1.162010 1.224568 1.240542 1.303653
#>  [761] 1.284268 1.210363 1.229386 1.290378 1.269092 1.216465 1.242451 1.267445
#>  [769] 1.285729 1.264518 1.159192 1.197642 1.231788 1.313301 1.278089 1.246516
#>  [777] 1.218938 1.245409 1.199144 1.175423 1.253931 1.306511 1.204977 1.255896
#>  [785] 1.209319 1.242299 1.248683 1.237087 1.235113 1.238732 1.254237 1.200974
#>  [793] 1.205420 1.234557 1.238867 1.225397 1.166015 1.213065 1.223801 1.246712
#>  [801] 1.269290 1.252318 1.322783 1.207832 1.276057 1.218278 1.260140 1.207129
#>  [809] 1.172191 1.251105 1.320561 1.201245 1.247607 1.253172 1.220736 1.246252
#>  [817] 1.249793 1.187866 1.322097 1.214089 1.189037 1.229918 1.206961 1.243869
#>  [825] 1.219361 1.246971 1.280044 1.238349 1.258731 1.261874 1.270642 1.255853
#>  [833] 1.260797 1.194658 1.282959 1.260625 1.266402 1.246058 1.286217 1.260794
#>  [841] 1.217443 1.317192 1.245460 1.258224 1.209686 1.240157 1.229541 1.175757
#>  [849] 1.253197 1.282599 1.204414 1.290809 1.297073 1.211563 1.278669 1.297340
#>  [857] 1.269769 1.300097 1.249675 1.307957 1.265666 1.271515 1.220151 1.242657
#>  [865] 1.224378 1.324918 1.245585 1.170966 1.234814 1.238239 1.272434 1.301724
#>  [873] 1.255827 1.264471 1.189123 1.257762 1.263004 1.241666 1.241584 1.250800
#>  [881] 1.258334 1.222356 1.206390 1.230696 1.190102 1.286941 1.254703 1.295861
#>  [889] 1.253688 1.264698 1.263127 1.274070 1.249281 1.231606 1.230263 1.228047
#>  [897] 1.303656 1.253797 1.268946 1.277759 1.236504 1.179328 1.223373 1.255858
#>  [905] 1.211423 1.225271 1.207950 1.274936 1.265144 1.292822 1.230900 1.266533
#>  [913] 1.225806 1.199318 1.311209 1.215372 1.242082 1.245048 1.213891 1.216487
#>  [921] 1.269044 1.254154 1.265546 1.250473 1.205785 1.203049 1.287051 1.244598
#>  [929] 1.254080 1.304040 1.249286 1.221959 1.240525 1.235157 1.196490 1.271973
#>  [937] 1.202462 1.267877 1.208265 1.292415 1.190979 1.304544 1.264109 1.227190
#>  [945] 1.264533 1.269351 1.254503 1.227728 1.262899 1.207285 1.186783 1.173650
#>  [953] 1.277557 1.196527 1.206108 1.263991 1.181874 1.241089 1.197465 1.235719
#>  [961] 1.332586 1.245408 1.215787 1.240714 1.301041 1.249250 1.273115 1.267648
#>  [969] 1.280488 1.226847 1.222783 1.204186 1.207251 1.303066 1.227368 1.200214
#>  [977] 1.288265 1.294696 1.249085 1.238368 1.275665 1.240872 1.209757 1.266749
#>  [985] 1.231384 1.219225 1.240950 1.288110 1.236763 1.285549 1.225258 1.193140
#>  [993] 1.219718 1.183379 1.225612 1.227567 1.320451 1.255594 1.269936 1.266373
#> attr(,"coef")
#> [1] "mmse"
#> 
#> 
#> attr(,"class")
#> [1] "cogxwalkr" "list"