Covariance of two available case means from their overlap and the standard error of their sum

Two available case means in one arm rest on n_1 and n_2 participants, of whom n_12 appear in both, so the covariance of the means depends on the overlap as well as on the correlation. Derrick, Toher and White print the term for the difference of two means that use all available data, subtracting 2 r s_1 s_2 n_c / (n_1 n_2) under the square root in their equation 4, with r taken from the paired observations only. For a sum the sign is plus, and half the term is the covariance (both derived, because independent participants contribute to the covariance only when they are in both means). HE-FM-NBA-001 keeps one arm size for both variances and the cross term, r_1 s_E1 s_C1 / n_1 before its lambda scaling, and that cross term is the case n_1 = n_2 = n_12 here. V_C and SE_C take the form of SE_INB in HE-FM-AN-004 with lambda set to minus 1 (derived), a value outside that record's threshold, so only Cov_12 is new. With no overlap the covariance is 0. For a cost mean and a QALY mean in one arm, Cov_12 feeds Cov_CE of HE-FM-AN-004, as HE-CF-ACA-001 sets out.

Signature

Cov_12 = r * s_1 * s_2 * n_12 / (n_1 * n_2); V_C = s_1^2 / n_1 + s_2^2 / n_2 + 2 * Cov_12; SE_C = sqrt(V_C)
Inputs
InputsDefinitionUnit
rPearson correlation of the two quantities over the n_12 participants observed on both, entered as 0 when n_12 is 0none, at least -1 and at most 1
s_1Sample standard deviation of all values observed for the first meanunit of the values
s_2Sample standard deviation of all values observed for the second meanunit of the values
n_12Number of participants observed for both means, n_c in Derrick and colleaguescount, at least 0 and at most the smaller of n_1 and n_2
n_1Number of participants observed for the first meancount, at least 2
n_2Number of participants observed for the second meancount, at least 2
Output
Cov_12Covariance of the two sample means given who is observed on eachunit of the first values times unit of the second values
V_CVariance of the sum of the two meansunit of the values, squared
SE_CStandard error of the sum of the two meansunit of the values, for example pounds

Function

Available case standard error of a sum of means with a separate count for each mean

Takes two available case means from one treatment group, their standard deviations, their counts, the count observed on both and the correlation in that overlap, and returns their covariance and the variance and standard error of their sum. The available case point estimate needs no new record. Each period mean is x_bar of HE-FM-BSE-002 on the participants observed for that period, and the mean total is the sum of those means, as Faria and colleagues describe and the article displays, so the cost and QALY totals in one arm can each rest on their own counts. A complete case mean is the same x_bar on a smaller set of participants. The respondent-weighted means in the article's example take the form of c_bar in HE-FM-CWT-001, and reweighting stratum means to the randomised mix takes the form of R_g in HE-FM-INEQ-001. The ratio and the net benefit built on these means are HE-FM-ICER-001 and HE-FM-NMB-002, and the interval for net benefit is HE-FM-AN-004, which takes the covariance as an input. In the article's example each participant gives one QALY measure, so each QALY mean is a single division, 47 / 65 = 0.7231 on the new treatment. Notation follows the Available Case Analysis article.

Computational function

  • Computational function for net benefit and its standard error from patient rows under available case means

    Takes each arm's patient rows of costs and QALYs with gaps and returns incremental net benefit at a threshold with its standard error, keeping a separate count for each mean and the overlap count for each arm's covariance. The arm covariances are HE-FM-ACA-002 with costs and QALYs as the two quantities; the two arms are independent, so their covariances add to give the Cov_CE input of HE-FM-AN-004 (derived). The last two parts are INB and SE_INB of HE-FM-AN-004, written with variances in place of squared standard errors. Delta_C and Delta_E are differences in arm means. HE-CF-NBA-001 has the same chain with one count per arm; this function adds a count for each mean and the overlap count. The calculator line runs on summary values, and the code below starts from the rows.

    Inputs and outputs: m_CT, m_CU, m_ET, m_EU are mean cost and mean QALYs on the new treatment (T) and usual care (U); s_CT, s_CU, s_ET, s_EU their sample standard deviations over all observed values; n_CT, n_CU, n_ET, n_EU their counts; n_CET, n_CEU the count observed on both in each arm; r_T, r_U the correlation in that overlap; lambda the threshold in pounds per QALY. Outputs are Cov_T, Cov_U, Delta_C, Delta_E, V_C, V_E, Cov_CE, INB and SE_INB. In the code, cT, qT, cU and qU are vectors of equal length within an arm with NA in R and None in Python for an unobserved value.

    Assumption: The assumptions of HE-FM-ACA-002 and HE-FM-AN-004 hold. Each mean has at least 2 observed values; the R code stops with a message and the Python code raises AssertionError when one does not. With fewer than 2 pairs in an arm, or no variation in the pairs, the R and Python code set that arm's correlation to 0, so its covariance is 0; this is correct for no pairs and a stated simplification otherwise (derived).

    Worked example (Article's means with assumed spreads): Means and counts follow the article's worked example; the standard deviations and correlations are assumed for illustration. Costs are complete, so each overlap equals the QALY count. INB is about GBP 467, as in the article, with a standard error of about GBP 873.84 and z_INB of about 0.535 under HE-FM-AN-004. The article's true value is minus GBP 300, which the standard error does not reveal because it measures sampling spread around a biased estimate. m_CT = 5000; m_CU = 3500; m_ET = 0.72308; m_EU = 0.62471; s_CT = 3000; s_CU = 2800; s_ET = 0.2; s_EU = 0.22; r_T = -0.3; r_U = -0.2; n_CT = 100; n_CU = 100; n_ET = 65; n_EU = 85; n_CET = 65; n_CEU = 85; lambda = 20000; Cov_T = -1.8; Cov_U = -1.232; Delta_C = 1500; Delta_E = 0.09837; V_C = 168400; V_E = 0.001185; Cov_CE = -3.032; INB = 467.4; SE_INB = 873.84

    Worked example (Limiting case with every value observed): With all 100 participants observed in each arm, the cross term has one count per arm and Cov_CE equals Cov_EC of HE-CF-NBA-001 on the same inputs (computed here). The means are held at the first example's values so that only the counts change. m_CT = 5000; m_CU = 3500; m_ET = 0.72308; m_EU = 0.62471; s_CT = 3000; s_CU = 2800; s_ET = 0.2; s_EU = 0.22; r_T = -0.3; r_U = -0.2; n_CT = 100; n_CU = 100; n_ET = 100; n_EU = 100; n_CET = 100; n_CEU = 100; lambda = 20000; Cov_T = -1.8; Cov_U = -1.232; Delta_C = 1500; Delta_E = 0.09837; V_C = 168400; V_E = 0.000884; Cov_CE = -3.032; INB = 467.4; SE_INB = 802.05

    Excel: In one arm's rows, with costs in column B named CostsNew and QALYs in column C named QalysNew, true blanks where unobserved, a helper column named PairsNew holds =ISNUMBER(B2)*ISNUMBER(C2) filled down. A cell named CountPairsNew holds =SUM(PairsNew). A cell named CorrNew holds =(CountPairsNew*SUMPRODUCT(PairsNew,CostsNew,QalysNew)-SUMPRODUCT(PairsNew,CostsNew)*SUMPRODUCT(PairsNew,QalysNew))/SQRT((CountPairsNew*SUMPRODUCT(PairsNew,CostsNew,CostsNew)-SUMPRODUCT(PairsNew,CostsNew)^2)*(CountPairsNew*SUMPRODUCT(PairsNew,QalysNew,QalysNew)-SUMPRODUCT(PairsNew,QalysNew)^2)). A cell named CovNew holds =CorrNew*STDEV.S(CostsNew)*STDEV.S(QalysNew)*CountPairsNew/(COUNT(CostsNew)*COUNT(QalysNew)). Repeat for CostsUsual and QalysUsual, giving CovUsual. With the threshold in a cell named Threshold, a cell named IncNBAvail holds =Threshold*(AVERAGE(QalysNew)-AVERAGE(QalysUsual))-(AVERAGE(CostsNew)-AVERAGE(CostsUsual)) and a cell named SeNBAvail holds =SQRT(Threshold^2*(VAR.S(QalysNew)/COUNT(QalysNew)+VAR.S(QalysUsual)/COUNT(QalysUsual))+VAR.S(CostsNew)/COUNT(CostsNew)+VAR.S(CostsUsual)/COUNT(CostsUsual)-2*Threshold*(CovNew+CovUsual)). CorrNew returns #DIV/0! with fewer than 2 pairs or no variation in the pairs, and STDEV.S returns #DIV/0! with fewer than 2 observed values.

    R: aca <- function(cT, qT, cU, qU, lam) { arm <- function(c, q) { ok <- !is.na(c) & !is.na(q); stopifnot(sum(!is.na(c)) >= 2, sum(!is.na(q)) >= 2); r <- if (sum(ok) < 2 || sd(c[ok]) == 0 || sd(q[ok]) == 0) 0 else cor(c[ok], q[ok]); r * sd(c, na.rm = TRUE) * sd(q, na.rm = TRUE) * sum(ok) / (sum(!is.na(c)) * sum(!is.na(q))) }; v <- function(x) var(x, na.rm = TRUE) / sum(!is.na(x)); cv <- arm(cT, qT) + arm(cU, qU); inb <- lam * (mean(qT, na.rm = TRUE)-mean(qU, na.rm = TRUE))-(mean(cT, na.rm = TRUE)-mean(cU, na.rm = TRUE)); c(INB = inb, SE_INB = sqrt(lam^2 * (v(qT) + v(qU)) + v(cT) + v(cU)-2 * lam * cv), Cov_CE = cv) } Called as aca(c(100, 200, 300, 400, 500, 600), c(0.5, 0.6, NA, 0.8, NA, 0.7), c(100, 150, NA, 300, 350, 400), c(0.4, NA, 0.6, 0.5, 0.7, 0.6), 20000) it returns INB of 1710, SE_INB of 1585.93 and Cov_CE of 5.017.

    Python: def aca(cT, qT, cU, qU, lam): o = lambda x: [a for a in x if a is not None]; m = lambda x: sum(x) / len(x); v = lambda x: sum((a-m(x)) ** 2 for a in x) / (len(x)-1); assert min(len(o(x)) for x in (cT, qT, cU, qU)) >= 2, 'at least 2 observed values per mean'; sxy = lambda A, B: sum((a-m(A)) * (b-m(B)) for a, b in zip(A, B)); r = lambda A, B: 0.0 if len(A) < 2 or sxy(A, A) * sxy(B, B) == 0 else sxy(A, B) / (sxy(A, A) * sxy(B, B)) ** 0.5; p = lambda c, q: [(a, b) for a, b in zip(c, q) if a is not None and b is not None]; cov = lambda c, q: (lambda A, B: r(A, B) * (v(o(c)) * v(o(q))) ** 0.5 * len(A) / (len(o(c)) * len(o(q))))([a for a, b in p(c, q)], [b for a, b in p(c, q)]); cv = cov(cT, qT) + cov(cU, qU); inb = lam * (m(o(qT))-m(o(qU)))-(m(o(cT))-m(o(cU))); return inb, (lam ** 2 * (v(o(qT)) / len(o(qT)) + v(o(qU)) / len(o(qU))) + v(o(cT)) / len(o(cT)) + v(o(cU)) / len(o(cU))-2 * lam * cv) ** 0.5, cv Standard library only; the same call with None for each gap returns 1710, 1585.93 and 5.017.

    Test (Patient rows with gaps): With the rows in the R call above and Threshold 20000, SeNBAvail equals 1585.93 within 0.005. Expected result TRUE. Leaving out the covariances gives 1647.98 and FALSE, and doubling (3171.86) or halving (792.96) the cell also gives FALSE. Excel check =ABS(SeNBAvail-1585.93)<0.005

    Test (Complete rows against person net benefit): With complete costs of 100, 200, 300 and 400 and QALYs of 0.5, 0.6, 0.7 and 0.8 on the new treatment, costs of 100, 150, 300 and 350 and QALYs of 0.4, 0.7, 0.5 and 0.6 on usual care, Threshold 20000, and each person's Threshold times QALYs less cost in columns named NetBenefitNew and NetBenefitUsual, SeNBAvail equals the standard error computed directly from those columns, 1772.30. Expected result TRUE. Doubling (3544.60) or halving (886.15) the cell gives FALSE. Excel check =ABS(SeNBAvail-SQRT(VAR.S(NetBenefitNew)/COUNT(NetBenefitNew)+VAR.S(NetBenefitUsual)/COUNT(NetBenefitUsual)))<0.001

    Common error (Overlap count used alone for the covariance): Dividing each arm's cross term by its pair count in place of the two counts gives Cov_CE of minus 4.2186 and SE_INB of about GBP 900.59 in the first worked example, 3.1% above GBP 873.84; leaving out the covariance gives GBP 801.45, 8.3% below (computed here).

    Source: Derrick B, Toher D, White P. How to compare the means of two samples that include paired observations and independent observations: a companion to Derrick, Russ, Toher and White (2017). The Quantitative Methods for Psychology. 2017;13(2):120-126. Section Worked Example, page 123, equation (4). Faria R, Gomes M, Epstein D, White IR. A guide to handling missing data in cost-effectiveness analysis conducted within randomised controlled trials. PharmacoEconomics. 2014;32(12):1157-1170. Section Complete Case Analysis, Available Case Analysis and Inverse Probability Weighting.

    Cov_T = r_T * s_CT * s_ET * n_CET / (n_CT * n_ET); Cov_U = r_U * s_CU * s_EU * n_CEU / (n_CU * n_EU); Delta_C = m_CT - m_CU; Delta_E = m_ET - m_EU; V_C = s_CT^2 / n_CT + s_CU^2 / n_CU; V_E = s_ET^2 / n_ET + s_EU^2 / n_EU; Cov_CE = Cov_T + Cov_U; INB = lambda * Delta_E - Delta_C; SE_INB = sqrt(lambda^2 * V_E + V_C - 2 * lambda * Cov_CE)

Try this function

Implementations

  • Excel

    Overlap covariance and standard error in three named cells

    With named cells SdPeriod1, SdPeriod2, CountPeriod1, CountPeriod2, CountBoth and CorrOverlap, the formulas return the covariance in a cell named CovOverlap, the variance in a cell named VarAvailableTotal and the standard error in a cell named SeAvailableTotal. CorrOverlap is the correlation over the participants observed on both, computed as for CorrNew in HE-CF-ACA-001.

    =CorrOverlap*SdPeriod1*SdPeriod2*CountBoth/(CountPeriod1*CountPeriod2); =SdPeriod1^2/CountPeriod1+SdPeriod2^2/CountPeriod2+2*CovOverlap; =SQRT(VarAvailableTotal)

Assumptions

  • Missing completely at random for the overlap covariance

    Derrick, Toher and White state that their partially overlapping samples tests are valid under missing completely at random, and that observations within a sample must be independent of each other. The formula treats the pattern of who is observed as fixed and unrelated to the values (derived). Under any other mechanism the mean may be biased, and the standard error measures only sampling spread around it (derived).

  • Standard deviations from each mean and correlation from the overlap

    As in Derrick and colleagues, s_1 and s_2 use all observations behind each mean, and r uses only those observed on both. The correlation needs n_12 of at least 2 with variation in both quantities. With n_12 of 0, r is entered as 0, which gives the covariance of 0 the formula requires (derived). Values from different participants are independent, so only those in both means add to the covariance (derived).

  • Both means taken from one arm

    In a trial the two means come from the same treatment group. Means from two separately randomised arms share no participants, so n_12 is 0 and their covariance is 0 (derived).

  • Missing data mechanisms under which an available case mean is valid

    Faria and colleagues state that complete case and available case analyses are valid under missing completely at random and, if the analysis model includes all baseline variables that predict both outcome and missingness, under covariate-dependent missingness. A plain unadjusted mean has no baseline variable in it, so it meets the second condition only when no baseline variable predicts both (derived).

Worked examples

  • Two period means from 100 and 80 participants with 70 in both

    Illustrative inputs for two follow-up periods in one arm, with costs observed for 100 and 80 participants, 70 of them in both, assumed standard deviations of GBP 1,500 and GBP 1,200 and an assumed correlation of 0.5. The covariance is 7,875, the variance 56,250 and the standard error about GBP 237.17.

    s_1 = 1500; s_2 = 1200; r = 0.5; n_1 = 100; n_2 = 80; n_12 = 70; Cov_12 = 7875; V_C = 56250; SE_C = 237.17
  • Limiting case of full overlap between two available case means

    Illustrative limiting case with the same 80 participants behind both means. The cross term takes one count, and the variance is the common-count form (1,500^2 + 1,200^2 + 2 x 0.5 x 1,500 x 1,200) / 80 = 68,625.

    s_1 = 1500; s_2 = 1200; r = 0.5; n_1 = 80; n_2 = 80; n_12 = 80; Cov_12 = 11250; V_C = 68625; SE_C = 261.96
  • Limiting case of no overlap between two available case means

    Illustrative limiting case in which no participant is in both means, so r is entered as 0, the covariance is 0 and the variance is the sum of the two terms.

    s_1 = 1500; s_2 = 1200; r = 0; n_1 = 100; n_2 = 80; n_12 = 0; Cov_12 = 0; V_C = 40500; SE_C = 201.25
  • Derrick and colleagues sleep scores used to check the overlap term

    Inputs printed by Derrick, Toher and White for a fictional sleep study, in score units, with 16 observations per sample and 8 pairs. The variance terms are 0.5573 and 0.4823 and the cross term 2 x 0.1781 = 0.3562. Subtracting it as the source does gives 0.6834 with a square root of 0.8267, and the mean difference 2 / 0.8267 = 2.419, the t statistic they print. Adding it gives the variance of the sum shown here. The two samples are the viewing conditions of that study and not a treatment arm, so the example checks the overlap term only and the sum has no meaning of its own.

    s_1 = 2.986; s_2 = 2.778; r = 0.687; n_1 = 16; n_2 = 16; n_12 = 8; Cov_12 = 0.1781; V_C = 1.3958; SE_C = 1.1814

Common errors

  • Dropping the cross term between two available case means

    Treating the two means as independent ignores participants who are in both. In HE-EX-ACA-004 the standard error falls to GBP 201.25 against GBP 237.17, 15.1% too low with a positive correlation.

  • Using one average count for both means and the overlap

    Replacing all three counts with the average of 100 and 80 gives a variance of 61,000 and a standard error of GBP 246.98 in HE-EX-ACA-004, 4.1% too high. At a correlation of minus 0.5 the same shortcut gives GBP 144.91 against GBP 157.32, 7.9% too low, so in this two-mean case the direction depends on r (computed here). Van Buuren reports that the average sample size gives standard errors that are too small under pairwise deletion, and that it is unclear which sample size to use.

  • Dividing the cross term by the overlap count alone

    Taking the covariance as r s_1 s_2 / n_12 treats both means as if they rested on the overlap alone. In HE-EX-ACA-004 it gives a covariance of 12,857.14 against 7,875 and a standard error of GBP 257.32 against GBP 237.17, 8.5% too high.

  • Reading the larger count as removing bias

    More observations improve precision and leave the bias set by the missing data mechanism. In the article's example the new treatment's mean QALYs use all 65 respondents and give 0.7231 against a true 0.675, an overstatement of 0.048, because severe patients are under-represented among those respondents.

  • Typing zero for an unobserved period value

    COUNT includes a typed zero and skips a blank. In an illustrative period with 60 observed costs totalling GBP 36,000, typing the 40 unobserved values as 0 gives a count of 100 and a mean of GBP 360 against GBP 600, 40% too low, and the counts and standard deviations fed to HE-FM-ACA-002 are then wrong too.

Sources

  • Derrick and colleagues on the standard error with paired and independent observations

    Derrick B, Toher D, White P. How to compare the means of two samples that include paired observations and independent observations: a companion to Derrick, Russ, Toher and White (2017). The Quantitative Methods for Psychology. 2017;13(2):120-126. Section Worked Example, page 123, defines each mean and standard deviation over all observations in its sample and r over the paired observations only, and equation (4) gives the partially overlapping samples t statistic with denominator the square root of s_1^2 / n_1 + s_2^2 / n_2 less 2 r s_1 s_2 n_c / (n_1 n_2). The printed inputs and the result t_2 = 2.419 are on the same page. The sentence on validity under missing completely at random is on page 122, and the assumption that observations within a sample are independent is on page 125. The tests were developed in Derrick, Russ, Toher and White 2017, Journal of Modern Applied Statistical Methods (not seen). The sum form and the covariance reading are derived here.

    View source →

  • Faria and colleagues on summing available case means, their validity and the covariance structure

    Faria R, Gomes M, Epstein D, White IR. A guide to handling missing data in cost-effectiveness analysis conducted within randomised controlled trials. PharmacoEconomics. 2014;32(12):1157-1170. Section Complete Case Analysis, Available Case Analysis and Inverse Probability Weighting states that with available case analysis the mean costs and QALYs are calculated by treatment group at each follow-up point and that total means over the whole time horizon are estimated as the sum of these means. The same section gives the validity conditions in the assumption of this record on missing data mechanisms, and states that available case analysis may use different samples for the costs and for the health outcomes, which may lead to non-comparability between the patient groups and affect the covariance structure.

    View source →

  • Van Buuren on pairwise deletion as available case analysis, its consistency and the sample size for standard errors

    van Buuren S. Flexible Imputation of Missing Data. 2nd ed. Boca Raton: Chapman & Hall/CRC; 2018. Section 1.3.2, Pairwise deletion, describes the method, also known as available-case analysis, as calculating the means and (co)variances on all observed data, states that under missing completely at random it gives consistent estimates of mean, correlations and covariances, citing Little and Rubin 2002, and states that the estimates can be biased if the data are not missing completely at random. It also states that it is not clear what sample size should be used for calculating standard errors and that taking the average sample size yields standard errors that are too small, citing Little 1992.

    View source →

  • Briggs and colleagues on differing observation counts across resource use items

    Briggs A, Clark T, Wolstenholme J, Clarke P. Missing... presumed at random: cost-analysis of incomplete data. Health Economics. 2003;12(5):377-392. The abstract states that available case analysis, by employing different numbers of observations for each resource use item, generates severe problems for standard statistical inference. HE-FM-ACA-002 treats that problem for two means only (derived).

    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/covariance-of-two-available-case-means-from-their-overlap-and-the-standard-error-of-their-sum