R package latentcor
utilizes the powerful semi-parametric latent Gaussian copula models to estimate latent correlations between mixed data types. The package allows to estimate correlations between any of continuous/binary/ternary/zero-inflated (truncated) variable types. The underlying implementation takes advantage of fast multi-linear interpolation scheme with a clever choice of grid points that give the package a small memory footprint, and allows to use the latent correlations with sub-sampling and bootstrapping.
First, we will generate a pair of variables with different types using a sample size \(n=100\) which will serve as example data. Here first variable will be ternary, and second variable will be continuous.
= GenData(n = 100, types = c("ter", "con")) simdata
The output of GenData
is a list with 2 elements:
names(simdata)
#> [1] "X" "plotX"
X
: a matrix (\(100\times 2\)), the first column is the ternary variable; the second column is the continuous variable.= simdata$X
X head(X, n = 6L)
#> [,1] [,2]
#> [1,] 0 0.20587026
#> [2,] 1 -0.04915793
#> [3,] 1 -0.65222833
#> [4,] 2 0.89411877
#> [5,] 0 0.20746957
#> [6,] 0 -0.50552757
plotX
: NULL (showplot = FALSE
, can be changed to display the plot of generated data inGenData
input).$plotX
simdata#> NULL
Then we can estimate the latent correlation matrix based on these 2 variables using estR
function.
= estR(X, types = c("ter", "con")) estimate
The output of estR
is a list with several elements:
names(estimate)
#> [1] "zratios" "K" "R" "Rpointwise" "plotR"
zratios
is a list has the same length as the number of variables. Here the first element is a (\(2\times1\)) vector indicating the cumulative proportions for zeros and ones in the ternary variable (e.g. first element in vector is the proportion of zeros, second element in vector is the proportion of zeros and ones.) The second element of the list is NA for continuous variable.$zratios
estimate#> [[1]]
#> [1] 0.3 0.8
#>
#> [[2]]
#> [1] NA
K
: Kendall \(\tau\) (\(\tau_{a}\)) correlation matrix for these 2 variables.$K
estimate#> X1 X2
#> X1 1.0000000 0.2359596
#> X2 0.2359596 1.0000000
Rpointwise
: matrix of pointwise estimated correlations. Due to pointwise estimation, Rpointwise
is not guaranteed to be positive semi-definite$Rpointwise
estimate#> X1 X2
#> X1 1.0000000 0.4309563
#> X2 0.4309563 1.0000000
R
: estimated final latent correlation matrix, this matrix is guaranteed to be strictly positive definite (through nearPD
projection and parameter nu
, see Mathematical framework for estimation)$R
estimate#> X1 X2
#> X1 1.0000000 0.4305253
#> X2 0.4305253 1.0000000
plotR
: NULL by default as showplot = FALSE
in estR
. Otherwise displays a heatmap of latent correlation matrix.$plotR
estimate#> NULL
We use the build-in dataset mtcars
:
head(mtcars, n = 6L)
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
#> Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
#> Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
#> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
#> Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
#> Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
Let’s take a look at the unique values for each variable to determine the corresponding data type.
apply(mtcars, 2, table)
#> $mpg
#>
#> 10.4 13.3 14.3 14.7 15 15.2 15.5 15.8 16.4 17.3 17.8 18.1 18.7 19.2 19.7 21
#> 2 1 1 1 1 2 1 1 1 1 1 1 1 2 1 2
#> 21.4 21.5 22.8 24.4 26 27.3 30.4 32.4 33.9
#> 2 1 2 1 1 1 2 1 1
#>
#> $cyl
#>
#> 4 6 8
#> 11 7 14
#>
#> $disp
#>
#> 71.1 75.7 78.7 79 95.1 108 120.1 120.3 121 140.8 145 146.7 160
#> 1 1 1 1 1 1 1 1 1 1 1 1 2
#> 167.6 225 258 275.8 301 304 318 350 351 360 400 440 460
#> 2 1 1 3 1 1 1 1 1 2 1 1 1
#> 472
#> 1
#>
#> $hp
#>
#> 52 62 65 66 91 93 95 97 105 109 110 113 123 150 175 180 205 215 230 245
#> 1 1 1 2 1 1 1 1 1 1 3 1 2 2 3 3 1 1 1 2
#> 264 335
#> 1 1
#>
#> $drat
#>
#> 2.76 2.93 3 3.07 3.08 3.15 3.21 3.23 3.54 3.62 3.69 3.7 3.73 3.77 3.85 3.9
#> 2 1 1 3 2 2 1 1 1 1 1 1 1 1 1 2
#> 3.92 4.08 4.11 4.22 4.43 4.93
#> 3 2 1 2 1 1
#>
#> $wt
#>
#> 1.513 1.615 1.835 1.935 2.14 2.2 2.32 2.465 2.62 2.77 2.78 2.875 3.15
#> 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 3.17 3.19 3.215 3.435 3.44 3.46 3.52 3.57 3.73 3.78 3.84 3.845 4.07
#> 1 1 1 1 3 1 1 2 1 1 1 1 1
#> 5.25 5.345 5.424
#> 1 1 1
#>
#> $qsec
#>
#> 14.5 14.6 15.41 15.5 15.84 16.46 16.7 16.87 16.9 17.02 17.05 17.3 17.4
#> 1 1 1 1 1 1 1 1 1 2 1 1 1
#> 17.42 17.6 17.82 17.98 18 18.3 18.52 18.6 18.61 18.9 19.44 19.47 19.9
#> 1 1 1 1 1 1 1 1 1 2 1 1 1
#> 20 20.01 20.22 22.9
#> 1 1 1 1
#>
#> $vs
#>
#> 0 1
#> 18 14
#>
#> $am
#>
#> 0 1
#> 19 13
#>
#> $gear
#>
#> 3 4 5
#> 15 12 5
#>
#> $carb
#>
#> 1 2 3 4 6 8
#> 7 10 3 10 1 1
Then we can estimate the latent correlation matrix for all variables of mtcars
by using estR
function.
= estR(mtcars, types = c("con", "ter", "con", "con", "con", "con", "con", "bin", "bin", "ter", "con"))
estimate_mtcars #> Using Matrix::nearPD since Minimum eigenvalue of latent correlation matrix is -0.203053866491842 smaller than 0.
The output of estR
for mtcars
:
names(estimate_mtcars)
#> [1] "zratios" "K" "R" "Rpointwise" "plotR"
zratios
: zratios for corresponding variables in mtcars
.$zratios
estimate_mtcars#> [[1]]
#> [1] NA
#>
#> [[2]]
#> [1] 0.34375 0.56250
#>
#> [[3]]
#> [1] NA
#>
#> [[4]]
#> [1] NA
#>
#> [[5]]
#> [1] NA
#>
#> [[6]]
#> [1] NA
#>
#> [[7]]
#> [1] NA
#>
#> [[8]]
#> [1] 0.5625
#>
#> [[9]]
#> [1] 0.59375
#>
#> [[10]]
#> [1] 0.46875 0.84375
#>
#> [[11]]
#> [1] NA
K
: Kendall \(\tau\) (\(\tau_{a}\)) correlation matrix for variables in mtcars
.$K
estimate_mtcars#> mpg cyl disp hp drat wt
#> mpg 1.0000000 -0.6431452 -0.7580645 -0.7278226 0.45564516 -0.7197581
#> cyl -0.6431452 1.0000000 0.6592742 0.6310484 -0.44354839 0.5907258
#> disp -0.7580645 0.6592742 1.0000000 0.6532258 -0.48991935 0.7358871
#> hp -0.7278226 0.6310484 0.6532258 1.0000000 -0.37298387 0.6008065
#> drat 0.4556452 -0.4435484 -0.4899194 -0.3729839 1.00000000 -0.5383065
#> wt -0.7197581 0.5907258 0.7358871 0.6008065 -0.53830645 1.0000000
#> qsec 0.3125000 -0.3649194 -0.2983871 -0.4657258 0.03225806 -0.1411290
#> vs 0.4173387 -0.4475806 -0.4274194 -0.4435484 0.26411290 -0.3467742
#> am 0.3286290 -0.2842742 -0.3649194 -0.2116935 0.40120968 -0.4314516
#> gear 0.3427419 -0.3326613 -0.3770161 -0.2197581 0.45967742 -0.4314516
#> carb -0.4395161 0.3326613 0.3608871 0.5161290 -0.08266129 0.3245968
#> qsec vs am gear carb
#> mpg 0.31250000 0.41733871 0.32862903 0.34274194 -0.43951613
#> cyl -0.36491935 -0.44758065 -0.28427419 -0.33266129 0.33266129
#> disp -0.29838710 -0.42741935 -0.36491935 -0.37701613 0.36088710
#> hp -0.46572581 -0.44354839 -0.21169355 -0.21975806 0.51612903
#> drat 0.03225806 0.26411290 0.40120968 0.45967742 -0.08266129
#> wt -0.14112903 -0.34677419 -0.43145161 -0.43145161 0.32459677
#> qsec 1.00000000 0.46774194 -0.11895161 -0.07258065 -0.44354839
#> vs 0.46774194 1.00000000 0.08467742 0.15322581 -0.36088710
#> am -0.11895161 0.08467742 1.00000000 0.43346774 -0.03629032
#> gear -0.07258065 0.15322581 0.43346774 1.00000000 0.06854839
#> carb -0.44354839 -0.36088710 -0.03629032 0.06854839 1.00000000
Rpointwise
: matrix of pointwise estimated correlations for mtcars
.$Rpointwise
estimate_mtcars#> mpg cyl disp hp drat wt
#> mpg 1.0000000 -0.9990000 -0.9286530 -0.9099905 0.65616525 -0.9046652
#> cyl -0.9990000 1.0000000 0.9990000 0.9900378 -0.77195772 0.9525997
#> disp -0.9286530 0.9990000 1.0000000 0.8552768 -0.69582182 0.9151697
#> hp -0.9099905 0.9900378 0.8552768 1.0000000 -0.55293425 0.8097609
#> drat 0.6561652 -0.7719577 -0.6958218 -0.5529342 1.00000000 -0.7483492
#> wt -0.9046652 0.9525997 0.9151697 0.8097609 -0.74834918 1.0000000
#> qsec 0.4713967 -0.6540431 -0.4517316 -0.6680316 0.05064917 -0.2198737
#> vs 0.8727316 -0.9623421 -0.8905658 -0.9188458 0.57685875 -0.7416377
#> am 0.7178533 -0.7124468 -0.7888268 -0.4746999 0.85723711 -0.9121559
#> gear 0.6234660 -0.6441105 -0.6786359 -0.4119442 0.80260415 -0.7617271
#> carb -0.6368382 0.6025491 0.5370028 0.7247928 -0.12947951 0.4880685
#> qsec vs am gear carb
#> mpg 0.47139674 0.8727316 0.71785333 0.6234660 -0.63683817
#> cyl -0.65404313 -0.9623421 -0.71244682 -0.6441105 0.60254911
#> disp -0.45173164 -0.8905658 -0.78882677 -0.6786359 0.53700280
#> hp -0.66803158 -0.9188458 -0.47469992 -0.4119442 0.72479279
#> drat 0.05064917 0.5768588 0.85723711 0.8026041 -0.12947951
#> wt -0.21987367 -0.7416377 -0.91215587 -0.7617271 0.48806852
#> qsec 1.00000000 0.9599123 -0.27004807 -0.1385035 -0.64170875
#> vs 0.95991229 1.0000000 0.27236999 0.4087924 -0.76863616
#> am -0.27004807 0.2723700 1.00000000 0.9941469 -0.08284094
#> gear -0.13850346 0.4087924 0.99414687 1.0000000 0.13086286
#> carb -0.64170875 -0.7686362 -0.08284094 0.1308629 1.00000000
R
: estimated final latent correlation matrix for mtcars
.$R
estimate_mtcars#> mpg cyl disp hp drat wt
#> mpg 1.0000000 -0.9609031 -0.9415043 -0.9158428 0.66735827 -0.9184175
#> cyl -0.9609031 1.0000000 0.9642266 0.9413892 -0.73792461 0.9100566
#> disp -0.9415043 0.9642266 1.0000000 0.8623242 -0.71394453 0.9357387
#> hp -0.9158428 0.9413892 0.8623242 1.0000000 -0.55916149 0.8168236
#> drat 0.6673583 -0.7379246 -0.7139445 -0.5591615 1.00000000 -0.7655481
#> wt -0.9184175 0.9100566 0.9357387 0.8168236 -0.76554810 1.0000000
#> qsec 0.4823428 -0.5822593 -0.4633043 -0.6776150 0.07314342 -0.2320168
#> vs 0.8544713 -0.9256791 -0.8492790 -0.9218190 0.53281338 -0.7091408
#> am 0.6969207 -0.6621142 -0.7398814 -0.4763248 0.82651611 -0.8702507
#> gear 0.6335341 -0.6404076 -0.7007359 -0.4148761 0.81916584 -0.7795446
#> carb -0.6389233 0.6083585 0.5440334 0.7239277 -0.13666971 0.4925960
#> qsec vs am gear carb
#> mpg 0.48234281 0.8544713 0.69692066 0.6335341 -0.63892330
#> cyl -0.58225925 -0.9256791 -0.66211416 -0.6404076 0.60835846
#> disp -0.46330426 -0.8492790 -0.73988144 -0.7007359 0.54403338
#> hp -0.67761499 -0.9218190 -0.47632483 -0.4148761 0.72392768
#> drat 0.07314342 0.5328134 0.82651611 0.8191658 -0.13666971
#> wt -0.23201675 -0.7091408 -0.87025068 -0.7795446 0.49259599
#> qsec 1.00000000 0.8394639 -0.21423820 -0.1320981 -0.65840975
#> vs 0.83946385 1.0000000 0.34069073 0.3558147 -0.72748608
#> am -0.21423820 0.3406907 1.00000000 0.9329160 -0.06824438
#> gear -0.13209815 0.3558147 0.93291605 1.0000000 0.12065393
#> carb -0.65840975 -0.7274861 -0.06824438 0.1206539 1.00000000
plotR
: NULL by default as showplot = FALSE
in estR
. Otherwise displays a heatmap of latent correlation matrix for mtcars
(See heatmap of latent correlation (approx) for mtcars).$plotR
estimate_mtcars#> NULL
latentcor
utilizes the powerful semi-parametric latent Gaussian copula models to estimate latent correlations between mixed data types (continuous/binary/ternary/truncated or zero-inflated). Below we review the definitions for each type.
Definition of continuous model (Fan et al. 2017)
A random \(X\in\cal{R}^{p}\) satisfies the Gaussian copula (or nonparanormal) model if there exist monotonically increasing \(f=(f_{j})_{j=1}^{p}\) with \(Z_{j}=f_{j}(X_{j})\) satisfying \(Z\sim N_{p}(0, \Sigma)\), \(\sigma_{jj}=1\); we denote \(X\sim NPN(0, \Sigma, f)\).
= GenData(n = 6, types = "con")$X
X
X#> [,1]
#> [1,] 0.8025116
#> [2,] -0.0168194
#> [3,] -2.2159450
#> [4,] 0.2073208
#> [5,] -0.3521075
#> [6,] -1.3127480
Definition of binary model (Fan et al. 2017)
A random \(X\in\cal{R}^{p}\) satisfies the binary latent Gaussian copula model if there exists \(W\sim NPN(0, \Sigma, f)\) such that \(X_{j}=I(W_{j}>c_{j})\), where \(I(\cdot)\) is the indicator function and \(c_{j}\) are constants.
= GenData(n = 6, types = "bin")$X
X
X#> [,1]
#> [1,] 1
#> [2,] 0
#> [3,] 1
#> [4,] 0
#> [5,] 1
#> [6,] 0
Definition of ternary model (Quan, Booth, and Wells 2018)
A random \(X\in\cal{R}^{p}\) satisfies the ternary latent Gaussian copula model if there exists \(W\sim NPN(0, \Sigma, f)\) such that \(X_{j}=I(W_{j}>c_{j})+I(W_{j}>c'_{j})\), where \(I(\cdot)\) is the indicator function and \(c_{j}<c'_{j}\) are constants.
= GenData(n = 6, types = "ter")$X
X
X#> [,1]
#> [1,] 1
#> [2,] 0
#> [3,] 1
#> [4,] 0
#> [5,] 2
#> [6,] 1
Definition of truncated or zero-inflated model (Yoon, Carroll, and Gaynanova 2020)
A random \(X\in\cal{R}^{p}\) satisfies the truncated latent Gaussian copula model if there exists \(W\sim NPN(0, \Sigma, f)\) such that \(X_{j}=I(W_{j}>c_{j})W_{j}\), where \(I(\cdot)\) is the indicator function and \(c_{j}\) are constants.
= GenData(n = 6, types = "tru")$X
X
X#> [,1]
#> [1,] 0.0000000
#> [2,] 0.0000000
#> [3,] 1.1227278
#> [4,] 0.0000000
#> [5,] 1.3762351
#> [6,] 0.7223574
Mixed latent Gaussian copula model
The mixed latent Gaussian copula model jointly models \(W=(W_{1}, W_{2}, W_{3}, W_{4})\sim NPN(0, \Sigma, f)\) such that \(X_{1j}=W_{1j}\), \(X_{2j}=I(W_{2j}>c_{2j})\), \(X_{3j}=I(W_{3j}>c_{3j})+I(W_{3j}>c'_{3j})\) and \(X_{4j}=I(W_{4j}>c_{4j})W_{4j}\).
set.seed("234820")
= GenData(n = 100, types = c("con", "bin", "ter", "tru"))$X
X head(X)
#> [,1] [,2] [,3] [,4]
#> [1,] -0.5728663 0 1 0.0000000
#> [2,] -1.5632883 0 0 0.0000000
#> [3,] 0.4600555 1 1 0.2634213
#> [4,] -1.5186510 1 1 0.0000000
#> [5,] -1.5438165 0 1 0.0000000
#> [6,] -0.5656219 0 0 0.0000000
The estimation of latent correlation matrix \(\Sigma\) is achieved via the bridge function \(F\) which is defined such that \(E(\hat{\tau}_{jk})=F(\sigma_{jk})\), where \(\sigma_{jk}\) is the latent correlation between variables \(j\) and \(k\), and \(\hat{\tau}_{jk}\) is the corresponding sample Kendall’s \(\tau\).
Kendall’s \(\tau\) (\(\tau_{a}\))
Given observed \(\mathbf{x}_{j}, \mathbf{x}_{k}\in\cal{R}^{n}\),
\[ \hat{\tau}_{jk}=\hat{\tau}(\mathbf{x}_{j}, \mathbf{x}_{k})=\frac{2}{n(n-1)}\sum_{1\le i<i'\le n}sign(x_{ij}-x_{i'j})sign(x_{ik}-x_{i'k}), \] where \(n\) is the sample size.
latentcor
calculates pairwise Kendall’s \(\widehat \tau\) as part of the estimation process
= estR(X, types = c("con", "bin", "ter", "tru"))
estimate = estimate$K
K
K#> X1 X2 X3 X4
#> X1 1.0000000 0.2557576 0.2456566 0.3331313
#> X2 0.2557576 1.0000000 0.1555556 0.2339394
#> X3 0.2456566 0.1555556 1.0000000 0.2183838
#> X4 0.3331313 0.2339394 0.2183838 1.0000000
Using \(F\) and \(\widehat \tau_{jk}\), a moment-based estimator is \(\hat{\sigma}_{jk}=F^{-1}(\hat{\tau}_{jk})\) with the corresponding \(\hat{\Sigma}\) being consistent for \(\Sigma\) (Fan et al. 2017; Quan, Booth, and Wells 2018; Yoon, Carroll, and Gaynanova 2020).
The explicit form of bridge function \(F\) has been derived for all combinations of continuous(C)/binary(B)/ternary(N)/truncated(T) variable types, and we summarize the corresponding references. Each of this combinations is implemented in latentcor
.
Type | continuous | binary | ternary | zero-inflated (truncated) |
---|---|---|---|---|
continuous | Liu, Lafferty, and Wasserman (2009) | - | - | - |
binary | Fan et al. (2017) | Fan et al. (2017) | - | - |
ternary | Quan, Booth, and Wells (2018) | Quan, Booth, and Wells (2018) | Quan, Booth, and Wells (2018) | - |
zero-inflated (truncated) | Yoon, Carroll, and Gaynanova (2020) | Yoon, Carroll, and Gaynanova (2020) | See Appendix | Yoon, Carroll, and Gaynanova (2020) |
Below we provide an explicit form of \(F\) for each combination.
Theorem (explicit form of bridge function) Let \(W_{1}\in\cal{R}^{p_{1}}\), \(W_{2}\in\cal{R}^{p_{2}}\), \(W_{3}\in\cal{R}^{p_{3}}\), \(W_{4}\in\cal{R}^{p_{4}}\) be such that \(W=(W_{1}, W_{2}, W_{3}, W_{4})\sim NPN(0, \Sigma, f)\) with \(p=p_{1}+p_{2}+p_{3}+p_{4}\). Let \(X=(X_{1}, X_{2}, X_{3}, X_{4})\in\cal{R}^{p}\) satisfy \(X_{j}=W_{j}\) for \(j=1,...,p_{1}\), \(X_{j}=I(W_{j}>c_{j})\) for \(j=p_{1}+1, ..., p_{1}+p_{2}\), \(X_{j}=I(W_{j}>c_{j})+I(W_{j}>c'_{j})\) for \(j=p_{1}+p_{2}+1, ..., p_{3}\) and \(X_{j}=I(W_{j}>c_{j})W_{j}\) for \(j=p_{1}+p_{2}+p_{3}+1, ..., p\) with \(\Delta_{j}=f(c_{j})\). The rank-based estimator of \(\Sigma\) based on the observed \(n\) realizations of \(X\) is the matrix \(\mathbf{\hat{R}}\) with \(\hat{r}_{jj}=1\), \(\hat{r}_{jk}=\hat{r}_{kj}=F^{-1}(\hat{\tau}_{jk})\) with block structure
\[ \mathbf{\hat{R}}=\begin{pmatrix} F_{CC}^{-1}(\hat{\tau}) & F_{CB}^{-1}(\hat{\tau}) & F_{CN}^{-1}(\hat{\tau}) & F_{CT}^{-1}(\hat{\tau})\\ F_{BC}^{-1}(\hat{\tau}) & F_{BB}^{-1}(\hat{\tau}) & F_{BN}^{-1}(\hat{\tau}) & F_{BT}^{-1}(\hat{\tau})\\ F_{NC}^{-1}(\hat{\tau}) & F_{NB}^{-1}(\hat{\tau}) & F_{NN}^{-1}(\hat{\tau}) & F_{NT}^{-1}(\hat{\tau})\\ F_{TC}^{-1}(\hat{\tau}) & F_{TB}^{-1}(\hat{\tau}) & F_{TN}^{-1}(\hat{\tau}) & F_{TT}^{-1}(\hat{\tau}) \end{pmatrix} \] \[ F(\cdot)=\begin{cases} CC:\ 2\sin^{-1}(r)/\pi \\ \\ BC: \ 4\Phi_{2}(\Delta_{j},0;r/\sqrt{2})-2\Phi(\Delta_{j}) \\ \\ BB: \ 2\{\Phi_{2}(\Delta_{j},\Delta_{k};r)-\Phi(\Delta_{j})\Phi(\Delta_{k})\} \\ \\ NC: \ 4\Phi_{2}(\Delta_{j}^{2},0;r/\sqrt{2})-2\Phi(\Delta_{j}^{2})+4\Phi_{3}(\Delta_{j}^{1},\Delta_{j}^{2},0;\Sigma_{3a}(r))-2\Phi(\Delta_{j}^{1})\Phi(\Delta_{j}^{2})\\ \\ NB: \ 2\Phi_{2}(\Delta_{j}^{2},\Delta_{k},r)\{1-\Phi(\Delta_{j}^{1})\}-2\Phi(\Delta_{j}^{2})\{\Phi(\Delta_{k})-\Phi_{2}(\Delta_{j}^{1},\Delta_{k},r)\} \\ \\ NN: \ 2\Phi_{2}(\Delta_{j}^{2},\Delta_{k}^{2};r)\Phi_{2}(-\Delta_{j}^{1},-\Delta_{k}^{1};r)-2\{\Phi(\Delta_{j}^{2})-\Phi_{2}(\Delta_{j}^{2},\Delta_{k}^{1};r)\}\{\Phi(\Delta_{k}^{2})-\Phi_{2}(\Delta_{j}^{1},\Delta_{k}^{2};r)\} \\ \\ TC: \ -2\Phi_{2}(-\Delta_{j},0;1/\sqrt{2})+4\Phi_{3}(-\Delta_{j},0,0;\Sigma_{3b}(r)) \\ \\ TB: \ 2\{1-\Phi(\Delta_{j})\}\Phi(\Delta_{k})-2\Phi_{3}(-\Delta_{j},\Delta_{k},0;\Sigma_{3c}(r))-2\Phi_{3}(-\Delta_{j},\Delta_{k},0;\Sigma_{3d}(r)) \\ \\ TN: \ -2\Phi(-\Delta_{k}^{1})\Phi(\Delta_{k}^{2}) + 2\Phi_{3}(-\Delta_{k}^{1},\Delta_{k}^{2},\Delta_{j};\Sigma_{3e}(r))+2\Phi_{4}(-\Delta_{k}^{1},\Delta_{k}^{2},-\Delta_{j},0;\Sigma_{4a}(r))+2\Phi_{4}(-\Delta_{k}^{1},\Delta_{k}^{2},-\Delta_{j},0;\Sigma_{4b}(r)) \\ \\ TT: \ -2\Phi_{4}(-\Delta_{j},-\Delta_{k},0,0;\Sigma_{4c}(r))+2\Phi_{4}(-\Delta_{j},-\Delta_{k},0,0;\Sigma_{4d}(r)) \\ \end{cases} \]
where \(\Delta_{j}=\Phi^{-1}(\pi_{0j})\), \(\Delta_{k}=\Phi^{-1}(\pi_{0k})\), \(\Delta_{j}^{1}=\Phi^{-1}(\pi_{0j})\), \(\Delta_{j}^{2}=\Phi^{-1}(\pi_{0j}+\pi_{1j})\), \(\Delta_{k}^{1}=\Phi^{-1}(\pi_{0k})\), \(\Delta_{k}^{2}=\Phi^{-1}(\pi_{0k}+\pi_{1k})\),
\[ \Sigma_{3a}(r)= \begin{pmatrix} 1 & 0 & \frac{r}{\sqrt{2}} \\ 0 & 1 & -\frac{r}{\sqrt{2}} \\ \frac{r}{\sqrt{2}} & -\frac{r}{\sqrt{2}} & 1 \end{pmatrix}, \;\;\; \Sigma_{3b}(r)= \begin{pmatrix} 1 & \frac{1}{\sqrt{2}} & \frac{r}{\sqrt{2}}\\ \frac{1}{\sqrt{2}} & 1 & r \\ \frac{r}{\sqrt{2}} & r & 1 \end{pmatrix}, \;\;\; \Sigma_{3c}(r)= \begin{pmatrix} 1 & -r & \frac{1}{\sqrt{2}} \\ -r & 1 & -\frac{r}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{r}{\sqrt{2}} & 1 \end{pmatrix}, \]
\[ \Sigma_{3d}(r)= \begin{pmatrix} 1 & 0 & -\frac{1}{\sqrt{2}} \\ 0 & 1 & -\frac{r}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} & -\frac{r}{\sqrt{2}} & 1 \end{pmatrix}, \;\;\; \Sigma_{3e}(r)= \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & r \\ 0 & r & 1 \end{pmatrix}, \;\;\; \Sigma_{4a}(r)= \begin{pmatrix} 1 & 0 & 0 & \frac{r}{\sqrt{2}} \\ 0 & 1 & -r & \frac{r}{\sqrt{2}} \\ 0 & -r & 1 & -\frac{1}{\sqrt{2}} \\ \frac{r}{\sqrt{2}} & \frac{r}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 1 \end{pmatrix}, \]
\[ \Sigma_{4b}(r)= \begin{pmatrix} 1 & 0 & r & \frac{r}{\sqrt{2}} \\ 0 & 1 & 0 & \frac{r}{\sqrt{2}} \\ r & 0 & 1 & \frac{1}{\sqrt{2}} \\ \frac{r}{\sqrt{2}} & \frac{r}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 1 \end{pmatrix}, \;\;\; \Sigma_{4c}(r)= \begin{pmatrix} 1 & 0 & \frac{1}{\sqrt{2}} & -\frac{r}{\sqrt{2}} \\ 0 & 1 & -\frac{r}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{r}{\sqrt{2}} & 1 & -r \\ -\frac{r}{\sqrt{2}} & \frac{1}{\sqrt{2}} & -r & 1 \end{pmatrix}\;\;\text{and}\;\; \Sigma_{4d}(r)= \begin{pmatrix} 1 & r & \frac{1}{\sqrt{2}} & \frac{r}{\sqrt{2}} \\ r & 1 & \frac{r}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & \frac{r}{\sqrt{2}} & 1 & r \\ \frac{r}{\sqrt{2}} & \frac{1}{\sqrt{2}} & r & 1 \end{pmatrix}. \]
Given the form of bridge function \(F\), obtaining a moment-based estimation \(\widehat \sigma_{jk}\) requires inversion of \(F\). latentcor
implements two methods for calcultation of the inversion.
method = "original"
)Original estimation approach relies on numerical inversion of \(F\) based on solving uni-root optimization problem.
= estR(X, types = c("con", "bin", "ter", "tru"), method = "original") estimate
Algorithm for Original method
Input: \(F(r)=F(r, \mathbf{\Delta})\) - bridge function based on the type of variables \(j\), \(k\)
$K
estimate#> X1 X2 X3 X4
#> X1 1.0000000 0.2557576 0.2456566 0.3331313
#> X2 0.2557576 1.0000000 0.1555556 0.2339394
#> X3 0.2456566 0.1555556 1.0000000 0.2183838
#> X4 0.3331313 0.2339394 0.2183838 1.0000000
$zratios
estimate#> [[1]]
#> [1] NA
#>
#> [[2]]
#> [1] 0.5
#>
#> [[3]]
#> [1] 0.3 0.8
#>
#> [[4]]
#> [1] 0.5
optimize
function in R.$R
estimate#> X1 X2 X3 X4
#> X1 1.0000000 0.5524373 0.4476503 0.5820345
#> X2 0.5524373 1.0000000 0.4046173 0.5815691
#> X3 0.4476503 0.4046173 1.0000000 0.4649222
#> X4 0.5820345 0.5815691 0.4649222 1.0000000
method = "approx"
)A faster approximation method is based on multi-linear interpolation of pre-computed inverse bridge function on a fixed grid of points. This is possible as the inverse bridge function is an analytic function of at most 5 parameters:
In short, d-dimensional multi-linear interpolation uses a weighted average of \(2^{d}\) neighbors to approximate the function values at the points within the d-dimensional cube of the neighbors, and to perform interpolation, latentcor
takes advantage of the R package chebpol
(Gaure 2019). This approximation method has been first described in (Yoon, Müller, and Gaynanova 2021) for continuous/binary/truncated cases. In latentcor
, we additionally implement ternary case, and optimize the choice of grid as well as interpolation boundary for faster computations with smaller memory footprint.
= estR(X, types = c("con", "bin", "ter", "tru"), method = "approx") estimate
Algorithm for Approximation method
Input: Let \(\check{g}=h(g)\), pre-computed values \(F^{-1}(h^{-1}(\check{g}))\) on a fixed grid \(\check{g}\in\check{\cal{G}}\) based on the type of variables \(j\) and \(k\). For binary/continuous case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j})\); for binary/binary case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j}, \check{\Delta}_{k})\); for truncated/continuous case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j})\); for truncated/truncated case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j}, \check{\Delta}_{k})\); for ternary/continuous case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j}^{1}, \check{\Delta}_{j}^{2})\); for ternary/binary case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j}^{1}, \check{\Delta}_{j}^{2}, \check{\Delta}_{k})\); for ternary/truncated case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j}^{1}, \check{\Delta}_{j}^{2}, \check{\Delta}_{k})\); for ternay/ternary case, \(\check{g}=(\check{\tau}_{jk}, \check{\Delta}_{j}^{1}, \check{\Delta}_{j}^{2}, \check{\Delta}_{k}^{1}, \check{\Delta}_{k}^{2})\).
Step 1 and Step 2 same as Original method.
Step 3. If \(|\hat{\tau}_{jk}|\le \mbox{ratio}\times \bar{\tau}_{jk}(\cdot)\), apply interpolation; otherwise apply Original method.
To avoid interpolation in areas with high approximation errors close to the boundary, we use hybrid scheme in Step 3. For the derivation of approximate bound for BC, BB, TC, TB, TT cases see Yoon, Müller, and Gaynanova (2021). The derivation of approximate bound for NC, NB, NN, NT case is in the Appendix.
\[ \bar{\tau}_{jk}(\cdot)= \begin{cases} 2\pi_{0j}(1-\pi_{0j}) & for \; BC \; case\\ 2\min(\pi_{0j},\pi_{0k})\{1-\max(\pi_{0j}, \pi_{0k})\} & for \; BB \; case\\ 2\{\pi_{0j}(1-\pi_{0j})+\pi_{1j}(1-\pi_{0j}-\pi_{1j})\} & for \; NC \; case\\ 2\min(\pi_{0j}(1-\pi_{0j})+\pi_{1j}(1-\pi_{0j}-\pi_{1j}),\pi_{0k}(1-\pi_{0k})) & for \; NB \; case\\ 2\min(\pi_{0j}(1-\pi_{0j})+\pi_{1j}(1-\pi_{0j}-\pi_{1j}), \\ \;\;\;\;\;\;\;\;\;\;\pi_{0k}(1-\pi_{0k})+\pi_{1k}(1-\pi_{0k}-\pi_{1k})) & for \; NN \; case\\ 1-(\pi_{0j})^{2} & for \; TC \; case\\ 2\max(\pi_{0k},1-\pi_{0k})\{1-\max(\pi_{0k},1-\pi_{0k},\pi_{0j})\} & for \; TB \; case\\ 1-\{\max(\pi_{0j},\pi_{0k},\pi_{1k},1-\pi_{0k}-\pi_{1k})\}^{2} & for \; TN \; case\\ 1-\{\max(\pi_{0j},\pi_{0k})\}^{2} & for \; TT \; case\\ \end{cases} \]
By default, latentcor
uses \(\mbox{ratio} = 0.9\), but this value can be modified by the user
estR(X, types = c("con", "bin", "ter", "tru"), method = "approx", ratio = 0.99)$R
#> X1 X2 X3 X4
#> X1 1.0000000 0.5522684 0.4472342 0.5817297
#> X2 0.5522684 1.0000000 0.4054908 0.5803080
#> X3 0.4472342 0.4054908 1.0000000 0.4563203
#> X4 0.5817297 0.5803080 0.4563203 1.0000000
estR(X, types = c("con", "bin", "ter", "tru"), method = "approx", ratio = 0.4)$R
#> X1 X2 X3 X4
#> X1 1.0000000 0.5524373 0.4472342 0.5820345
#> X2 0.5524373 1.0000000 0.4054908 0.5815691
#> X3 0.4472342 0.4054908 1.0000000 0.4563203
#> X4 0.5820345 0.5815691 0.4563203 1.0000000
estR(X, types = c("con", "bin", "ter", "tru"), method = "original")$R
#> X1 X2 X3 X4
#> X1 1.0000000 0.5524373 0.4476503 0.5820345
#> X2 0.5524373 1.0000000 0.4046173 0.5815691
#> X3 0.4476503 0.4046173 1.0000000 0.4649222
#> X4 0.5820345 0.5815691 0.4649222 1.0000000
The lower is the ratio
, the closer is the approximation method to original method (with ratio = 0
being equivalent to method = "original"
), but also the higher is the cost of computations.
Rescaled Grid for Interpolation
Since \(|\hat{\tau}|\le \bar{\tau}\), the grid does not need to cover the whole domain \(\tau\in[-1, 1]\). To optimize memory associated with storing the grid, we rescale \(\tau\) as follows: \(\check{\tau}_{jk}=\tau_{jk}/\bar{\tau}_{jk}\in[-1, 1]\), where \(\bar{\tau}_{jk}\) is as defined above.
In addition, for ternary variable \(j\), it always holds that \(\Delta_{j}^{2}>\Delta_{j}^{1}\) since \(\Delta_{j}^{1}=\Phi^{-1}(\pi_{0j})\) and \(\Delta_{j}^{2}=\Phi^{-1}(\pi_{0j}+\pi_{1j})\). Thus, the grid should not cover the the area corresponding to \(\Delta_{j}^{2}\ge\Delta_{j}^{1}\). We thus rescale as follows: \(\check{\Delta}_{j}^{1}=\Delta_{j}^{1}/\Delta_{j}^{2}\in[0, 1]\); \(\check{\Delta}_{j}^{2}=\Delta_{j}^{2}\in[0, 1]\).
Since the estimation is performed point-wise, the resulting matrix of estimated latent correlations is not guaranteed to be positive semi-definite. For example, this could be expected when the sample size is small (and so the estimation error for each pairwise correlation is larger)
set.seed("234820")
= GenData(n = 6, types = c("con", "bin", "ter", "tru"))$X
X
X#> [,1] [,2] [,3] [,4]
#> [1,] -0.5182800 0 1 0.1021738
#> [2,] -1.3017092 0 0 0.0000000
#> [3,] 0.3145191 1 2 0.4213514
#> [4,] -0.6093291 0 1 1.2771610
#> [5,] -1.3175490 1 0 0.0000000
#> [6,] -0.7807245 1 1 0.0000000
= estR(X, types = c("con", "bin", "ter", "tru"))
out $Rpointwise
out#> X1 X2 X3 X4
#> X1 1.0000000 -0.1477240 0.9990000 0.8548518
#> X2 -0.1477240 1.0000000 0.3523666 -0.5030324
#> X3 0.9990000 0.3523666 1.0000000 0.9114307
#> X4 0.8548518 -0.5030324 0.9114307 1.0000000
eigen(out$Rpointwise)$values
#> [1] 2.85954424 1.29130852 0.09944544 -0.25029820
latentcor
automatically corrects the pointwise estimator to be positive definite by making two adjustments. First, if Rpointwise
has smallest eigenvalue less than zero, the estR
projects this matrix to the nearest positive semi-definite matrix. The user is notified of this adjustment through the message (supressed in previous code chunk), e.g.
= estR(X, types = c("con", "bin", "ter", "tru"))
out #> Using Matrix::nearPD since Minimum eigenvalue of latent correlation matrix is -0.25029819695076 smaller than 0.
Second, latentcor
shrinks the adjusted matrix of correlations towards identity matrix using the parameter \(\nu\) with default value of 0.001 (nu = 0.001
), so that the resulting R
is strictly positive definite with the minimal eigenvalue being greater or equal to \(\nu\). That is \[
R = (1 - \nu) \widetilde R + \nu I,
\] where \(\widetilde R\) is the nearest positive semi-definite matrix to Rpointwise
.
= estR(X, types = c("con", "bin", "ter", "tru"), nu = 0.001)
out #> Using Matrix::nearPD since Minimum eigenvalue of latent correlation matrix is -0.25029819695076 smaller than 0.
$Rpointwise
out#> X1 X2 X3 X4
#> X1 1.0000000 -0.1477240 0.9990000 0.8548518
#> X2 -0.1477240 1.0000000 0.3523666 -0.5030324
#> X3 0.9990000 0.3523666 1.0000000 0.9114307
#> X4 0.8548518 -0.5030324 0.9114307 1.0000000
$R
out#> X1 X2 X3 X4
#> X1 1.0000000 -0.1053533 0.9232992 0.9048072
#> X2 -0.1053533 1.0000000 0.2372115 -0.4244433
#> X3 0.9232992 0.2372115 1.0000000 0.7723678
#> X4 0.9048072 -0.4244433 0.7723678 1.0000000
As a result, R
and Rpointwise
could be quite different when sample size \(n\) is small. When \(n\) is large and \(p\) is moderate, the difference is typically driven by parameter nu
.
set.seed("234820")
= GenData(n = 100, types = c("con", "bin", "ter", "tru"))$X
X = estR(X, types = c("con", "bin", "ter", "tru"), nu = 0.001)
out $Rpointwise
out#> X1 X2 X3 X4
#> X1 1.0000000 0.5528213 0.4476819 0.5823120
#> X2 0.5528213 1.0000000 0.4058967 0.5808889
#> X3 0.4476819 0.4058967 1.0000000 0.4567771
#> X4 0.5823120 0.5808889 0.4567771 1.0000000
$R
out#> X1 X2 X3 X4
#> X1 1.0000000 0.5522684 0.4472342 0.5817297
#> X2 0.5522684 1.0000000 0.4054908 0.5803080
#> X3 0.4472342 0.4054908 1.0000000 0.4563203
#> X4 0.5817297 0.5803080 0.4563203 1.0000000
Without loss of generality, let \(j=1\) and \(k=2\). By the definition of Kendall’s \(\tau\), \[ \tau_{12}=E(\hat{\tau}_{12})=E[\frac{2}{n(n-1)}\sum_{1\leq i\leq i' \leq n} sign\{(X_{i1}-X_{i'1})(X_{i2}-X_{i'2})\}]. \] Since \(X_{1}\) is ternary, \[\begin{align} &sign(X_{1}-X_{1}') \nonumber\\ =&[I(U_{1}>C_{11},U_{1}'\leq C_{11})+I(U_{1}>C_{12},U_{1}'\leq C_{12})-I(U_{1}>C_{12},U_{1}'\leq C_{11})] \nonumber\\ &-[I(U_{1}\leq C_{11}, U_{1}'>C_{11})+I(U_{1}\leq C_{12}, U_{1}'>C_{12})-I(U_{1}\leq C_{11}, U_{1}'>C_{12})] \nonumber\\ =&[I(U_{1}>C_{11})-I(U_{1}>C_{11},U_{1}'>C_{11})+I(U_{1}>C_{12})-I(U_{1}>C_{12},U_{1}'>C_{12}) \nonumber\\ &-I(U_{1}>C_{12})+I(U_{1}>C_{12},U_{1}'>C_{11})] \nonumber\\ &-[I(U_{1}'>C_{11})-I(U_{1}>C_{11},U_{1}'>C_{11})+I(U_{1}'>C_{12})-I(U_{1}>C_{12},U_{1}'>C_{12}) \nonumber\\ &-I(U_{1}'>C_{12})+I(U_{1}>C_{11},U_{1}'>C_{12})] \nonumber\\ =&I(U_{1}>C_{11})+I(U_{1}>C_{12},U_{1}'>C_{11})-I(U_{1}'>C_{11})-I(U_{1}>C_{11},U_{1}'>C_{12}) \nonumber\\ =&I(U_{1}>C_{11},U_{1}'\leq C_{12})-I(U_{1}'>C_{11},U_{1}\leq C_{12}). \end{align}\] Since \(X_{2}\) is truncated, \(C_{1}>0\) and \[\begin{align} sign(X_{2}-X_{2}')=&-I(X_{2}=0,X_{2}'>0)+I(X_{2}>0,X_{2}'=0) \nonumber\\ &+I(X_{2}>0,X_{2}'>0)sign(X_{2}-X_{2}') \nonumber\\ =&-I(X_{2}=0)+I(X_{2}'=0)+I(X_{2}>0,X_{2}'>0)sign(X_{2}-X_{2}'). \end{align}\] Since \(f\) is monotonically increasing, \(sign(X_{2}-X_{2}')=sign(Z_{2}-Z_{2}')\), \[\begin{align} \tau_{12}=&E[I(U_{1}>C_{11},U_{1}'\leq C_{12}) sign(X_{2}-X_{2}')] \nonumber\\ &-E[I(U_{1}'>C_{11},U_{1}\leq C_{12}) sign(X_{2}-X_{2}')] \nonumber\\ =&-E[I(U_{1}>C_{11},U_{1}'\leq C_{12}) I(X_{2}=0)] \nonumber\\ &+E[I(U_{1}>C_{11},U_{1}'\leq C_{12}) I(X_{2}'=0)] \nonumber\\ &+E[I(U_{1}>C_{11},U_{1}'\leq C_{12})I(X_{2}>0,X_{2}'>0)sign(Z_{2}-Z_{2}')] \nonumber\\ &+E[I(U_{1}'>C_{11},U_{1}\leq C_{12}) I(X_{2}=0)] \nonumber\\ &-E[I(U_{1}'>C_{11},U_{1}\leq C_{12}) I(X_{2}'=0)] \nonumber\\ &-E[I(U_{1}'>C_{11},U_{1}\leq C_{12})I(X_{2}>0,X_{2}'>0)sign(Z_{2}-Z_{2}')] \nonumber\\ =&-2E[I(U_{1}>C_{11},U_{1}'\leq C_{12}) I(X_{2}=0)] \nonumber\\ &+2E[I(U_{1}>C_{11},U_{1}'\leq C_{12}) I(X_{2}'=0)] \nonumber\\ &+E[I(U_{1}>C_{11},U_{1}'\leq C_{12})I(X_{2}>0,X_{2}'>0)sign(Z_{2}-Z_{2}')] \nonumber\\ &-E[I(U_{1}'>C_{11},U_{1}\leq C_{12})I(X_{2}>0,X_{2}'>0)sign(Z_{2}-Z_{2}')]. \end{align}\] From the definition of \(U\), let \(Z_{j}=f_{j}(U_{j})\) and \(\Delta_{j}=f_{j}(C_{j})\) for \(j=1,2\). Using \(sign(x)=2I(x>0)-1\), we obtain \[\begin{align} \tau_{12}=&-2E[I(Z_{1}>\Delta_{11},Z_{1}'\leq \Delta_{12},Z_{2}\leq \Delta_{2})]+2E[I(Z_{1}>\Delta_{11},Z_{1}'\leq \Delta_{12},Z_{2}'\leq \Delta_{2})] \nonumber\\ &+2E[I(Z_{1}>\Delta_{11},Z_{1}'\leq \Delta_{12})I(Z_{2}>\Delta_{2},Z_{2}'>\Delta_{2},Z_{2}-Z_{2}'>0)] \nonumber\\ &-2E[I(Z_{1}'>\Delta_{11},Z_{1}\leq \Delta_{12})I(Z_{2}>\Delta_{2},Z_{2}'>\Delta_{2},Z_{2}-Z_{2}'>0)] \nonumber\\ =&-2E[I(Z_{1}>\Delta_{11},Z_{1}'\leq \Delta_{12}, Z_{2}\leq \Delta_{2})]+2E[I(Z_{1}>\Delta_{11},Z_{1}'\leq \Delta_{12}, Z_{2}'\leq \Delta_{2})] \nonumber\\ &+2E[I(Z_{1}>\Delta_{11},Z_{1}'\leq\Delta_{12},Z_{2}'>\Delta_{2},Z_{2}>Z_{2}')] \nonumber\\ &-2E[I(Z_{1}'>\Delta_{11},Z_{1}\leq\Delta_{12},Z_{2}'>\Delta_{2},Z_{2}>Z_{2}')]. \end{align}\] Since \(\{\frac{Z_{2}'-Z_{2}}{\sqrt{2}}, -Z{1}\}\), \(\{\frac{Z_{2}'-Z_{2}}{\sqrt{2}}, Z{1}'\}\) and \(\{\frac{Z_{2}'-Z_{2}}{\sqrt{2}}, -Z{2}'\}\) are standard bivariate normally distributed variables with correlation \(-\frac{1}{\sqrt{2}}\), \(r/\sqrt{2}\) and \(-\frac{r}{\sqrt{2}}\), respectively, by the definition of \(\Phi_3(\cdot,\cdot, \cdot;\cdot)\) and \(\Phi_4(\cdot,\cdot, \cdot,\cdot;\cdot)\) we have \[\begin{align} F_{NT}(r;\Delta_{j}^{1},\Delta_{j}^{2},\Delta_{k})= & -2\Phi_{3}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},\Delta_{k};\begin{pmatrix} 1 & 0 & -r \\ 0 & 1 & 0 \\ -r & 0 & 1 \end{pmatrix} \right\} \nonumber\\ &+2\Phi_{3}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},\Delta_{k};\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & r \\ 0 & r & 1 \end{pmatrix}\right\}\nonumber \\ & +2\Phi_{4}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k},0;\begin{pmatrix} 1 & 0 & 0 & \frac{r}{\sqrt{2}} \\ 0 & 1 & -r & \frac{r}{\sqrt{2}} \\ 0 & -r & 1 & -\frac{1}{\sqrt{2}} \\ \frac{r}{\sqrt{2}} & \frac{r}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 1 \end{pmatrix}\right\} \nonumber\\ &-2\Phi_{4}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k},0;\begin{pmatrix} 1 & 0 & r & -\frac{r}{\sqrt{2}} \\ 0 & 1 & 0 & -\frac{r}{\sqrt{2}} \\ r & 0 & 1 & -\frac{1}{\sqrt{2}} \\ -\frac{r}{\sqrt{2}} & -\frac{r}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 1 \end{pmatrix}\right\}. \end{align}\] Using the facts that \[\begin{align} &\Phi_{4}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k},0;\begin{pmatrix} 1 & 0 & r & -\frac{r}{\sqrt{2}} \\ 0 & 1 & 0 & -\frac{r}{\sqrt{2}} \\ r & 0 & 1 & -\frac{1}{\sqrt{2}} \\ -\frac{r}{\sqrt{2}} & -\frac{r}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 1 \end{pmatrix}\right\} \nonumber\\ &+\Phi_{4}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k},0;\begin{pmatrix} 1 & 0 & r & \frac{r}{\sqrt{2}} \\ 0 & 1 & 0 & \frac{r}{\sqrt{2}} \\ r & 0 & 1 & \frac{1}{\sqrt{2}} \\ \frac{r}{\sqrt{2}} & \frac{r}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 1 \end{pmatrix}\right\} \nonumber\\ =&\Phi_{3}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k};\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & r \\ 0 & r & 1 \end{pmatrix}\right\} \end{align}\] and \[\begin{align} &\Phi_{3}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k};\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & r \\ 0 & r & 1 \end{pmatrix}\right\}+\Phi_{3}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},\Delta_{k};\begin{pmatrix} 1 & 0 & -r \\ 0 & 1 & 0 \\ -r & 0 & 1 \end{pmatrix} \right\} \nonumber\\ =&\Phi_{2}(-\Delta_{j}^{1},\Delta_{j}^{2};0) =\Phi(-\Delta_{j}^{1})\Phi(\Delta_{j}^{2}). \end{align}\] So that, \[\begin{align} F_{NT}(r;\Delta_{j}^{1},\Delta_{j}^{2},\Delta_{k})= & -2\Phi(-\Delta_{j}^{1})\Phi(\Delta_{j}^{2}) \nonumber\\ &+2\Phi_{3}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},\Delta_{k};\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & r \\ 0 & r & 1 \end{pmatrix}\right\}\nonumber \\ & +2\Phi_{4}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k},0;\begin{pmatrix} 1 & 0 & 0 & \frac{r}{\sqrt{2}} \\ 0 & 1 & -r & \frac{r}{\sqrt{2}} \\ 0 & -r & 1 & -\frac{1}{\sqrt{2}} \\ \frac{r}{\sqrt{2}} & \frac{r}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 1 \end{pmatrix}\right\} \nonumber\\ &+2\Phi_{4}\left\{-\Delta_{j}^{1},\Delta_{j}^{2},-\Delta_{k},0;\begin{pmatrix} 1 & 0 & r & \frac{r}{\sqrt{2}} \\ 0 & 1 & 0 & \frac{r}{\sqrt{2}} \\ r & 0 & 1 & \frac{1}{\sqrt{2}} \\ \frac{r}{\sqrt{2}} & \frac{r}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 1 \end{pmatrix}\right\}. \end{align}\]
It is easy to get the bridge function for truncated/ternary case by switching \(j\) and \(k\).
Let \(n_{0x}=\sum_{i=1}^{n_x}I(x_{i}=0)\), \(n_{2x}=\sum_{i=1}^{n_x}I(x_{i}=2)\), \(\pi_{0x}=\frac{n_{0x}}{n_{x}}\) and \(\pi_{2x}=\frac{n_{2x}}{n_{x}}\), then \[\begin{align} |\tau(\mathbf{x})|\leq & \frac{n_{0x}(n-n_{0x})+n_{2x}(n-n_{0x}-n_{2x})}{\begin{pmatrix} n \\ 2 \end{pmatrix}} \nonumber\\ = & 2\{\frac{n_{0x}}{n-1}-(\frac{n_{0x}}{n})(\frac{n_{0x}}{n-1})+\frac{n_{2x}}{n-1}-(\frac{n_{2x}}{n})(\frac{n_{0x}}{n-1})-(\frac{n_{2x}}{n})(\frac{n_{2x}}{n-1})\} \nonumber\\ \approx & 2\{\frac{n_{0x}}{n}-(\frac{n_{0x}}{n})^2+\frac{n_{2x}}{n}-(\frac{n_{2x}}{n})(\frac{n_{0x}}{n})-(\frac{n_{2x}}{n})^2\} \nonumber\\ = & 2\{\pi_{0x}(1-\pi_{0x})+\pi_{2x}(1-\pi_{0x}-\pi_{2x})\} \end{align}\]
For ternary/binary and ternary/ternary cases, we combine the two individual bounds.
Let \(\mathbf{x}\in\mathcal{R}^{n}\) and \(\mathbf{y}\in\mathcal{R}^{n}\) be the observed \(n\) realizations of ternary and truncated variables, respectively. Let \(n_{0x}=\sum_{i=0}^{n}I(x_{i}=0)\), \(\pi_{0x}=\frac{n_{0x}}{n}\), \(n_{1x}=\sum_{i=0}^{n}I(x_{i}=1)\), \(\pi_{1x}=\frac{n_{1x}}{n}\), \(n_{2x}=\sum_{i=0}^{n}I(x_{i}=2)\), \(\pi_{2x}=\frac{n_{2x}}{n}\), \(n_{0y}=\sum_{i=0}^{n}I(y_{i}=0)\), \(\pi_{0y}=\frac{n_{0y}}{n}\), \(n_{0x0y}=\sum_{i=0}^{n}I(x_{i}=0 \;\& \; y_{i}=0)\), \(n_{1x0y}=\sum_{i=0}^{n}I(x_{i}=1 \;\& \; y_{i}=0)\) and \(n_{2x0y}=\sum_{i=0}^{n}I(x_{i}=2 \;\& \; y_{i}=0)\) then \[\begin{align} |\tau(\mathbf{x}, \mathbf{y})|\leq & \frac{\begin{pmatrix}n \\ 2\end{pmatrix}-\begin{pmatrix}n_{0x} \\ 2\end{pmatrix}-\begin{pmatrix}n_{1x} \\ 2\end{pmatrix}-\begin{pmatrix} n_{2x} \\ 2 \end{pmatrix}-\begin{pmatrix}n_{0y} \\ 2\end{pmatrix}+\begin{pmatrix}n_{0x0y} \\ 2 \end{pmatrix}+\begin{pmatrix}n_{1x0y} \\ 2\end{pmatrix}+\begin{pmatrix}n_{2x0y} \\ 2\end{pmatrix}}{\begin{pmatrix}n \\ 2\end{pmatrix}} \nonumber \end{align}\] Since \(n_{0x0y}\leq\min(n_{0x},n_{0y})\), \(n_{1x0y}\leq\min(n_{1x},n_{0y})\) and \(n_{2x0y}\leq\min(n_{2x},n_{0y})\) we obtain \[\begin{align} |\tau(\mathbf{x}, \mathbf{y})|\leq & \frac{\begin{pmatrix}n \\ 2\end{pmatrix}-\begin{pmatrix}n_{0x} \\ 2\end{pmatrix}-\begin{pmatrix}n_{1x} \\ 2\end{pmatrix}-\begin{pmatrix} n_{2x} \\ 2 \end{pmatrix}-\begin{pmatrix}n_{0y} \\ 2\end{pmatrix}}{\begin{pmatrix}n \\ 2\end{pmatrix}} \nonumber\\ & + \frac{\begin{pmatrix}\min(n_{0x},n_{0y}) \\ 2 \end{pmatrix}+\begin{pmatrix}\min(n_{1x},n_{0y}) \\ 2\end{pmatrix}+\begin{pmatrix}\min(n_{2x},n_{0y}) \\ 2\end{pmatrix}}{\begin{pmatrix}n \\ 2\end{pmatrix}} \nonumber\\ \leq & \frac{\begin{pmatrix}n \\ 2\end{pmatrix}-\begin{pmatrix}\max(n_{0x},n_{1x},n_{2x},n_{0y}) \\ 2\end{pmatrix}}{\begin{pmatrix}n \\ 2\end{pmatrix}} \nonumber\\ \leq & 1-\frac{\max(n_{0x},n_{1x},n_{2x},n_{0y})(\max(n_{0x},n_{1x},n_{2x},n_{0y})-1)}{n(n-1)} \nonumber\\ \approx & 1-(\frac{\max(n_{0x},n_{1x},n_{2x},n_{0y})}{n})^{2} \nonumber\\ =& 1-\{\max(\pi_{0x},\pi_{1x},\pi_{2x},\pi_{0y})\}^{2} \nonumber\\ =& 1-\{\max(\pi_{0x},(1-\pi_{0x}-\pi_{2x}),\pi_{2x},\pi_{0y})\}^{2} \end{align}\]
It is easy to get the approximate bound for truncated/ternary case by switching \(\mathbf{x}\) and \(\mathbf{y}\).