Sampling variance of a paired strategy difference under common random numbers

Gives the sampling variance of an estimated difference in mean output under the two designs Owen compares in equation 8.21. Var_com applies when both strategies run on the same n random inputs and the paired differences are averaged, and Var_ind when each strategy runs on its own n inputs and the two averages are subtracted. The two differ only by the covariance term, so with both standard deviations above zero the paired design has the smaller variance when rho is positive and the larger when rho is negative. Var_com takes the form of SE_INB squared in HE-FM-AN-004 and of Var_INMB in HE-FM-BSE-003 at lambda equal to 1 (derived), records that hold a cost difference and an effect difference and not the outputs of two strategies on shared inputs. Var_ind takes the form of the V_E step of HE-CF-NBA-001 at equal arm sizes, and the square roots give the standard errors that enter HE-FM-AN-001.

Signature

Var_com = (sigma_f^2 + sigma_g^2 - 2 * rho * sigma_f * sigma_g) / n; Var_ind = (sigma_f^2 + sigma_g^2) / n; SE_com = sqrt(Var_com); SE_ind = sqrt(Var_ind)
Inputs
InputsDefinitionUnit
sigma_fStandard deviation of a single simulated output under the first strategy, at least 0output unit
sigma_gStandard deviation of a single simulated output under the second strategy, at least 0output unit
rhoCorrelation between the two strategies' outputs on the same random inputs, at least -1 and at most 1none, a correlation coefficient
nNumber of paired differences, equal to the number of runs per strategy, above 0count of pairs
Output
Var_comSampling variance of the average of n paired differences computed with common random numberssquare of the output unit, for example pounds squared
Var_indSampling variance of the difference between two averages of n independent runs eachsquare of the output unit
SE_comStandard error of the paired difference estimate, the square root of Var_comoutput unit, for example pounds
SE_indStandard error of the difference of two independent averages, the square root of Var_indoutput unit

Function

Variance of a strategy difference with and without common random numbers

Maps the standard deviations of one simulated output under each of two strategies, the correlation between their paired outputs and the number of pairs to the variance and standard error of the estimated difference, once with both strategies on the same random inputs and once with each on its own. HE-FM-CRN-002 takes the standard deviations of the increment in test runs with and without the method and returns the shares removed from the variance and the interval half-width. HE-FM-ANTV-001 uses a correlation within the estimate of one output, and this record uses a correlation between two strategies. HE-FM-AN-004 and HE-FM-BSE-003 hold the same subtraction of a covariance term for a cost difference and an effect difference at a threshold lambda. The standard errors enter the Wald interval of HE-FM-AN-001, and the runs needed for a target standard error of a paired increment are in HE-FM-ABM-003, which computes them for agent-based model runs. Notation follows the Common Random Numbers article.

Computational function

  • Computational function: paired-run table to common random numbers standard error and correlation

    Takes a table of paired outputs from a pilot run with both strategies on the same random numbers and returns the mean difference, its standard error from the paired differences, the sample correlation and the standard error that independent arms with the same spreads would have. It checks that the sample variance of the differences equals the sample form of HE-FM-CRN-001, an identity that holds exactly with divisor n-1 (derived). The inputs differ from the formula's variables, since sigma_f, sigma_g and rho are computed from the table. The standard error step takes the form of HE-FM-ANTV-002 with paired differences in place of pair means, as HE-FM-ABM-003 describes for a paired increment. The calculator line runs four pairs, and the Excel, R and Python versions take any number of at least two.

    Inputs and outputs: f_1 to f_4: Outputs of the first strategy for four simulated patients. Unit: output unit.; g_1 to g_4: Outputs of the second strategy for the same patients on the same draws. Unit: output unit.; D_1 to D_4: Paired differences. Unit: output unit.; Dbar: Mean paired difference. Unit: output unit.; V_d: Sample variance of the paired differences. Unit: square of the output unit.; fbar, gbar: Strategy means. Unit: output unit.; V_f, V_g: Sample variances of the outputs. Unit: square of the output unit.; C_fg: Sample covariance of the outputs. Unit: square of the output unit.; rho_hat: Sample correlation. Unit: none.; V_chk: Sample form of the numerator of HE-FM-CRN-001. Unit: square of the output unit.; SE_com: Standard error of the mean paired difference. Unit: output unit.; SE_ind: Standard error if the arms were independent with the same spreads. Unit: output unit.; VR_est: Share of the independent variance removed by the pairing (derived). Unit: proportion.; ok: TRUE when V_chk equals V_d. Unit: none.

    Assumption: Each row holds one simulated patient under both strategies on synchronised draws, and rows are independent of one another. SE_ind and VR_est take the spreads of the two strategies as unchanged by the pairing, and a full check runs the model both ways as in HE-FM-CRN-002. At least two pairs are needed, and rho_hat needs a non-zero variance in each column.

    Worked example (four illustrative patients): Illustrative per-patient net benefits with large patient spread and a small steady difference give a correlation of about 0.9988 and a standard error of about 478.71 against about 10,184.75 for independent arms. f_1 = 12000; f_2 = 30000; f_3 = 21000; f_4 = 45000; g_1 = 10000; g_2 = 29000; g_3 = 18000; g_4 = 44000; Dbar = 1750; V_d = 916666.67; rho_hat = 0.9988; SE_com = 478.71; SE_ind = 10184.75; VR_est = 0.9978; ok = 1

    Worked example (identical strategies): Two identical columns give a zero difference in every row, so the paired standard error is 0, the correlation is 1 and the whole of the independent variance is removed. f_1 = 12000; f_2 = 30000; f_3 = 21000; f_4 = 45000; g_1 = 12000; g_2 = 30000; g_3 = 21000; g_4 = 45000; Dbar = 0; V_d = 0; rho_hat = 1; SE_com = 0; VR_est = 1; ok = 1

    Worked example (draws running in opposite directions): A reversed second column gives a correlation of minus 1, and the paired variance is twice the independent one, so VR_est is minus 1. f_1 = 1000; f_2 = 2000; f_3 = 3000; f_4 = 4000; g_1 = 4000; g_2 = 3000; g_3 = 2000; g_4 = 1000; Dbar = 0; V_d = 6666666.67; rho_hat = -1; SE_com = 1290.99; SE_ind = 912.87; VR_est = -1; ok = 1

    Excel: With fixed outputs in ranges named OutputF and OutputG that start in cells B2 and C2, and =B2-C2 filled down a helper range named PairDiff in the same rows, use =AVERAGE(PairDiff) for the mean difference, =STDEV.S(PairDiff)/SQRT(COUNT(PairDiff)) in a cell named SECommonPilot, =CORREL(OutputF,OutputG) in a cell named PilotCorr, =SQRT((VAR.S(OutputF)+VAR.S(OutputG))/COUNT(OutputF)) in a cell named SEIndepPilot and =1-VAR.S(PairDiff)/(VAR.S(OutputF)+VAR.S(OutputG)) in a cell named PilotVarianceCut. CORREL returns #DIV/0! when a column has no variance, and VAR.S returns #DIV/0! with fewer than two numbers.

    R: crn_pilot <- function(f, g) { d <- f-g; n <- length(d); vf <- var(f); vg <- var(g); c(rho = cor(f, g), se_com = sd(d)/sqrt(n), se_ind = sqrt((vf+vg)/n), vr = 1-var(d)/(vf+vg)) } crn_pilot(c(12000, 30000, 21000, 45000), c(10000, 29000, 18000, 44000)) returns about 0.9988, 478.71, 10184.75 and 0.9978. One pair returns NA for each value. A constant column returns NA for rho with a warning, and two constant columns also return NaN for vr.

    Python: def crn_pilot(f, g): n = len(f); d = [a-b for a, b in zip(f, g)]; vf = statistics.variance(f); vg = statistics.variance(g); vd = statistics.variance(d); r = (vf+vg-vd)/(2*math.sqrt(vf*vg)) if vf*vg > 0 else None; vr = 1-vd/(vf+vg) if vf+vg > 0 else None; return r, math.sqrt(vd/n), math.sqrt((vf+vg)/n), vr Uses the math and statistics modules and returns the same four values for the table above. It raises StatisticsError with fewer than two pairs and returns None for a correlation or share that has a zero divisor.

    Test (standard error routes agree): SECommonPilot, computed from the paired differences, is compared with the root of the sample form of HE-FM-CRN-001 over the number of pairs, at a tolerance of 0.01. Expected result TRUE. With the first worked example, a doubled cell of 957.43 or a halved cell of 239.36 gives FALSE, and so does a cell that uses SEIndepPilot in error. Excel check =ABS(SECommonPilot-SQRT((VAR.S(OutputF)+VAR.S(OutputG)-2*PilotCorr*STDEV.S(OutputF)*STDEV.S(OutputG))/COUNT(OutputF)))<0.01

    Test (hand values for four patients): With the fixed table of the first worked example, SECommonPilot is compared with 478.71 and PilotCorr with 0.9988. Expected result TRUE. A doubled or halved SECommonPilot gives FALSE, and so does a PilotCorr of 0.4994 or 1.9977. Excel check =AND(ABS(SECommonPilot-478.71)<0.01,ABS(PilotCorr-0.9988)<0.0001)

    Test (variance share from the result cell): PilotVarianceCut is compared with the value rebuilt from SECommonPilot and the two column variances, at a tolerance of 0.001. Expected result TRUE. With the first worked example, a cell of 0.9978 passes and a doubled cell of 1.9956 or a halved cell of 0.4989 gives FALSE. Excel check =ABS(PilotVarianceCut-(1-COUNT(OutputF)*SECommonPilot^2/(VAR.S(OutputF)+VAR.S(OutputG))))<0.001

    Common error (blank output cell in the table): The helper =B2-C2 treats a blank as 0, so the row's difference equals the whole output, while VAR.S and STDEV.S ignore the blank. In the first worked example a blank fourth second-strategy cell makes that row's difference 45,000, and the first test no longer returns TRUE. Each row needs a number in both columns.

    Common error (a shared seed that does not keep the draws in step): A pilot whose arms fall out of step loses correlation and gain (derived). Murphy and colleagues report a 5.55% variance reduction for matching only the initial patient characteristics, against 93.58% for the full method, and attribute the weak partial result to the model's structure.

    Source: Owen AB. Monte Carlo Theory, Methods and Examples. 2013. Chapter 8, section 8.6, equations 8.19 to 8.21, for the paired estimator and its variance. The sample routes, the checks and the code are derived.

    D_1 = f_1 - g_1; D_2 = f_2 - g_2; D_3 = f_3 - g_3; D_4 = f_4 - g_4; Dbar = (D_1 + D_2 + D_3 + D_4) / 4; V_d = ((D_1 - Dbar)^2 + (D_2 - Dbar)^2 + (D_3 - Dbar)^2 + (D_4 - Dbar)^2) / 3; fbar = (f_1 + f_2 + f_3 + f_4) / 4; gbar = (g_1 + g_2 + g_3 + g_4) / 4; V_f = ((f_1 - fbar)^2 + (f_2 - fbar)^2 + (f_3 - fbar)^2 + (f_4 - fbar)^2) / 3; V_g = ((g_1 - gbar)^2 + (g_2 - gbar)^2 + (g_3 - gbar)^2 + (g_4 - gbar)^2) / 3; C_fg = ((f_1 - fbar) * (g_1 - gbar) + (f_2 - fbar) * (g_2 - gbar) + (f_3 - fbar) * (g_3 - gbar) + (f_4 - fbar) * (g_4 - gbar)) / 3; rho_hat = C_fg / sqrt(V_f * V_g); V_chk = V_f + V_g - 2 * rho_hat * sqrt(V_f) * sqrt(V_g); SE_com = sqrt(V_d / 4); SE_ind = sqrt((V_f + V_g) / 4); VR_est = 1 - V_d / (V_f + V_g); ok = abs(V_chk - V_d) < 0.000001 * (V_f + V_g)

Try this function

Implementations

  • Excel

    Paired and independent difference variances in four named cells

    With inputs in cells named SigmaF, SigmaG, PairCorr and NumPairs, the four formulas go in cells named VarCommon, VarIndep, SECommon and SEIndep in that order. A blank NumPairs cell counts as 0 in arithmetic and returns #DIV/0!.

    =(SigmaF^2+SigmaG^2-2*PairCorr*SigmaF*SigmaG)/NumPairs; =(SigmaF^2+SigmaG^2)/NumPairs; =SQRT(VarCommon); =SQRT(VarIndep)

Assumptions

  • Outputs driven only by the shared random inputs

    Owen first assumes that neither f nor g uses any random numbers other than the inputs X, with the X_i independent and identically distributed. Once a strategy draws further numbers, keeping them common takes careful synchronisation, and Murphy and colleagues describe a separate stream for each source of variability as necessary but not sufficient, because events can fall out of step between arms.

  • Same number of runs per strategy at comparable computing cost

    Owen takes n equal to n1 and n2, which makes the computing costs of the two designs comparable when the cost of computing f and g dominates that of generating X. The comparison of Var_com with Var_ind is therefore at equal effort only under that condition.

  • Positive correlation between strategies has to be measured

    Owen states that a positive rho is not guaranteed and is anticipated when f and g compute similar quantities. The formula takes rho as a given input, so a value assumed for planning has to be confirmed with test runs of the kind compared in HE-FM-CRN-002.

  • Same output variance for each strategy in both designs

    Both designs draw X from the same distribution, so sigma_f and sigma_g are the same in Var_com and Var_ind and only the covariance term changes (derived from Owen's set-up). A model whose paired design alters the distribution of either strategy's own output breaks the comparison.

  • Treatment response draws shared only where the model justifies it

    A shared treatment-related draw can raise rho by imposing a link between a patient's responses to the two treatments, when the draw maps to each response in the same direction (derived). Murphy and colleagues, for treatments acting by different mechanisms, state that a separate series of random numbers should be applied for each treatment, and Stout and Goldie state that where little clinical evidence supports such a relationship, synchronising is not desired and could lead to incorrect conclusions.

Worked examples

  • Article example of net monetary benefit at a correlation of 0.95

    The article's illustrative inputs have a standard deviation of GBP 30,000 per patient under each strategy, 5,000 patients per strategy and a correlation of 0.95. The standard errors are about GBP 134.16 and GBP 600. HE-FM-AN-001 with z equal to 1.96 gives half-widths of about GBP 263 and GBP 1,176, as in the article, and independent runs would need about 100,000 patients per strategy to match the smaller standard error, which takes the form of HE-FM-ABM-003 (derived).

    sigma_f = 30000; sigma_g = 30000; rho = 0.95; n = 5000; Var_com = 18000; Var_ind = 360000; SE_com = 134.16; SE_ind = 600
  • Article example at a correlation of 0.5 halving the variance

    With the same illustrative inputs and a correlation of 0.5, the paired variance is half the independent variance, as the article states. The standard error falls by less than half.

    sigma_f = 30000; sigma_g = 30000; rho = 0.5; n = 5000; Var_com = 180000; Var_ind = 360000; SE_com = 424.26; SE_ind = 600
  • Zero correlation between strategies gives no gain

    Limiting case with the same illustrative inputs. At a correlation of 0 the covariance term vanishes and the two designs have the same variance.

    sigma_f = 30000; sigma_g = 30000; rho = 0; n = 5000; Var_com = 360000; Var_ind = 360000; SE_com = 600; SE_ind = 600
  • Negative correlation between strategies makes matching worse

    Illustrative inputs with a correlation of minus 0.2. The paired variance exceeds the independent variance, the case Owen allows for in stating that a positive rho is not guaranteed, and the standard error is about 9.5% larger.

    sigma_f = 30000; sigma_g = 30000; rho = -0.2; n = 5000; Var_com = 432000; Var_ind = 360000; SE_com = 657.27; SE_ind = 600
  • Perfect correlation with unequal standard deviations leaves a floor

    Illustrative inputs with standard deviations of GBP 30,000 and GBP 20,000 and a correlation of 1. The paired variance falls to its smallest value, the squared difference of the two standard deviations divided by n, and it is not zero (derived).

    sigma_f = 30000; sigma_g = 20000; rho = 1; n = 5000; Var_com = 20000; Var_ind = 260000; SE_com = 141.42; SE_ind = 509.9

Common errors

  • Two-sample standard error applied to matched strategy output

    Stout and Goldie state that tests such as the paired t test, which account for the correlation, should be used, and that two-sample t tests assuming independence should not. In the article's example the two-sample standard error of GBP 600 is about 4.5 times the paired GBP 134.16, so the half-width of GBP 1,176 hides the precision that matching bought.

  • Assuming the correlation between strategies is positive

    Owen states that there is no guarantee of a positive rho, and Murphy and colleagues state that common random numbers can actually increase variance where several variables interact. In HE-EX-CRN-004 a correlation of minus 0.2 gives a standard error of about GBP 657, against GBP 600 for independent runs.

  • Counting model evaluations as n in the paired variance

    Here n counts pairs, whereas HE-VR-ANTV-003 counts model evaluations for the antithetic variance. Entering 10,000 evaluations for 5,000 patients per strategy in HE-EX-CRN-001 gives a variance of 9,000 where the correct value is 18,000, and it understates the standard error by about 29%.

  • Expecting a smaller standard error for one strategy's own mean

    Stout and Goldie state that common random numbers do not reduce stochastic variation within a single model run, as simulating a larger cohort might. With a standard deviation of GBP 30,000 and 5,000 patients, the standard error of one strategy's mean is about GBP 424 in both designs (derived), and only the difference gains.

Sources

  • Owen on common and independent random numbers for a difference

    Owen AB. Monte Carlo Theory, Methods and Examples. 2013. Chapter 8, section 8.6, equations 8.19 to 8.21, which define the common and independent estimators of the difference, give their sampling variances with rho as the correlation of f(X) and g(X), state that common random numbers are better when rho is positive and that a positive rho is not guaranteed, and set the assumptions on X and on n.

    View source →

  • Stout and Goldie on paired tests and within-run variation

    Stout NK, Goldie SJ. Keeping the noise down: common random numbers for disease simulation modeling. Health Care Manag Sci. 2008;11(4):399-406 (author manuscript read in PubMed Central, PMC2761656; published text not seen). Section Basics about Common Random Numbers, on no reduction of stochastic variation within a single run; section Statistical Considerations with CRN, on paired tests in place of two-sample tests; section Phase One: Design, on synchronising treatment draws.

    View source →

  • Murphy and colleagues on streams and separate treatment draws

    Murphy DR, Klein RW, Smolen LJ, Klein TM, Roberts SD. Using common random numbers in health care cost-effectiveness simulation modeling. Health Serv Res. 2013;48(4):1508-1525. Subsection Isolating Treatment Effects from Statistical Noise, on a separate stream for each source of variability as necessary but not sufficient; section Discussion, on separate random numbers for treatments acting by different mechanisms and on variance that can increase where several variables interact.

    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/sampling-variance-of-a-paired-strategy-difference-under-common-random-numbers