Basic Statistics
13.2 Solutions
-
13.2.1 The variances of \(X\) and \(Y\) and the covariance between \(X\) and \(Y\) are given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} S^2_X =& 4.127269, &&& S^2_Y =& 4.127629 &\textrm { and } && S_{XY}=& 3.095609. \end{align*}
The point estimate of the sample correlation coefficient is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} r=& \dfrac {3.095609}{\sqrt {4.127269\times 4.127629}}=0.7500054. \end{align*}
The hypothesis of interest to be tested is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} H_0: \rho =& 0 \end{align*} against the alternative
\(\seteqnumber{0}{13.}{0}\)\begin{align*} H_1: \rho \ne & 0. \end{align*}
The two tests presented in the section are:
-
i) Exact test assuming bivariate normality:
The test statistic is:
\(\seteqnumber{0}{13.}{0}\)\begin{align*} t_c =& \dfrac {r\sqrt {n-2}}{\sqrt {1-r^2}}= \dfrac {0.7500054\sqrt {11-2}}{\sqrt {1-0.7500054^2}}\\ =& 3.401736. \end{align*} Since under \(H_0\) the value of this statistic is a random value of the Student’s \(t\) distribution with \(\nu \) \(=\) \(11-2\) \(=\) \(9\) degrees of freedom, under bivariate normality and \(\rho \) \(=\) \(0\), we have an associated \(p\)-value of \(0.007851702\). Since the \(p\)-value is less than the nominal significance level adopted of \(5\%\), we reject the null hypothesis of zero correlation between the two variables. Therefore, the two methods are correlated in the determination of a given mineral of interest.
-
ii) Approximate Fisher test for \(\rho =0\), using the Pearson correlation
The estimated correlation is the same, \(r=0.75\), the standard deviation is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \sigma _z =& \dfrac {1}{\sqrt {n - 3}}=0.3535534. \end{align*}
The transformation led to the quantity \(z\) \(=\) \(0.9729674\), whose mean under \(H_0: \rho =0\) was \(\mu _z\) \(=\) \(0\), as expected. The test statistic was
\(\seteqnumber{0}{13.}{0}\)\begin{align*} Z_c =& \dfrac {0.9729674-0}{0.3535534}=2.751967, \end{align*} whose associated \(p\)-value is \(0.005923841\), which leads us to reject \(H_0\), considering the nominal significance level of \(5\%\). Therefore, the conclusions are the same as the first test.
To measure the magnitude of their agreement (effect size), we will proceed with obtaining the confidence intervals presented in this chapter. All methods will be presented and, at the end, the R program used to obtain them.
-
Since the quantile of the standard normal distribution is \(Z_{0.025}\) \(=\) \(1.96\), the auxiliary quantities for obtaining the confidence interval are
\(\seteqnumber{0}{13.}{0}\)\begin{align*} A=& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+R}{1-R} \right ) - \dfrac {Z_{\alpha /2}}{\sqrt {n-3}}\right ]\right \}\\ =& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+ 0.7500054}{1-0.7500054} \right ) - \dfrac {1.96}{\sqrt {11-3}}\right ]\right \}\\ =& 1.750727 \end{align*} and
\(\seteqnumber{0}{13.}{0}\)\begin{align*} B =& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+R}{1-R} \right ) + \dfrac {Z_{\alpha /2}}{\sqrt {n-3}}\right ]\right \} \\ =& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+0.7500054}{1-0.7500054} \right ) + \dfrac {1.96}{\sqrt {11-3}}\right ]\right \}\\ =& 27.98976. \end{align*}
Thus,
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{95\%}(\rho ):&\,\,\left [\dfrac {A-1}{A+1},\,\, \dfrac {B-1}{B+1}\right ] = \left [\dfrac {1.750727-1}{1.750727+1},\,\, \dfrac {27.98976-1}{27.98976+1}\right ]\\ &\,\, =[0.2729194,\,\, 0.9310101]. \end{align*}
-
ii) Muddapur (1988)
The Muddapur interval depends on the upper \(2.5\%\) quantile of the \(F\) distribution with \(\nu _1\) \(=\) \(\nu _2\) \(=\) \(\nu \) \(=\) \(n - 2\) \(=\) \(9\) degrees of freedom. This quantile is \(F_{0.025;\nu _1=9,\nu _2=9}\) \(=\) \(4.025994\). The interval is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} &CI_{0.95}(\rho ):\,\, \left [\dfrac {\left (1+F_{0.025}\right )R + \left (1 - F_{0.025}\right )}{\left (1+F_{0.025}\right ) + \left (1 - F_{0.025}\right )R},\,\, \dfrac {\left (1+F_{0.025}\right )R - \left (1 - F_{0.025}\right )}{\left (1+F_{0.025}\right ) - \left (1 - F_{0.025}\right )R}\right ] \\ & = \left [\dfrac {\left (1+4.025994\right )0.7500054 + \left (1 - 4.025994\right )}{\left (1+4.025994\right ) + \left (1 - 4.025994\right )0.7500054},\,\, \dfrac {\left (1+4.025994\right )0.7500054 -4.025994 \left (1 - 4.025994\right )}{\left (1+4.025994\right ) - \left (1 - 4.025994\right ) 0.7500054}\right ]\\ &= [0.2697382,\,\,0.9314661]. \end{align*}
-
iii) Jeyaratnam (1992)
The upper quantile of the Student’s \(t\) distribution to determine this interval with \(\nu \) \(=\) \(n - 2\) \(=\) \(9\) degrees of freedom is \(t_{0.025;\nu =9}\) \(=\) \(2.262157\). The value of the auxiliary quantity \(C\) is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} C =& \sqrt {\dfrac {t_{0.025;\nu =9}^2}{t_{0.025;\nu =9}^2+9}} = \sqrt {\dfrac {2.262157^2}{2.262157^2+11}} =0.6020688. \end{align*}
Thus, the confidence interval is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{0.95}(\rho ):&\,\, \left [\dfrac {R - C}{1-RC},\,\, \dfrac {R+C}{1+R C}\right ]\\ &\,\,= \left [\dfrac {0.7500054 - 0.5529435}{1-0.7500054\times 0.6020688},\,\, \dfrac {0.7500054+0.6020688}{1+0.7500054 \times 0.6020688}\right ]\\ &\,\, =[0.2697382,\,\,0.9314661]. \end{align*}
-
iv) Exact interval for \(\rho ^2\)
The alternative commented previously was applied. Given the calculated value of \(r^2\) \(=\) \(0.7500054^2\) \(=\) \(0.5625081\), the distribution function was numerically inverted with respect to the non-centrality parameter \(\rho ^2\). The interval obtained (using Python and not the R program below) was
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{0.95}(\rho ):&\,\, [0.254184,\, 0.9208833]. \end{align*}
This result is used for comparison purposes with the other intervals.
In all cases, it can be concluded with \(95\%\) confidence that there is a reasonable positive linear correlation between the two methods and that its real value should be between \(0.25\) and \(0.92\). All methods showed great agreement among themselves. If the small sample size of \(n = 11\) is considered, this result is surprising.
The R program made to facilitate the application of the tests and obtaining the confidence intervals in this example or in others of interest to the reader is presented below with the present example as illustration. It should be emphasized that the three types of correlation, Pearson, Spearman or Kendall, can be used in all procedures. I also included the solved examples of the book so that the reader can use them and compare the results with those presented in the Book. It should be emphasized that the Kendall test has a continuity correction, which was not presented in the Book.
# Function to apply the test of hypothesis of # H0: rho = 0 under bivariate normality. # Input: x and y (two samples), alternative hypothesis # return: r, sxy, s2x, s2y, t and p.value # alternative: "two.sided", "less" or "greater # method="pearson", ""spearman" or "kendall" # dependence: library(Kendall), for Kendall's tau library(Kendall) cor_test <- function(x, y, alternative="two.sided", method="pearson") { if (length(x) != length(y)) stop("Sample sizes must be equal!") n <- length(x) if (n <= 2) stop("n must be greater than 2!") xb <- mean(x) yb <- mean(y) sxy <- sum((x - xb) * (y - yb)) / (n - 1) s2x <- sum((x - xb)^2) / (n - 1) s2y <- sum((y - yb)^2) / (n - 1) if (method=="pearson") r <- sxy / (s2x * s2y)^0.5 else if (method=="spearman") r <- cor(x, y, method = "spearman") else if (method=="kendall") { res <- Kendall(x, y) r <- as.numeric(res$tau) varS <- as.numeric(res$varS) D <- as.numeric(res$D) S <- as.numeric(res$S) v3v4 <- (S / r)^2 if (alternative=="two.sided") { zc <- (abs(S) - 1) / sqrt(varS) p.value <- 2 * (1 - pnorm(abs(zc))) } else if (alternative=="less") { zc <- (S + 1) / sqrt(varS) p.value <- pnorm(zc) } else if (alternative=="greater") { zc <- (S - 1) / sqrt(varS) p.value <- 1 - pnorm(zc) } return(list(r=r, zc=zc, p.value=p.value, S=S, vars=varS, D=D, alternative=alternative, method=method)) } if ((method=="pearson") | (method=="spearman")) { tc <- r * sqrt(n - 2) / sqrt(1 - r * r) if (alternative=="two.sided") p.value <- 2 * (1 - pt(abs(tc), n - 2)) else if (alternative=="less") p.value <- pt(tc, n - 2) else p.value <- 1 - pt(tc, n - 2) return(list(r=r, tc=tc, p.value=p.value, nu = n - 2, s2x=s2x, s2y=s2y, sxy=sxy, alternative=alternative, method=method)) } } # Function to apply the test of hypothesis of # H0: rho = rho0 under any bivariate distribution. # Fisher's test for H0: rho = rho0. # Input: x and y (two samples), rho0, alternative hypothesis # return: r, t and p.value, muz, sigz, rho0 # alternative: "two.sided", "less" or "greater # method="pearson", ""spearman" or "kendall" # dependence: library(Kendall), for Kendall's tau library(Kendall) cor_test_fish <- function(x, y, rho0=0, alternative="two.sided", method="pearson") { if (length(x) != length(y)) stop("Sample sizes must be equal!") n <- length(x) if (n <= 3) stop("n must be greater than 3!") xb <- mean(x) yb <- mean(y) sxy <- sum((x - xb) * (y - yb)) / (n - 1) s2x <- sum((x - xb)^2) / (n - 1) s2y <- sum((y - yb)^2) / (n - 1) if (method=="pearson") { r <- sxy / (s2x * s2y)^0.5 sigz <- sqrt(1 / (n - 3)) } else if (method=="spearman") { r <- cor(x, y, method = "spearman") sigz <- sqrt(1 / (n - 3)) } else if (method=="kendall") { res <- Kendall(x, y) r <- as.numeric(res$tau) varS <- as.numeric(res$varS) D <- as.numeric(res$D) sigz <- sqrt(varS) / D } z <- 0.5 * log((1 + r) / (1- r)) muz <- 0.5 * (log((1 + rho0) / (1- rho0)) + rho0 / (n - 1)) zc <- (z - muz) / sigz if (alternative=="two.sided") p.value <- 2 * (1 - pnorm(abs(zc))) else if (alternative=="less") p.value <- pnorm(zc) else if (alternative=="greater") p.value <- 1 - pnorm(zc) return(list(r=r, zc=zc, p.value=p.value, muz=muz, sigz=sigz, rho0=rho0, alternative=alternative, method=method)) } # Function to obtain the Fisher confidence interval # for the coefficient of correlation rho under any # bivariate distribution. # input: x, y, alpha # output: list of Lower and Upper limits of # the CI, r, alpha # method="pearson", ""spearman" or "kendall" # dependence: library(Kendall), for Kendall's tau library(Kendall) cor_conf_int_fish <- function(x, y, alpha=0.05, method="pearson") { if (length(x) != length(y)) stop("Sample sizes must be equal!") n <- length(x) if (n <= 3) stop("n must be greater than 3!") xb <- mean(x) yb <- mean(y) sxy <- sum((x - xb) * (y - yb)) / (n - 1) s2x <- sum((x - xb)^2) / (n - 1) s2y <- sum((y - yb)^2) / (n - 1) if (method=="pearson") { r <- sxy / (s2x * s2y)^0.5 sigz <- sqrt(1 / (n - 3)) } else if (method=="spearman") { r <- cor(x, y, method = "spearman") sigz <- sqrt(1 / (n - 3)) } else if (method=="kendall") { res <- Kendall(x, y) r <- as.numeric(res$tau) varS <- as.numeric(res$varS) D <- as.numeric(res$D) sigz <- sqrt(varS) / D } z <- 0.5 * log((1 + r) / (1 - r)) za2 <- qnorm(1 - alpha / 2) A <- exp(2 * (z - za2 * sigz)) B <- exp(2 * (z + za2 * sigz)) L <- (A - 1) / (A + 1) U <- (B - 1) / (B + 1) return(list(L=L, U=U, r=r, alpha=alpha, method=method)) } # Function to obtain the Muddapur (1988) confidence interval # for the coefficient of correlation rho under any # bivariate distribution. # input: x, y, alpha # output: list of Lower and Upper limits of the CI, r, alpha # method="pearson", ""spearman" or "kendall" # dependence: library(Kendall), for Kendall's tau library(Kendall) cor_conf_int_mudd <- function(x, y, alpha=0.05, method="pearson") { if (length(x) != length(y)) stop("Sample sizes must be equal!") n <- length(x) if (n <= 2) stop("n must be greater than 2!") xb <- mean(x) yb <- mean(y) sxy <- sum((x - xb) * (y - yb)) / (n - 1) s2x <- sum((x - xb)^2) / (n - 1) s2y <- sum((y - yb)^2) / (n - 1) if (method=="pearson") { r <- sxy / (s2x * s2y)^0.5 } else if (method=="spearman") { r <- cor(x, y, method = "spearman") } else if (method=="kendall") { res <- Kendall(x, y) r <- as.numeric(res$tau) } fa2 <- qf(1 - alpha / 2, n - 2, n - 2) A <- (1 - fa2) * r B <- (1 + fa2) * r C <- 1 - fa2 D <- 1 + fa2 L <- (B + C) / (D + A) U <- (B - C) / (D - A) return(list(L=L, U=U, r=r, alpha=alpha, method=method)) } # Function to obtain the Jeyaratnam (1992) confidence interval # for the coefficient of correlation rho under any # bivariate distribution. # input: x, y, alpha # output: list of Lower and Upper limits of the CI, r, alpha # method="pearson", ""spearman" or "kendall" # dependence: library(Kendall), for Kendall's tau library(Kendall) cor_conf_int_jeyar <- function(x, y, alpha=0.05, method="pearson") { if (length(x) != length(y)) stop("Sample sizes must be equal!") n <- length(x) if (n <= 2) stop("n must be greater than 2!") xb <- mean(x) yb <- mean(y) sxy <- sum((x - xb) * (y - yb)) / (n - 1) s2x <- sum((x - xb)^2) / (n - 1) s2y <- sum((y - yb)^2) / (n - 1) if (method=="pearson") { r <- sxy / (s2x * s2y)^0.5 } else if (method=="spearman") { r <- cor(x, y, method = "spearman") } else if (method=="kendall") { res <- Kendall(x, y) r <- as.numeric(res$tau) } ta2 <- qt(1 - alpha / 2, n - 2) C <- sqrt(ta2^2 / (ta2^2 + n - 2)) L <- (r - C) / (1 - r * C) U <- (r + C) / (1 + r * C) return(list(L=L, U=U, r=r, alpha=alpha, method=method)) } # Function to obtain the Exact confidence interval # for the coefficient of correlation rho under # bivariate normal distribution. # we allow nonparametric correlation for test # but it is not exact # input: x, y, alpha # output: list of Lower and Upper limits of the CI, r, alpha # dependence: package MBESS library(Kendall) library(MBESS) cor_conf_int_exact <- function(x, y, alpha=0.05, method="pearson") { if (length(x) != length(y)) stop("Sample sizes must be equal!") n <- length(x) if (n <= 2) stop("n must be greater than 2!") xb <- mean(x) yb <- mean(y) sxy <- sum((x - xb) * (y - yb)) / (n - 1) s2x <- sum((x - xb)^2) / (n - 1) s2y <- sum((y - yb)^2) / (n - 1) if (method=="pearson") { r <- sxy / (s2x * s2y)^0.5 } else if (method=="spearman") { r <- cor(x, y, method = "spearman") } else if (method=="kendall") { res <- Kendall(x, y) r <- as.numeric(res$tau) } r2 <- r^2 ci <- ci.R2(R2 = r2, N = n, K = 1, conf.level = 1 - alpha, Random.Predictors = TRUE) L <- ci$Lower.Conf.Limit.R2^0.5 U <- ci$Upper.Conf.Limit.R2^0.5 return(list(L=L, U=U, r=r, alpha=alpha, method=method)) } # Function to obtain the Kendall normal confidence # interval for the coefficient of correlation rho # under any bivariate distribution. # input: x, y, alpha # output: list of Lower and Upper limits of # the CI, r, alpha # dependence: library(Kendall), for Kendall's tau library(Kendall) cor_conf_int_kendall <- function(x, y, alpha=0.05) { if (length(x) != length(y)) stop("Sample sizes must be equal!") n <- length(x) if (n <= 2) stop("n must be greater than 2!") res <- Kendall(x, y) r <- as.numeric(res$tau) varS <- as.numeric(res$varS) D <- as.numeric(res$D) sigz <- sqrt(varS) / D za2 <- qnorm(1 - alpha / 2) L <- r - za2 * sigz U <- r + za2 * sigz if (L < 0) L <- 0 if (U > 1) U <- 1 return(list(L=L, U=U, r=r, alpha=alpha)) } # Proposed example from book exercise 13.4.1 x <- c(8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68) y <- c(9.14, 8.14, 8.74, 8.77, 9.26, 8.10, 6.13, 3.10, 9.13, 7.26, 4.74) # Hypotheses's tests alternative <- "two.sided" method <- "kendall" cor_test(x, y, alternative, method) rho0 <- 0.0 cor_test_fish(x, y, rho0, alternative, method) # Confidence intervals alpha <- 0.05 cor_conf_int_fish(x, y, alpha, method) cor_conf_int_mudd(x, y, alpha, method) cor_conf_int_jeyar(x, y, alpha, method) cor_conf_int_exact(x, y, alpha, method) cor_conf_int_kendall(x, y, alpha) # Exact CI (95%) by Python (using a better algorithm): # [0.254184, 0.9208833] # More examples # Solved example from book (13.6) x <- c(200, 160, 145, 250, 230, 160, 160, 160, 160, 130, 90, 90) y <- c(23, 21, 16, 25, 27, 21, 16, 29, 17, 21, 9, 16) # Solved example from book (13.7) x <- c(150, 115, 140, 155, 75, 100, 150, 125, 100, 100, 130, 120, 125, 110, 80) y <- c(21, 13, 15, 13, 7, 13, 13, 17, 13, 7, 14, 15, 20, 14, 10) # Solved example from book (13.8) x <- c(0.502, 0.548, 0.588, 0.590, 0.592, 0.594, 0.602, 0.604, 0.606, 0.625, 0.626, 0.636, 0.641) y <- c(0.501, 0.538, 0.590, 0.616, 0.601, 0.622, 0.619, 0.620, 0.579, 0.664, 0.606, 0.620, 0.652) -
-
13.2.2 The ranks of \(X\) and \(Y\) are presented below:
Sample \(R_i\) \(S_i\) 1 7 10 2 4 6 3 6 7 4 9 8 5 8 11 6 10 5 7 5 3 8 1 1 9 11 9 10 2 4 11 3 2 The variances of the ranks of \(X\) and \(Y\) and the covariance between the ranks of \(X\) and \(Y\) are given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} S^2_X =& 11, &&& S^2_Y =& 11 &\textrm { and } && S_{XY}=& 7.9. \end{align*}
The point estimate of the Spearman sample correlation coefficient is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} r=& \dfrac {7.9}{\sqrt {11\times 11}}=0.7181818. \end{align*}
For the Kendall tau correlation coefficient we have
\(\seteqnumber{0}{13.}{0}\)\begin{align*} S =& 31, &&& V(S)=& 165, & \nu _0=&2970, & \nu _f=\nu _g=\nu _1=\nu _2=&0 & \textrm { and }&& \nu _3=\nu _4=& 55. \end{align*}
The Kendall tau sample correlation coefficient is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \hat {\tau } =& \dfrac {31}{\sqrt {55 \times 55}}=0.5636364. \end{align*}
The hypothesis of interest to be tested is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} H_0: \rho =& 0 \end{align*} against the alternative
\(\seteqnumber{0}{13.}{0}\)\begin{align*} H_1: \rho \ne & 0. \end{align*}
The three tests presented in the section are:
-
i) “Exact” test using Spearman:
The test statistic is:
\(\seteqnumber{0}{13.}{0}\)\begin{align*} t_c =& \dfrac {r\sqrt {n-2}}{\sqrt {1-r^2}}= \dfrac {0.7181818\sqrt {11-2}}{\sqrt {1-0.7181818^2}}\\ =& 3.096254. \end{align*} Since under \(H_0\) the value of this statistic is a random value of the Student’s \(t\) distribution with \(\nu \) \(=\) \(11-2\) \(=\) \(9\) degrees of freedom, under bivariate normality and \(\rho \) \(=\) \(0\), we have an associated \(p\)-value of \(0.0127996\). Since the \(p\)-value is less than the nominal significance level adopted of \(5\%\), we reject the null hypothesis of zero correlation between the two variables. Therefore, the two methods are correlated in the determination of a given mineral of interest.
-
ii) Approximate Fisher test for \(\rho =0\), using the Spearman correlation
The estimated correlation is the same, \(r=0.7181818\), the standard deviation is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \sigma _z =& \dfrac {1}{\sqrt {n - 3}}=0.3535534. \end{align*}
The transformation led to the quantity \(z\) \(=\) \(0.9038799\), whose mean under \(H_0: \rho =0\) was \(\mu _z\) \(=\) \(0\), as expected. The test statistic was
\(\seteqnumber{0}{13.}{0}\)\begin{align*} Z_c =& \dfrac {0.9038799-0}{0.3535534}=2.556558, \end{align*} whose associated \(p\)-value is \(0.01057133\), which leads us to reject \(H_0\), considering the nominal significance level of \(5\%\). Therefore, the conclusions are the same as the first test.
-
iii) Test using Kendall’s tau
The \(V(S)\) is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} V(S) =& \dfrac {\nu _0-\nu _f-\nu _g}{18} + \dfrac {\nu _1}{2n(n-1)}+\dfrac {\nu _2}{ 9n(n-1)(n-2)}\\ =& \dfrac {2970-0-0}{18}+\dfrac {0}{220}+\dfrac {0}{8910}\\ =& 165. \end{align*}
Thus, the test statistic with continuity correction is:
\(\seteqnumber{0}{13.}{0}\)\begin{align*} Z_c =& \dfrac {|31|-1}{\sqrt {165}}=2.335497, \end{align*} whose associated \(p\)-value is \(0.01951748\), leading to rejection of the null hypothesis, as in the previous cases.
To measure the magnitude of their agreement (effect size), we will proceed with obtaining the confidence intervals presented in this chapter. All methods will be presented and, at the end, the R program used to obtain them.
-
i) Fisher interval
Since the quantile of the standard normal distribution is \(Z_{0.025}\) \(=\) \(1.96\), the auxiliary quantities for obtaining the confidence interval are
\(\seteqnumber{0}{13.}{0}\)\begin{align*} A=& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+R}{1-R} \right ) - \dfrac {Z_{\alpha /2}}{\sqrt {n-3}}\right ]\right \}\\ =& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+ 0.7181818}{1-0.7181818} \right ) - \dfrac {1.96}{\sqrt {11-3}}\right ]\right \}\\ =& 1.524789 \end{align*} and
\(\seteqnumber{0}{13.}{0}\)\begin{align*} B =& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+R}{1-R} \right ) + \dfrac {Z_{\alpha /2}}{\sqrt {n-3}}\right ]\right \} \\ =& \exp \left \{2 \left [\dfrac {1}{2}\ln \left (\dfrac {1+0.7181818}{1-0.7181818} \right ) + \dfrac {1.96}{\sqrt {11-3}}\right ]\right \}\\ =& 24.37757. \end{align*}
Thus,
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{95\%}(\rho ):&\,\,\left [\dfrac {A-1}{A+1},\,\, \dfrac {B-1}{B+1}\right ] = \left [\dfrac {1.524789-1}{1.524789+1},\,\, \dfrac {24.37757-1}{24.37757+1}\right ]\\ &\,\, =[0.2078546,\,\, 0.9211903]. \end{align*}
-
The Muddapur interval depends on the upper \(2.5\%\) quantile of the \(F\) distribution with \(\nu _1\) \(=\) \(\nu _2\) \(=\) \(\nu \) \(=\) \(n - 2\) \(=\) \(9\) degrees of freedom. This quantile is \(F_{0.025;\nu _1=9,\nu _2=9}\) \(=\) \(4.025994\). The interval is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} &CI_{0.95}(\rho ):\,\, \left [\dfrac {\left (1+F_{0.025}\right )R + \left (1 - F_{0.025}\right )}{\left (1+F_{0.025}\right ) + \left (1 - F_{0.025}\right )R},\,\, \dfrac {\left (1+F_{0.025}\right )R - \left (1 - F_{0.025}\right )}{\left (1+F_{0.025}\right ) - \left (1 - F_{0.025}\right )R}\right ] \\ & = \left [\dfrac {\left (1+4.025994\right )0.7181818 + \left (1 - 4.025994\right )}{\left (1+4.025994\right ) + \left (1 - 4.025994\right )0.7181818},\,\, \dfrac {\left (1+4.025994\right )0.7181818 -4.025994 \left (1 - 4.025994\right )}{\left (1+4.025994\right ) - \left (1 - 4.025994\right ) 0.7181818}\right ]\\ &= [0.2045666,\,\,0.9217086]. \end{align*}
-
iii) Jeyaratnam (1992)
The upper quantile of the Student’s \(t\) distribution to determine this interval with \(\nu \) \(=\) \(n - 2\) \(=\) \(9\) degrees of freedom is \(t_{0.025;\nu =9}\) \(=\) \(2.262157\). The value of the auxiliary quantity \(C\) is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} C =& \sqrt {\dfrac {t_{0.025;\nu =9}^2}{t_{0.025;\nu =9}^2+9}} = \sqrt {\dfrac {2.262157^2}{2.262157^2+11}} =0.6020688. \end{align*}
Thus, the confidence interval is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{0.95}(\rho ):&\,\, \left [\dfrac {R - C}{1-RC},\,\, \dfrac {R+C}{1+R C}\right ]\\ &\,\,= \left [\dfrac {0.7181818 - 0.5529435}{1-0.7181818\times 0.6020688},\,\, \dfrac {0.7181818+0.6020688}{1+0.7181818 \times 0.6020688}\right ]\\ &\,\, =[0.2045666,\,\,0.9217086]. \end{align*}
-
iv) Exact interval for \(\rho ^2\)
The alternative commented previously was applied. Given the calculated value of \(r^2\) \(=\) \(0.7181818^2\) \(=\) \(0.5157851\), the distribution function was numerically inverted with respect to the non-centrality parameter \(\rho ^2\). The interval obtained the previous R program was
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{0.95}(\rho ):&\,\, [0.1852099,\, 0.9083687]. \end{align*}
This result is used for comparison purposes with the other intervals.
In all cases, it can be concluded with \(95\%\) confidence that there is a reasonable positive linear correlation between the two methods and that its real value should be between \(0.20\) and \(0.92\). All methods showed great agreement among themselves. If the small sample size of \(n = 11\) is considered, this result is surprising, as in the first exercise. Regarding Pearson correlation, the confidence intervals led to a small difference in the lower limit, but agreed considerably regarding the upper limit of the interval. The tests in terms of the final result, previous and this exercise, also agreed in rejecting the null hypothesis of absence of linear correlation.
For the particular case of Kendall’s tau, we will present the two main intervals presented in the chapter. The first, based on the normal approximation, is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{0.95}(\rho ):&\,\, \hat {\tau }\pm Z_{\alpha /2}\sqrt {V(\hat {\tau })}\\ &\,\, 0.5636364\pm 1.96\times \sqrt {\dfrac {V(S)}{\nu _3\nu _4}}=0.5636364\pm 1.96\times \sqrt {\dfrac {165}{55 \times 55}} &\,\, [0.1058874,\, 1]. \end{align*}
This interval is very imprecise and should be avoided. The second, using Fisher’s approximation, resulted in
\(\seteqnumber{0}{13.}{0}\)\begin{align*} CI_{0.95}(\rho ):&\,\, [0.178466,\, 0.7990199], \end{align*} which was quite different from the intervals based on Fisher or Spearman.
-
-
13.2.3 The null hypothesis is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} H_0:&\, \rho _1 = \rho _2 = \rho _3 =\rho _4=\rho . \end{align*}
Initially, Fisher’s transformation was applied and the results are presented below.
Soils \(n_i\) \(R_i\) \(Z_i\) \((n_i-3)Z_i\) 1 120 -0.63 -0.7414 -86.74569 2 120 -0.65 -0.7753 -90.70995 3 120 -0.83 -1.1881 -139.01196 4 120 -0.87 -1.3331 -155.97032 Total 480 \(-\) \(-\) -472.4379 Thus,
\(\seteqnumber{0}{13.}{0}\)\begin{align*} Z_p =& \dfrac {-472.4379}{468}=-1.009483. \end{align*}
For the calculation of the chi-square statistic value, some necessary quantities are presented below.
Soils \(n_i-3\) \((n_i-3)(Z_i-Z_p)^2\) 1 117 8.407584 2 117 6.416532 3 117 3.734305 4 117 12.251650 Total 468 30.81007 Thus, the value of the chi-square statistic is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& \sum _{i=1}^{k} (n_i-3)\left (Z_i-Z_p\right )^2=30.81007. \end{align*}
Since the value \(\chi ^2_c\) \(=\) \(30.81007\) is greater than the tabulated value for \(\alpha \) \(=\) \(5\%\), with \(3\) degrees of freedom, of \(7.814\), the null hypothesis of homogeneity of the correlation coefficients must be rejected at the nominal level of \(5\%\) significance.
To illustrate the obtaining of the bias-corrected test, we have
\(\seteqnumber{0}{13.}{0}\)\begin{align*} R_p =& \dfrac {e^{2Z_p}-1}{e^{2Z_p}+1} = \dfrac {e^{2\times (-1.009483)}-1}{e^{2\times (-1.009483)}+1}=-0.765548. \end{align*}
Then, the value of the chi-square statistic is obtained by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_p =& \sum _{i=1}^{k} \dfrac {n_i\left (R_i-R_p\right )^2}{\left (1-R_iR_p\right )^2}\\ =& \dfrac {120\times (-0.63+0.765548)^2}{(1-0.63\times 0.765548)^2}+ \dfrac {120\times (-0.65+0.765548)^2}{(1-0.65\times 0.765548)^2}\\ & +\dfrac {120\times (-0.83+0.765548)^2}{(1-0.83\times 0.765548)^2} + \dfrac {120\times (-0.87+0.765548)^2}{(1-0.87\times 0.765548)^2}\\ =& 30.06193. \end{align*}
Since the value \(\chi ^2_p\) \(=\) \(30.06193\) is greater than the tabulated value with \(3\) degrees of freedom of \(7.814\), the null hypothesis of homogeneity of the correlation coefficients should not be rejected at the nominal level of \(5\%\) significance. The value of the corrected chi-square statistic is very close to the uncorrected value in this example.
Since there is at least one difference between the correlation coefficients of the 4 soils, the natural interest is to perform the multiple comparison test to identify these differences.
One can opt for the choice of an average precision for all comparisons using the harmonic mean of the sample sizes or for the specific precision of each pair of comparisons. In this case, it makes no difference because the sample sizes are equal in the \(4\) soils. The general expression for obtaining each lsd, which in this case results in the same value, is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \Delta _{ii'} =& q_{\alpha ;k,\infty }\sqrt {\dfrac {1}{2} \left (\dfrac {1}{n_i-3}+ \dfrac {1}{n_{i'}-3}\right )},\quad i\ne i'=1,\,2,\,3,\,4. \end{align*}
For the comparison of any pair of soils we have
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \Delta =& 3.63316\times \sqrt {\dfrac {1}{2}\left (\dfrac {1}{120-3}+ \dfrac {1}{120-3}\right )}=0.3358857. \end{align*}
Thus, since \(|Z_1 - Z_2|\) \(=\) \(0.0339\) is less than the lsd \(\Delta _{12}\) \(=\) \(0.336\), it implies that \(\rho _1\) does not differ from \(\rho _2\). Since \(|Z_1 - Z_3|\) \(=\) \(0.4467\) is greater than the lsd value (\(0.336\)), then \(\rho _1\) \(<\) \(\rho _3\) in absolute value. If we continue with this process, we will have the results for all possible pairs. A summary of the tests can be presented as in the following Table using letters. Two coefficients do not differ significantly from each other if they have the same letter.
Environment \(R_i\) \(Z_i\) Results 4 -0.87 -0.7414 a 3 -0.83 -0.7753 a 2 -0.65 -1.1881 b 1 -0.63 -1.3331 b lsd (\(\Delta \)) 0.341 The R programs for performing the tests are presented in the sequence.
# function to apply the chi-squared test # for H0: rho1=rho2=...=rhok=rho # ris = c(rh1, rh2,...,rhk) # nis = c9n1, n2,..., nk) cor_global_test <- function(ris, nis) { if (any(nis <= 3)) stop("All n's must be greater than 3!") zis <- 0.5 * log((1 + ris) / (1 - ris)) zp <- sum((nis - 3) * zis) / sum(nis - 3) Chi2c <- sum((nis - 3) * (zis - zp)^2) nu <- length(ris) - 1 p.value <- 1 - pchisq(Chi2c, nu) return(list(Chi2c=Chi2c, p.value=p.value)) } # function to apply the chi-squared # Paul's test for # H0: rho1=rho2=...=rhok=rho # ris = c(rh1, rh2,...,rhk) # nis = c9n1, n2,..., nk) cor_paul_global_test <- function(ris, nis) { if (any(nis <= 3)) stop("All n's must be greater than 3!") zis <- 0.5 * log((1 + ris) / (1 - ris)) zp <- sum((nis - 3) * zis) / sum((nis - 3)) Rp <- (exp(2 * zp) - 1) / (exp(2 * zp) + 1) Chi2c <- sum((nis * (ris - Rp)^2) / (1 - ris * Rp)^2) nu <- length(ris) - 1 p.value <- 1 - pchisq(Chi2c, nu) return(list(Chi2c=Chi2c, p.value=p.value, rp=Rp)) } # function to apply the Paul's confidence # interval for the common rho # ris = c(rh1, rh2,...,rhk) # nis = c9n1, n2,..., nk) cor_paul_global_ci <- function(ris, nis, alpha=0.05) { if (any(nis <= 3)) stop("All n's must be greater than 3!") zis <- 0.5 * log((1 + ris) / (1 - ris)) zp <- sum((nis - 3) * zis) / sum(nis - 3) Rp <- (exp(2 * zp) - 1) / (exp(2 * zp) + 1) if (Rp < 0.5) { zisc <- zis - (3 * zis + ris) / (4 * (nis - 1)) zp <- sum((nis - 3) * zisc) / sum((nis - 3)) Rp <- (exp(2 * zp) - 1) / (exp(2 * zp) + 1) } z <- 0.5 * log((1 + Rp) / (1 - Rp)) sigz <- 1 / sqrt(sum(nis - 3)) za2 <- qnorm(1 - alpha / 2) A <- exp(2 * (z - za2 * sigz)) B <- exp(2 * (z + za2 * sigz)) L <- (A - 1) / (A + 1) U <- (B - 1) / (B + 1) return(list(L=L, U=U, rp=Rp, alpha=alpha)) } # Test Neyman (1959) para H0: rho_global = 0 cor_neyman_global_test <- function(ris, nis) { if (any(nis <= 3)) stop("All n's must be greater than 3!") zis <- 0.5 * log((1 + ris) / (1 - ris)) zp <- sum((nis - 3) * zis) / sum((nis - 3)) rp <- (exp(2 * zp) - 1) / (exp(2 * zp) + 1) zc <- sum(nis * zis) / sqrt(sum(nis)) p.value <- 2 * (1 - pnorm(abs(zc))) return(list(rp=rp, zc=zc, p.value=p.value)) } # Fisher's test for H0: rho_global = rho0 # alternative: "two.sided", "less" or "greater cor_test_fish_global <- function(ris, nis, rho0=0, alternative="two.sided") { if (length(ris) != length(nis)) stop("Sample sizes must be equal!") if (any(nis <= 3)) stop("All n's must be greater than 3!") zis <- 0.5 * log((1 + ris) / (1 - ris)) zp <- sum((nis - 3) * zis) / sum((nis - 3)) rp <- (exp(2 * zp) - 1) / (exp(2 * zp) + 1) n <- sum(nis - 3) muz <- 0.5 * (log((1 + rho0) / (1- rho0)) + rho0 / (n - 1)) sigz <- 1 / sqrt(n) zc <- (zp - muz) / sigz if (alternative=="two.sided") p.value <- 2 * (1 - pnorm(abs(zc))) else if (alternative=="less") p.value <- pnorm(zc) else if (alternative=="greater") p.value <- 1 - pnorm(zc) return(list(rp=rp, zc=zc, p.value=p.value, muz=muz, sigz=sigz, rho0=rho0, alternative=alternative)) } # Multiple Comparisons of k coefficient of correlation # usinf Fisher's normal aproximation H0: rho_i = rho_k cor_multcompar_test_fish <- function(ris, nis, alpha=0.05) { if (length(ris) != length(nis)) stop("Sample sizes must be equal!") if (any(nis <= 3)) stop("All n's must be greater than 3!") zis <- 0.5 * log((1 + ris) / (1 - ris)) k <- length(ris) qa <- qtukey(1 - alpha, k, Inf) m <- k * (k - 1) / 2 res <- data.frame( Contrasts = character(), estimates = numeric(), Deltaik = numeric(), Meaning = character(), stringsAsFactors = FALSE ) sqrtnis <- sqrt(nis) for (i in 1:(k - 1)) for (k in (i + 1):k) { cont <- paste0("Corr. ", i, " vs ", k) est <- zis[i] - zis[k] Delta <- qa * sqrt(0.5 * (1 / (nis[i] - 3) + 1 / (nis[k] -3))) if ((abs(est) >= Delta) & est > 0) { if (ris[i] < 0) Meaning <- "i is smaller than k" else Meaning <- "i is greater than k" } else if ((abs(est) >= Delta) & est < 0) { if (ris[i] > 0) Meaning <- "i is smaller than k" else Meaning <- "i is greater than k" } else Meaning = "i is equal k" res[nrow(res) + 1, ] <- list(cont, est, Delta, Meaning) } return(list(res=res, obs1="If |estimates| >= Deltaik, rhoi difers rhok", obs2="Comparison for absolute values")) } # Solved example 13.4 from book # nis <- c(80, 65, 70) # ris <- c(0.72, 0.68, 0.74) # Solved example 13.5 from book # nis <- c(100, 120, 80) # ris <- c(0.76, 0.57, 0.78) # Proposed example from book exercise 13.4.3 nis <- c(120, 120, 120, 120) ris <- c(-0.63, -0.65, -0.83, -0.87) alpha <- 0.05 alternative="two.sided" rho0=0.0 cor_global_test(ris, nis) cor_paul_global_test(ris, nis) cor_paul_global_ci(ris, nis, alpha) cor_neyman_global_test(ris, nis) cor_test_fish_global(ris, nis, rho0, alternative) cor_multcompar_test_fish(ris, nis, alpha=0.05) -
13.2.4 The null hypotheses of independence and alternative are formally presented by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \left \{ \begin{array}{ll} H_0:\,\, \pi _{ij}=\pi _{i.}\pi _{.j} & \forall i=1,2,\,\cdots ,\, r,\,\,j=1,2,\,\cdots ,\,c \\ H_1:\,\, \pi _{ij}\ne \pi _{i.}\pi _{.j} & \textrm { for some pair } i,\,j. \end {array} \right . \end{align*}
We can apply the three tests presented in the Book for each of the contingency tables. We will present simultaneously each test for each of the two markers. In the sequence we have each of the tests:
-
a) Conventional \(\chi ^2\) test:
-
i) Marker A08,1:
The contingency table with the observed and expected frequencies and the marginal totals is presented below:
Observed (expected) frequencies Marker A08,1 Reaction to disease 0 1 Total Tolerant 4(4.67) 3(2.33) 7 Non-tolerant 6(5.33) 2(2.67) 8 Total 10 5 15 The conventional chi-square test statistic is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {\left (f_{ij} - e_{ij}\right )^2}{e_{ij}}\\ =&\left [\dfrac {(4-4.67)^2}{4.67}+ \dfrac {(3-2.33)^2}{2.33}+ \dfrac {(6-5.33)^2}{5.33}+\dfrac {(2-2.67)^2}{2.67}\right ]\\ =& 0.5357143. \end{align*}
The associated \(p\)-value, obtained from the chi-square distribution with \(\nu \) \(=\) \((r-1)(c-1)\) \(=\) \(1\), is \(0.4642143\). Since the value is greater than the nominal significance level of \(5\%\), the null hypothesis of absence of linear association (independence) should not be rejected and this marker would not be appropriate for selecting plants tolerant to the disease.
-
ii) Marker C01,1:
The contingency table with the observed and expected frequencies and the marginal totals is presented below:
Observed (expected) frequencies Marker C01,1 Reaction to disease 0 1 Total Tolerant 0(3.26) 7(3.73) 7 Non-tolerant 7(3.73) 1(4.27) 8 Total 7 8 15 The conventional chi-square test statistic is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {\left (f_{ij} - e_{ij}\right )^2}{e_{ij}}\\ =&\left [\dfrac {(0-3.26)^2}{3.26}+ \dfrac {(7-3.73)^2}{3.73}+ \dfrac {(7-3.73)^2}{3.73}+\dfrac {(1-4.27)^2}{4.27}\right ]\\ =& 11.48438. \end{align*}
The associated \(p\)-value, obtained from the chi-square distribution with \(\nu \) \(=\) \((r-1)(c-1)\) \(=\) \(1\), is \(0.0007018372\). Since the value is less than the nominal significance level of \(5\%\), the null hypothesis of absence of linear association (independence) must be rejected and this marker is appropriate for selecting plants tolerant to the disease. Plants presenting the value \(1\) of the marker should have priority in selection, because they would be associated with plants tolerant to the disease.
-
-
b) \(\chi ^2\) test with bias correction:
Since the table of this example is \(2 \times 2\), we can apply the test with bias correction. The statistic of this test is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& \sum _{i=1}^{2}\sum _{j=1}^{2} \dfrac {\left [\max \left (0, \left |f_{ij} - e_{ij}\right |-0.5\right )\right ]^2}{e_{ij}} \end{align*}
The contingency table with the observed and expected frequencies and the marginal totals are exactly the same as in the previous item, only the way of calculating the statistic changes.
-
i) Marker A08,1:
The chi-square test statistic with continuity correction is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& \left [\dfrac {(|4-4.67|-0.5)^2}{4.67}+ \dfrac {(|3-2.33|-0.5)^2}{2.33}+ \dfrac {(|6-5.33|-0.5)^2}{5.33}+\dfrac {(|2-2.67|-0.5)^2}{2.67}\right ]\\ =& 0.03348214. \end{align*}
The associated \(p\)-value, obtained from the chi-square distribution with \(\nu \) \(=\) \((r-1)(c-1)\) \(=\) \(1\), is \(0.8548127\). Since the value is greater than the nominal significance level of \(5\%\), the null hypothesis of absence of linear association (independence) should not be rejected and this marker would not be appropriate for selecting plants tolerant to the disease.
-
ii) Marker C01,1:
The chi-square test statistic is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& \left [\dfrac {(|0-3.26|-0.5)^2}{3.26}+ \dfrac {(|7-3.73|-0.5)^2}{3.73}+ \dfrac {(|7-3.73|-0.5)^2}{3.73}+\dfrac {(|1-4.27|-0.5)^2}{4.27}\right ]\\ =& 8.237803. \end{align*}
The associated \(p\)-value, obtained from the chi-square distribution with \(\nu \) \(=\) \((r-1)(c-1)\) \(=\) \(1\), is \(0.004102676\). Since the value is less than the nominal significance level of \(5\%\), the null hypothesis of absence of linear association (independence) must be rejected and this marker is appropriate for selecting plants tolerant to the disease.
-
-
c) LRT test:
Since the table of this example is \(2 \times 2\), we can apply the LRT, whose statistic is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& 2\sum _{i=1}^{r}\sum _{j=1}^{c} f_{ij}\ln \left (\dfrac {f_{ij}}{e_{ij}}\right ) \end{align*}
The contingency table with the observed and expected frequencies and the marginal totals are exactly the same as in the previous item, only the way of calculating the statistic changes.
-
i) Marker A08,1:
The LRT test statistic is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& 2\left [4.67\ln \left (\dfrac {4}{4.67}\right )+ 2.33\ln \left (\dfrac {3}{2.33}\right ) + 5.33 \ln \left (\dfrac {6}{5.33}\right )+ 2.67\ln \left (\dfrac {2}{2.67}\right )\right ]\\ =& 0.5373493. \end{align*}
The associated \(p\)-value, obtained from the chi-square distribution with \(\nu \) \(=\) \((r-1)(c-1)\) \(=\) \(1\), is \(0.4635334\). Since the value is greater than the nominal significance level of \(5\%\), the null hypothesis of absence of linear association (independence) should not be rejected.
-
ii) Marker C01,1:
The LRT test statistic is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& 2\left [0 + 3.73\ln \left (\dfrac {7}{3.73}\right ) + 3.73\ln \left (\dfrac {7}{3.73}\right ) + 4.27\ln \left (\dfrac {1}{4.27}\right )\right ]\\ =& 14.69938. \end{align*}
The associated \(p\)-value, obtained from the chi-square distribution with \(\nu \) \(=\) \((r-1)(c-1)\) \(=\) \(1\), is \(0.0001260881\). Since the value is less than the nominal significance level of \(5\%\), the null hypothesis of absence of linear association (independence) must be rejected.
In summary, the three tests agree on the decisions that must be made: Marker A08,1 has no correlation with the disease reaction and marker C01,1 has linear association, being considered appropriate for selecting plants tolerant to the disease. Plants presenting the value \(1\) of marker C01,1 should have priority in selection, because they would be associated with plants tolerant to the disease, and plants with genotype \(0\) should not be selected, since they would be associated with non-tolerance to the disease.
-
For the continuity of the procedures, we should present for marker C01,1 the correlation coefficients for contingency tables, so that we can evaluate the magnitude of this dependence.
The uncorrected contingency coefficient is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} P =& \sqrt {\dfrac {\chi ^2_c}{\chi ^2_c+n}}= \sqrt {\dfrac {11.48438}{11.48438+15}}\\ =& 0.6585. \end{align*}
The corrected contingency coefficient, given that \(m\) \(=\) \(\min (r\), \(c)\) \(=\) \(\min (2\), \(2)\) \(=\) \(2\), is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} P_c =& P\sqrt {\dfrac {m}{m-1}}= 0.6585046\times \sqrt {\dfrac {2}{2-1}}\\ =& 0.9213. \end{align*}
Cramér’s coefficient \(\phi _1\) is given by
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \phi _1 =& \dfrac {0 \times 1 - 7\times 7}{\sqrt {7\times 8\times 7\times 8}}\\ =& -0.875. \end{align*}
Finally, Cramér’s coefficient \(\phi _2\) is
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \phi _2 =& \sqrt {\dfrac {\chi ^2_c/n}{\min (r-1,\,c-1)}} = \sqrt {\dfrac {11.48438/15}{\min (2-1,\,2-1)}}\\ =&0.875, \end{align*} which is equal to \(\phi _1\) for \(2 \times 2\) contingency tables (except for the sign), since none of the conditions was violated.
Therefore, the intensity of the correlation between the marker genotypes and disease tolerance is moderately high and significantly different from zero. It should be emphasized that the two Cramér correlation coefficients are identical except for a sign, since the value \(\min (r-1\), \(c-1)\) is equal to \(1\). This means that values \(1\) of the marker are generally associated with disease tolerance and therefore it can be used for indirect selection without the need for an inoculation field.
The R program with the examples to obtain the results of this chapter or perform new analyses is presented below.
# Function to apply the independence chi-squared test # for frequency tables of r x c (r rows and c columns) chi_squared_table <- function(tb) { r <- length(unique(tb[, 1])) c <- length(unique(tb[, 2])) n <- sum(tb[, 3]) # 1. Create the contingency table using # the columns positions tab <- xtabs(tb[, 3] ~ tb[, 1] + tb[, 2]) # 2. Add marginals sum to row and columns tab_fobs <- addmargins(tab) chi2_c <- 0 nu <- (r - 1) * (c - 1) for (i in 1:r) for (k in 1:c) { feik <- tab_fobs[i, c + 1] * tab_fobs[r + 1, k] / n chi2_c <- chi2_c + (tab_fobs[i, k] - feik)**2 / feik } p.value <- 1 - pchisq(chi2_c, nu) return(list(chi2_c=chi2_c, nu=nu, p.value=p.value)) } # Function to apply the independence chi-squared test # for frequency tables of 2 x 2 (2 rows and 2 columns) # with correction of continuity chi_squared_cont_table <- function(tb) { r <- length(unique(tb[, 1])) c <- length(unique(tb[, 2])) if ((r != 2) | (c != 2)) { warning("Number of rows or columns must be only 2!") return(NaN) } n <- sum(tb[, 3]) # 1. Create the contingency table using # the columns positions tab <- xtabs(tb[, 3] ~ tb[, 1] + tb[, 2]) # 2. Add marginals sum to row and columns tab_fobs <- addmargins(tab) chi2_c <- 0 nu <- (r - 1) * (c - 1) for (i in 1:r) for (k in 1:c) { feik <- tab_fobs[i, c + 1] * tab_fobs[r + 1, k] / n num <- max(0, abs(tab_fobs[i, k] - feik) - 0.5) chi2_c <- chi2_c + num**2 / feik } p.value <- 1 - pchisq(chi2_c, nu) return(list(chi2_c=chi2_c, nu=nu, p.value=p.value)) } # Function to apply the LRT chi-squared test # for frequency tables of r x c (r rows and c columns) chi_squared_lrt_table <- function(tb) { r <- length(unique(tb[, 1])) c <- length(unique(tb[, 2])) n <- sum(tb[, 3]) # 1. Create the contingency table using the column # positions tab <- xtabs(tb[, 3] ~ tb[, 1] + tb[, 2]) # 2. Add marginal sums to rows and columns tab_fobs <- addmargins(tab) chi2_c <- 0 nu <- (r - 1) * (c - 1) for (i in 1:r) for (k in 1:c) { feik <- tab_fobs[i, c + 1] * tab_fobs[r + 1, k] / n if (tab_fobs[i, k] == 0) term <- 0 else term <- tab_fobs[i, k] * log(tab_fobs[i, k] / feik) chi2_c <- chi2_c + term } chi2_c <- 2 * chi2_c p.value <- 1 - pchisq(chi2_c, nu) return(list(chi2_c=chi2_c, nu=nu, p.value=p.value)) } # Function to compute the contingence coefficient P # Cramér coefficients phi1 and phi2 # for frequency tables of r x c (r rows and c columns) correlations_for_contingence_tables <- function(tb) { r <- length(unique(tb[, 1])) c <- length(unique(tb[, 2])) n <- sum(tb[, 3]) # Lock the exact order of appearance in the # data frame (prevents alphabetical sorting) col1_ord <- factor(tb[, 1], levels = unique(tb[, 1])) col2_ord <- factor(tb[, 2], levels = unique(tb[, 2])) # 1. Create the contingency table using the column # positions (preserving original order) tab <- xtabs(tb[, 3] ~ col1_ord + col2_ord) names(dimnames(tab)) <- names(tb)[1:2] # 2. Add marginal sums to rows and columns tab_fobs <- addmargins(tab) chi2_c <- 0 nu <- (r - 1) * (c - 1) for (i in 1:r) for (k in 1:c) { feik <- tab_fobs[i, c + 1] * tab_fobs[r + 1, k] / n chi2_c <- chi2_c + (tab_fobs[i, k] - feik)**2 / feik } P <- sqrt(chi2_c / (chi2_c +n)) m <- min(r, c) Pc <- P * sqrt(m / (m - 1)) if ((r == 2) & (c == 2)) { num <- tab_fobs[1, 1] * tab_fobs[2, 2] - tab_fobs[1, 2] * tab_fobs[2, 1] den <- tab_fobs[1, 3] * tab_fobs[2, 3] * tab_fobs[3, 1] * tab_fobs[3, 2] phi1 <- num / sqrt(den) } else phi1 <- sqrt(chi2_c / n) phi2 <- sqrt(chi2_c / n / (m - 1)) return(list(P=P, Pc=Pc, phi1=phi1, phi2=phi2, r=r, c=c)) } # Proposed example from book exercise 13.4.4 (table 1) tb1 <- data.frame( reaction = c("tolerante", "tolerante", "não tolerante", "não tolerante"), primerA08 = c(0, 1, 0, 1), frequencia = c(4,3,6,2), stringsAsFactors = FALSE ) chi_squared_table(tb1) chi_squared_cont_table(tb1) chi_squared_lrt_table(tb1) correlations_for_contingence_tables(tb1) # Proposed example from book exercise 13.4.4 (table 2) tb2 <- data.frame( reaction = c("tolerante", "tolerante", "não tolerante", "não tolerante"), primerC01 = c(0, 1, 0, 1), frequencia = c(0,7,7,1), stringsAsFactors = FALSE ) chi_squared_table(tb2) chi_squared_cont_table(tb2) chi_squared_lrt_table(tb2) correlations_for_contingence_tables(tb2) # Solved example 13.9 from book tb3 <- data.frame( enraizamento = c("positivo", "positivo", "positivo", "negativo", "negativo", "negativo"), hormonio = c("BAP", "TDZ", "Sem hormonio", "BAP", "TDZ", "Sem hormonio"), frequencia = c(60,55, 5, 10, 15, 65), stringsAsFactors = FALSE ) chi_squared_table(tb3) chi_squared_cont_table(tb3) chi_squared_lrt_table(tb3) correlations_for_contingence_tables(tb3) -
-
13.2.5 We have that
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c =& \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {\left (f_{ij} - e_{ij}\right )^2}{e_{ij}}, \end{align*} and if \(m\) \(=\) \(\min (r\), \(c)\), it is verified that the value of \(P\) is a measure in the interval \([0\), \(\sqrt {(m-1)/m}]\), being
\(\seteqnumber{0}{13.}{0}\)\begin{align*} P =& \sqrt {\dfrac {\chi ^2_c}{\chi ^2_c+n}}. \end{align*}
To verify this statement, we must initially show that the chi-square statistic is bounded by the interval
\[ 0 \le \chi ^2_c \le n(m - 1), \]
where \(n = \sum _{i=1}^{r}\sum _{j=1}^{c} f_{ij}\) is the overall total of observations, \(f_{i\cdot } = \sum _{j=1}^{c} f_{ij}\) are the marginal totals of the rows, \(f_{\cdot j} = \sum _{i=1}^{r} f_{ij}\) are the marginal totals of the columns and \(e_{ij} = \dfrac {f_{i\cdot } f_{\cdot j}}{n}\) are the expected frequencies under independence (assuming there are no null rows or columns, that is, \(f_{i\cdot } > 0\) and \(f_{\cdot j} > 0\)).
1. Lower bound of \(\chi ^2_c\) Since \((f_{ij} - e_{ij})^2 \ge 0\) and \(e_{ij} > 0\) for all \(i \in \{1, \dots , r\}\) and \(j \in \{1, \dots , c\}\), each term of the summation is non-negative. Therefore,
\[ \chi ^2_c \ge 0, \]
with equality if and only if \(f_{ij} = e_{ij}\) for all cells (perfect independence).
2. Upper bound of \(\chi ^2_c\) Expanding the numerator of the expression of \(\chi ^2_c\), we obtain:
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c &= \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2 - 2f_{ij}e_{ij} + e_{ij}^2}{e_{ij}} \\ &= \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{e_{ij}} - 2\sum _{i=1}^{r}\sum _{j=1}^{c} f_{ij} + \sum _{i=1}^{r}\sum _{j=1}^{c} e_{ij}. \end{align*} Since \(\sum _{i=1}^{r}\sum _{j=1}^{c} f_{ij} = n\) and the sum of the expected frequencies is also equal to \(n\):
\[ \sum _{i=1}^{r}\sum _{j=1}^{c} e_{ij} = \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{i\cdot } f_{\cdot j}}{n} = \dfrac {1}{n}\left (\sum _{i=1}^{r} f_{i\cdot }\right )\left (\sum _{j=1}^{c} f_{\cdot j}\right ) = \dfrac {n \cdot n}{n} = n, \]
the expression of \(\chi ^2_c\) reduces to:
\(\seteqnumber{0}{13.}{0}\)\begin{align*} \chi ^2_c &= \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{e_{ij}} - 2n + n = \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{e_{ij}} - n \\ &= n \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{f_{i\cdot } f_{\cdot j}} - n = n \left ( \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{f_{i\cdot } f_{\cdot j}} - 1 \right ). \end{align*}
Since \(f_{ij} \ge 0\), no observed frequency can exceed the marginal total of its column (\(f_{ij} \le f_{\cdot j} \implies \dfrac {f_{ij}}{f_{\cdot j}} \le 1\)) nor the marginal total of its row (\(f_{ij} \le f_{i\cdot } \implies \dfrac {f_{ij}}{f_{i\cdot }} \le 1\)). Applying each of these bounds to the double summation:
-
• Bounding by the columns \(\left (\dfrac {f_{ij}}{f_{\cdot j}} \le 1\right )\):
\[ \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{f_{i\cdot } f_{\cdot j}} = \sum _{i=1}^{r} \dfrac {1}{f_{i\cdot }} \sum _{j=1}^{c} f_{ij} \left (\dfrac {f_{ij}}{f_{\cdot j}}\right ) \le \sum _{i=1}^{r} \dfrac {1}{f_{i\cdot }} \sum _{j=1}^{c} f_{ij} = \sum _{i=1}^{r} \dfrac {f_{i\cdot }}{f_{i\cdot }} = r. \]
-
• Bounding by the rows \(\left (\dfrac {f_{ij}}{f_{i\cdot }} \le 1\right )\):
\[ \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{f_{i\cdot } f_{\cdot j}} = \sum _{j=1}^{c} \dfrac {1}{f_{\cdot j}} \sum _{i=1}^{r} f_{ij} \left (\dfrac {f_{ij}}{f_{i\cdot }}\right ) \le \sum _{j=1}^{c} \dfrac {1}{f_{\cdot j}} \sum _{i=1}^{r} f_{ij} = \sum _{j=1}^{c} \dfrac {f_{\cdot j}}{f_{\cdot j}} = c. \]
Since the double summation is simultaneously less than or equal to \(r\) and to \(c\), it is bounded by the smaller of the two, that is, \(m = \min (r, c)\):
\[ \sum _{i=1}^{r}\sum _{j=1}^{c} \dfrac {f_{ij}^2}{f_{i\cdot } f_{\cdot j}} \le \min (r, c) = m. \]
Substituting this inequality into the expression of \(\chi ^2_c\), we conclude that:
\[ \chi ^2_c \le n(m - 1). \]
3. Interval of the contingency coefficient \(P\) Consider the function \(g(x) = \sqrt {\dfrac {x}{x + n}}\) defined for \(x \ge 0\) (with \(n > 0\)). For \(x > 0\), its derivative is strictly positive:
\[ g'(x) = \dfrac {n}{2\sqrt {x}(x + n)^{3/2}} > 0. \]
Since \(g(x)\) is strictly increasing on \([0, \infty )\), we can apply it directly to the extremes of the inequality \(0 \le \chi ^2_c \le n(m - 1)\):
\(\seteqnumber{0}{13.}{0}\)\begin{align*} g(0) &\le g(\chi ^2_c) \le g\big (n(m - 1)\big ) \\ \sqrt {\dfrac {0}{0 + n}} &\le P \le \sqrt {\dfrac {n(m - 1)}{n(m - 1) + n}} \\ 0 &\le P \le \sqrt {\dfrac {n(m - 1)}{nm}} = \sqrt {\dfrac {m - 1}{m}}. \end{align*} Thus, \(P \in \left [0, \sqrt {(m-1)/m}\right ]\).