One-way analysis of variance estimator of the intracluster correlation for equal clusters

Turns the two mean squares from a one-way analysis of variance of a cost or outcome by cluster into estimates of the between-cluster variance and of rho in HE-FM-CLUE-001. MSW estimates sigma_w2 directly, and the expected value of MSB is m sigma_b2 + sigma_w2, so the difference divided by m estimates sigma_b2. The estimate rho_hat equals sigma_b2_hat over the sum of sigma_b2_hat and MSW (derived). Killip and colleagues state that calculating rho usually requires a pilot study, and these are the sums such a study needs when its clusters are of equal size. Clusters of unequal size use HE-CF-CLUE-001.

Signature

sigma_b2_hat = (MSB - MSW) / m; rho_hat = (MSB - MSW) / (MSB + (m - 1) * MSW)
Inputs
InputsDefinitionUnit
MSBMean square between clusters from a one-way analysis of variance, on k minus 1 degrees of freedom for k clusters in one group and k minus 2 within two arms; zero or abovesquare of the outcome's unit
MSWMean square within clusters, on k (m minus 1) degrees of freedom; above zerosquare of the outcome's unit
mNumber of individuals in each cluster, the same in every cluster; 2 or morepeople per cluster
Output
sigma_b2_hatEstimate of the between-cluster variance; negative when MSB is below MSWsquare of the outcome's unit
rho_hatAnalysis of variance estimate of rho; negative when MSB is below MSWproportion

Function

Intracluster correlation of costs or outcomes from variance components and mean squares

Maps the variance of a cost or an outcome between and within clusters, or the mean squares of a one-way analysis of variance, to the intracluster correlation coefficient and a confidence interval for it. HE-AS-BINOM-002 states the independence that fails under clustering for a count, and HE-AS-AN-002 asks for cluster-robust standard errors in a Wald interval. The design effect and the effective sample size that follow from rho sit on the Design Effect concept and are not restated here. Incremental net benefit and its standard error in the article's worked example are HE-FM-AN-004 with Cov_CE of 0, and the article's step 4 is the same record with each standard error multiplied by the square root of its design effect (derived), so that step is a citation and not a new formula. Notation follows the Cluster Effect article.

Computational function

  • Computational function for the intracluster correlation from cluster sizes, means and variances

    Takes the size, mean and sample variance of the cost or outcome in each cluster, which a trial report or a pilot study can supply, and returns the one-way analysis of variance table, the adjusted cluster size n_A and the estimates of HE-FM-CLUE-002 with n_A in the place of m. The inputs therefore differ from the formula's variables, which are the finished mean squares. The calculator line writes four clusters out term by term. The Excel code takes any number of clusters as the same summaries, and the R and Python code take the individual values in each cluster.

    Inputs and outputs: n_1 to n_4 are the people in each cluster, whole numbers of 1 or more. y_1 to y_4 are the cluster means. s2_1 to s2_4 are the sample variances within each cluster with divisor one less than the size, and a cluster of one person adds nothing to SSW whatever its entry. N is the total number of people. ybar is the overall mean, weighted by size. SSB and SSW are the between and within sums of squares. MSB and MSW are the mean squares, on 3 and N minus 4 degrees of freedom here. n_A is the adjusted cluster size. sigma_b2_hat and rho_hat are the estimates.

    Assumption: The conditions of HE-AS-CLUE-005 hold, and the list holds the clusters of one trial arm (HE-AS-CLUE-007). There must be at least 2 clusters and more people than clusters. For a binary outcome, the means are proportions p_j and the variances n_j p_j (1 minus p_j) / (n_j minus 1), which reproduces the mean squares that Wu and colleagues print (derived, no mismatch on 50,000 random tables).

    Worked example (Illustrative four practices of unequal size): Sizes of 20, 30, 25 and 25 give n_A of 24.8333, a little below the mean size of 25, and a correlation of about 0.0291. n_1 = 20; n_2 = 30; n_3 = 25; n_4 = 25; y_1 = 1200; y_2 = 1500; y_3 = 1350; y_4 = 1650; s2_1 = 450000; s2_2 = 500000; s2_3 = 480000; s2_4 = 520000; N = 100; ybar = 1440; SSB = 2565000; SSW = 47050000; MSB = 855000; MSW = 490104.17; n_A = 24.8333; sigma_b2_hat = 14693.79; rho_hat = 0.0291

    Worked example (Illustrative equal clusters): Four practices of 30 return n_A of 30, the formula HE-FM-CLUE-002 at m of 30, a case that checks an implementation. n_1 = 30; n_2 = 30; n_3 = 30; n_4 = 30; y_1 = 1100; y_2 = 1300; y_3 = 1500; y_4 = 1700; s2_1 = 475000; s2_2 = 475000; s2_3 = 475000; s2_4 = 475000; N = 120; ybar = 1400; SSB = 6000000; SSW = 55100000; MSB = 2000000; MSW = 475000; n_A = 30; sigma_b2_hat = 50833.33; rho_hat = 0.0967

    Worked example (Identical cluster means): With no difference between the means, MSB is 0 and the estimate reaches its floor of minus 1 / (n_A minus 1) (derived). n_1 = 30; n_2 = 30; n_3 = 30; n_4 = 30; y_1 = 1400; y_2 = 1400; y_3 = 1400; y_4 = 1400; s2_1 = 475000; s2_2 = 475000; s2_3 = 475000; s2_4 = 475000; N = 120; ybar = 1400; SSB = 0; SSW = 55100000; MSB = 0; MSW = 475000; n_A = 30; sigma_b2_hat = -15833.33; rho_hat = -0.0345

    Excel: With ranges named ClusterSizes, ClusterMeans and ClusterVariances, =SUMPRODUCT(ClusterSizes,ClusterMeans)/SUM(ClusterSizes) fills OverallMean, =SUMPRODUCT(ClusterSizes,(ClusterMeans-OverallMean)^2)/(COUNT(ClusterSizes)-1) fills MeanSquareBetween, =SUMPRODUCT(ClusterSizes-1,ClusterVariances)/(SUM(ClusterSizes)-COUNT(ClusterSizes)) fills MeanSquareWithin, =(SUM(ClusterSizes)-SUMSQ(ClusterSizes)/SUM(ClusterSizes))/(COUNT(ClusterSizes)-1) fills AdjustedClusterSize, and =(MeanSquareBetween-MeanSquareWithin)/(MeanSquareBetween+(AdjustedClusterSize-1)*MeanSquareWithin) fills IccFromSummaries. A blank variance for a cluster of one person counts as 0, which is right because its factor is 0, and that cell is left blank because VAR on one value returns #DIV/0!. A blank size inside ClusterSizes makes ClusterSizes-1 read minus 1 and gives a wrong MeanSquareWithin with no warning, a text cell in ClusterSizes or ClusterMeans returns #VALUE!, and a text cell in ClusterVariances counts as 0 with no warning (0.0436 in place of 0.0291 with text as the first variance of the first example), so the ranges hold complete numeric rows only. A single cluster returns #DIV/0!.

    R: icc_anova <- function(groups) { groups <- Filter(length, groups); k <- length(groups); n <- lengths(groups); N <- sum(n); if (k < 2 || N <= k) return(NULL); means <- sapply(groups, mean); ybar <- sum(n*means)/N; msb <- sum(n*(means-ybar)^2)/(k-1); msw <- sum(sapply(groups, function(x) sum((x-mean(x))^2)))/(N-k); n_a <- (N-sum(n^2)/N)/(k-1); den <- msb+(n_a-1)*msw; c(MSB = msb, MSW = msw, n_A = n_a, sigma_b2_hat = (msb-msw)/n_a, rho_hat = if (den > 0) (msb-msw)/den else NA) } Takes a list of numeric vectors, one per cluster, and returns a named vector. Empty clusters are dropped. It returns NULL when there are fewer than 2 clusters or no more people than clusters, and rho_hat of NA when every value in the data is identical.

    Python: def icc_anova(groups): g = [x for x in groups if len(x) > 0]; k = len(g); n = [len(x) for x in g]; N = sum(n); valid = k >= 2 and N > k; means = [sum(x)/len(x) for x in g]; ybar = sum(a*b for a, b in zip(n, means))/N if valid else None; msb = sum(a*(b-ybar)**2 for a, b in zip(n, means))/(k-1) if valid else None; msw = sum(sum((v-b)**2 for v in x) for x, b in zip(g, means))/(N-k) if valid else None; n_a = (N-sum(a*a for a in n)/N)/(k-1) if valid else None; den = msb+(n_a-1)*msw if valid else None; return (msb, msw, n_a, (msb-msw)/n_a, (msb-msw)/den if den > 0 else None) if valid else None Plain Python with no imports, taking a list of lists, one per cluster, and returning MSB, MSW, n_A, sigma_b2_hat and rho_hat as a tuple. Empty clusters are dropped. It returns None when there are fewer than 2 clusters or no more people than clusters, and None for rho_hat when every value in the data is identical, so no valid input divides by zero.

    Test (Illustrative four practices): With the first worked example in the three ranges, IccFromSummaries is compared with the hand value. The expected result is TRUE. Doubling or halving the cell gives FALSE, and a cell using the mean size of 25 in place of n_A returns 0.0289 and FALSE. Excel check =ABS(IccFromSummaries-0.0291)<0.00005

    Test (Illustrative equal clusters): With the second worked example, AdjustedClusterSize is compared with the common size and IccFromSummaries with its hand value. The expected result is TRUE. Doubling or halving either cell gives FALSE. Excel check =AND(ABS(AdjustedClusterSize-30)<1E-9,ABS(IccFromSummaries-0.0967)<0.00005)

    Common error (Mean cluster size in place of n_A): The two differ more as sizes spread. With the first example's means and variances and sizes of 5, 5, 45 and 45, n_A is 19.6667 against a mean of 25, and rho_hat is 0.0316 with n_A against 0.0250 with the mean (derived).

    Source: Wu S, Crespi CM, Wong WK. Comparison of methods for estimating the intraclass correlation coefficient for binary responses in cancer prevention cluster randomized trials. Contemporary Clinical Trials. 2012;33(5):869-880. doi:10.1016/j.cct.2012.05.004 (author manuscript read in PubMed Central, PMC3426610, with section and equation numbers from that version). Section Methods of Estimating the ICC, subsection (1) The ANOVA estimator, equation 1.

    N = n_1 + n_2 + n_3 + n_4; ybar = (n_1 * y_1 + n_2 * y_2 + n_3 * y_3 + n_4 * y_4) / N; SSB = n_1 * (y_1 - ybar)^2 + n_2 * (y_2 - ybar)^2 + n_3 * (y_3 - ybar)^2 + n_4 * (y_4 - ybar)^2; SSW = (n_1 - 1) * s2_1 + (n_2 - 1) * s2_2 + (n_3 - 1) * s2_3 + (n_4 - 1) * s2_4; MSB = SSB / 3; MSW = SSW / (N - 4); n_A = (N - (n_1^2 + n_2^2 + n_3^2 + n_4^2) / N) / 3; sigma_b2_hat = (MSB - MSW) / n_A; rho_hat = (MSB - MSW) / (MSB + (n_A - 1) * MSW)

Try this function

Implementations

  • Excel

    Intracluster correlation estimate from named mean square cells

    With inputs in cells named MeanSquareBetween, MeanSquareWithin and PeoplePerCluster, the two formulas fill cells named BetweenVarEstimate and IccEstimate. A blank PeoplePerCluster is treated as 0 and returns #DIV/0! in the first cell and, unless the two mean squares are equal, 1 in the second, so the cell needs an entry check. Both mean squares blank returns 0 in the first cell and #DIV/0! in the second.

    =(MeanSquareBetween-MeanSquareWithin)/PeoplePerCluster; =(MeanSquareBetween-MeanSquareWithin)/(MeanSquareBetween+(PeoplePerCluster-1)*MeanSquareWithin)

Assumptions

  • One-way random effects layout with clusters as targets

    Each cluster has its own people, and a response is an overall mean plus a cluster effect with variance sigma_b2 plus an independent residual with variance sigma_w2. This is Case 1 of Shrout and Fleiss, with clusters in the place of their targets and people in the place of their ratings. That mapping is made here, and Wu and colleagues state the estimator directly for cluster trials. Shrout and Fleiss note that the estimate is consistent but biased.

  • Same number of people in every cluster for the simple estimator

    The form with m holds when all clusters have m people. With unequal sizes Wu and colleagues replace m by n_A, which HE-CF-CLUE-001 computes, and n_A returns m when the sizes are equal (derived).

  • Mean squares taken within trial arms

    In a two-arm cluster trial the between-cluster mean square is taken within arms, with arm differences removed, because the cluster effect is defined around the mean of each treatment group (HE-AS-CLUE-002). Computed over both arms together it also holds the difference between arms, as HE-ER-CLUE-007 shows. Taken within two arms, the between-cluster mean square has k minus 2 degrees of freedom for k clusters (derived), which changes the interval as HE-AS-CLUE-011 sets out.

  • Negative estimates can occur by chance

    Wu and colleagues note that the analysis of variance estimate can be negative. Under this model rho is a variance ratio and cannot be below 0, so a negative estimate is sampling error (derived). The estimate cannot fall below minus 1 / (m minus 1), reached when MSB is 0 (derived).

Worked examples

  • Mean squares of an illustrative single group of 30 practices with 30 patients each

    Illustrative mean squares set at their expected values for the variances of HE-EX-CLUE-001, with the 30 practices taken as one group and no arm difference, so MSW is 475,000 and MSB is 30 x 25,000 + 475,000. The estimator returns those variances and a correlation of 0.05.

    MSB = 1225000; MSW = 475000; m = 30; sigma_b2_hat = 25000; rho_hat = 0.05
  • Shrout and Fleiss analysis of variance table for six targets and four ratings

    The mean squares of Table 3 of Shrout and Fleiss, with four ratings on each of six targets, give 0.1659, printed as .17 for ICC(1,1) in their Table 4. The data are ratings and not clinical clusters, and the case checks an implementation against a published value.

    MSB = 11.24; MSW = 6.26; m = 4; sigma_b2_hat = 1.245; rho_hat = 0.1659
  • Illustrative mean squares giving the correlation in the Killip case study

    Killip and colleagues use rho of 0.017 for 4 physicians recruiting 32 patients each, without giving mean squares. These illustrative mean squares are chosen to return that value, with the within-cluster mean square scaled to 1.

    MSB = 1.5534; MSW = 1; m = 32; sigma_b2_hat = 0.0173; rho_hat = 0.017
  • Illustrative between-cluster mean square below the within-cluster mean square

    With MSB below MSW both estimates are negative, a result Wu and colleagues note can occur. The figures are illustrative.

    MSB = 0.9; MSW = 1; m = 32; sigma_b2_hat = -0.0031; rho_hat = -0.0031

Common errors

  • Variance of the cluster means taken as the between-cluster variance

    The variance of observed cluster means also holds sampling noise, since its expected value is sigma_b2 + sigma_w2 / m (derived from the mean square expectations of Shrout and Fleiss, Table 1). In the first worked example it is about 40,833 in place of 25,000, and the ratio with MSW is 0.0792 in place of 0.05.

  • Reliability of a cluster mean reported as the intracluster correlation

    The ratio (MSB minus MSW) / MSB is the reliability of a mean of m responses, ICC(1,k) in Shrout and Fleiss, and answers a different question. In the first worked example it returns 0.6122 against 0.05 for a single person, and the design effect needs the single-person value.

  • Mean squares computed across both arms of a cluster trial

    Four illustrative practices of 30 with MSW of 500,000 and mean costs of GBP 1,000 and GBP 1,200 in one arm and GBP 1,500 and GBP 1,700 in the other give MSB of 2,900,000 and rho_hat of 0.1379 when arms are ignored. Taken within arms, MSB is 600,000 on 2 degrees of freedom and rho_hat is 0.0066 (derived), so most of the apparent clustering here is the difference between arms.

  • Negative estimate carried directly into a design effect

    Putting rho_hat of minus 0.003135, shown as minus 0.0031 in HE-EX-CLUE-008, into the factor on the Design Effect concept with 32 people per cluster gives 0.9028, and an effective size of about 141.8 for 128 people, more information than was enrolled (derived). The estimate and its interval in HE-FM-CLUE-003 are reported instead of treating the value as a gain in precision.

Sources

  • Shrout and Fleiss on the one-way estimator of the intraclass correlation

    Shrout PE, Fleiss JL. Intraclass correlations: uses in assessing rater reliability. Psychological Bulletin. 1979;86(2):420-428. doi:10.1037/0033-2909.86.2.420. Table 1 gives the expected mean squares under Case 1, k sigma_T squared + sigma_W squared for BMS and sigma_W squared for WMS. The section Decision 1, A One- or Two-Way Analysis of Variance, states that WMS is an unbiased estimate of the within-target variance, that subtracting WMS from BMS and dividing by the number of judges per target gives an unbiased estimate of the target variance, and prints ICC(1,1) = (BMS minus WMS) / (BMS + (k minus 1) WMS), noting that it is consistent but biased. Table 3 gives BMS 11.24 and WMS 6.26, and Table 4 gives ICC(1,1) of .17. Section Decision 3, What Is the Unit of Reliability?, prints ICC(1,k) = (BMS minus WMS) / BMS. Their k is m here, their n is the number of clusters, and their sigma_T and sigma_W are sigma_b and sigma_w here.

    View source →

  • Wu and colleagues on the analysis of variance estimator in cluster trials

    Wu S, Crespi CM, Wong WK. Comparison of methods for estimating the intraclass correlation coefficient for binary responses in cancer prevention cluster randomized trials. Contemporary Clinical Trials. 2012;33(5):869-880. doi:10.1016/j.cct.2012.05.004 (author manuscript read in PubMed Central, PMC3426610, with section and equation numbers from that version). Section Methods of Estimating the ICC, subsection (1) The ANOVA estimator, equation 1, prints the estimator (MSB minus MSW) / (MSB + (n_A minus 1) MSW) with n_A = (N minus the sum of n_i squared over N) / (k minus 1), and gives the mean squares for binary data. It says the estimator was originally proposed for continuous data. Subsection (4) says the analysis of variance estimate can be negative.

    View source →

Canonical Identity

This formula is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/formula/one-way-analysis-of-variance-estimator-of-the-intracluster-correlation-for-equal-clusters