Delta-method variance of a function of two correlated estimates

Expands the gradient form of the delta method for two estimated inputs into three terms, one for each input variance and one for their covariance. The two partial derivatives are entered as numbers, so the same line serves any differentiable function of the pair. With derivatives 1 / Delta_E and -Delta_C / Delta_E^2 it returns the squared standard error of the ICER in HE-FM-AN-002; with derivatives lambda and -1 it returns the exact variance of net benefit in HE-FM-AN-004. The covariance term takes its sign from the covariance and from both derivatives. With more than two inputs the same rule is the quadratic form of the gradient and the covariance matrix, which HE-CF-DELM-001 computes.

Signature

Var_g = g_X^2 * Var_X + g_Y^2 * Var_Y + 2 * g_X * g_Y * Cov_XY; SE_g = sqrt(Var_g)
Inputs
InputsDefinitionUnit
g_XPartial derivative of g with respect to the first input, evaluated at the estimates; any real numberoutput unit per unit of the first input
Var_XSampling variance of the first estimate, zero or abovefirst input unit squared
g_YPartial derivative of g with respect to the second input, evaluated at the estimates; any real numberoutput unit per unit of the second input
Var_YSampling variance of the second estimate, zero or abovesecond input unit squared
Cov_XYSampling covariance of the two estimates, with square at most Var_X times Var_Y; a correlation must first be multiplied by both standard errorsfirst input unit times second input unit
Output
Var_gApproximate sampling variance of g at the two estimates, exact when g is linear in themoutput unit squared
SE_gApproximate standard error of g at the two estimates, the square root of Var_goutput unit

Function

First-order delta method variance of a function of estimated parameters

Takes a differentiable function g, its estimated inputs and their variances and covariances, and returns an approximate sampling variance and standard error for the output, by replacing g with its tangent at the estimates. Its result feeds the Wald interval of HE-FM-AN-001. The live ICER case is HE-FM-AN-002, with its Fieller alternative HE-FM-AN-003 and all three intervals in HE-CF-AN-001; net benefit, which is linear, is HE-FM-AN-004; the log risk ratio variance of one trial is HE-FM-PWMA-001, which equals the delta-method form Zepeda-Tello and colleagues derive (eq. 30, equal on a 144-point grid, derived); the variance of Hedges' g in HE-FM-HEDG-002 takes the same form with its correction factor J as a constant slope (derived). Those records fix the function, and this package holds the general rule with the slope or gradient as an input, plus one survival use. The second-order approximation to the mean of g is HE-FM-EV-002. Notation follows the Delta Method article.

Computational function

  • Computational function for a numerical delta-method standard error of a Weibull survival estimate by central differences

    Computes a delta-method standard error when the analyst holds a model function and a fitted covariance matrix and has no derivatives to hand. Each partial derivative comes from a central difference, the function's value one step above the estimate less its value one step below over twice the step, and the gradient then enters the quadratic form that HE-FM-DELM-002 writes out for two inputs. The calculator line runs the two-parameter Weibull survival function that Kearns and colleagues list in their Table 1, whose exponent is minus H_t of HE-FM-CUMH-003. The Excel, R and Python below take any number of parameters. Stata's nlcom works on the same lines, computing numerical derivatives and the product of the derivative matrix, the covariance matrix and its transpose. The central difference itself is a standard numerical device and is checked here against the analytic gradient (derived).

    Inputs and outputs: lambda: Weibull scale parameter, above zero. Unit: per year to the power gamma.; gamma: Weibull shape parameter, above zero. Unit: none.; t: Time at which survival is read, above zero. Unit: years.; h: Step for the central difference, above zero and small against each parameter. Unit: as the parameter.; V_1, V_2: Sampling variances of lambda and gamma. Unit: parameter unit squared.; C_12: Their sampling covariance. Unit: product of the parameter units.; S_hat: Survival at t. Unit: proportion.; S_1u, S_1d, S_2u, S_2d: Survival with one parameter moved one step up or down. Unit: proportion.; g_1, g_2: Numerical partial derivatives of survival. Unit: proportion per parameter unit.; Var_S: Delta-method variance of S_hat. Unit: proportion squared.; SE_S: Its standard error. Unit: proportion.

    Assumption: The function is differentiable at the estimates and smooth across one step either side. V_1, V_2 and C_12 describe the same parameters that the function takes, so a covariance matrix reported for log parameters needs a function written in log parameters. Any interval from SE_S uses HE-FM-AN-001 and can fall outside the range of a probability, so the article's advice on the log or logit scale applies.

    Worked example (Illustrative Weibull survival at 5 years): All inputs are illustrative. lambda = 0.1; gamma = 1.2; t = 5; h = 0.0001; V_1 = 0.0004; V_2 = 0.01; C_12 = -0.001; S_hat = 0.5016; S_1u = 0.501298; S_1d = 0.50199; S_2u = 0.501588; S_2d = 0.5017; g_1 = -3.4607; g_2 = -0.557; Var_S = 0.00404; SE_S = 0.0635

    Excel: Named cells hold ScaleLambda, ShapeGamma, TimePoint, StepH, VarScale, VarShape and CovScaleShape. SurvAboveScale is =EXP(-(ScaleLambda+StepH)*TimePoint^ShapeGamma) and SurvBelowScale is =EXP(-(ScaleLambda-StepH)*TimePoint^ShapeGamma). SurvAboveShape is =EXP(-ScaleLambda*TimePoint^(ShapeGamma+StepH)) and SurvBelowShape is =EXP(-ScaleLambda*TimePoint^(ShapeGamma-StepH)). GradScale is =(SurvAboveScale-SurvBelowScale)/(2*StepH), GradShape is =(SurvAboveShape-SurvBelowShape)/(2*StepH), VarSurvival is =GradScale^2*VarScale+GradShape^2*VarShape+2*GradScale*GradShape*CovScaleShape and SeSurvival is =SQRT(VarSurvival). With more parameters, keep the gradient in a column range GradVector and the matrix in CovMatrix, and the variance is =SUMPRODUCT(MMULT(CovMatrix,GradVector),GradVector), which needs no array entry. A blank StepH returns #DIV/0!.

    R: delta_numeric <- function(g, theta, V, h = 1e-4) { V <- as.matrix(V); k <- length(theta); if (h <= 0) stop("h must be positive"); if (k < 1 || nrow(V) != k || ncol(V) != k) stop("V must be k by k"); grad <- numeric(k); for (i in seq_len(k)) { e <- numeric(k); e[i] <- h; grad[i] <- (g(theta+e)-g(theta-e))/(2*h) }; v <- drop(t(grad) %*% V %*% grad); list(estimate = g(theta), grad = grad, var = v, se = sqrt(v)) }; surv <- function(p) exp(-p[1]*5^p[2]); delta_numeric(surv, c(0.1, 1.2), matrix(c(0.0004, -0.001, -0.001, 0.01), 2))$se returns 0.06354. A single parameter with a 1 by 1 matrix runs, a zero matrix returns a standard error of 0, a step of zero or an empty parameter vector stops with a message, and a matrix that gives a negative variance returns NaN with a warning.

    Python: def delta_numeric(g, theta, V, h=1e-4): import math; k = len(theta); assert h > 0 and k >= 1 and len(V) == k and all(len(r) == k for r in V); grad = [(g([x+h*(i == j) for j, x in enumerate(theta)])-g([x-h*(i == j) for j, x in enumerate(theta)]))/(2*h) for i in range(k)]; v = sum(grad[i]*V[i][j]*grad[j] for i in range(k) for j in range(k)); return {"estimate": g(theta), "grad": grad, "var": v, "se": math.sqrt(v)} After import math in the calling code, called with lambda p: math.exp(-p[0]*5**p[1]), [0.1, 1.2] and [[0.0004, -0.001], [-0.001, 0.01]] it returns the same values as the R function. The same edge cases run the same way, except that a step of zero or an empty vector raises AssertionError and a negative variance raises ValueError.

    Test (Standard error cell against the hand value): With the inputs of the worked example, =ABS(SeSurvival-0.0635)<0.00005 returns TRUE. A gradient divisor of 4*StepH halves the cell to 0.0318 and returns FALSE, and doubling the cell to 0.1271 also returns FALSE.

    Test (Numerical slope against the analytic slope): The analytic derivative of survival with respect to the scale is minus t to the power gamma times survival (derived), so =ABS(GradScale+TimePoint^ShapeGamma*EXP(-ScaleLambda*TimePoint^ShapeGamma))<0.00001 returns TRUE at the worked example. A forward difference with the divisor 2*StepH gives -1.7297 and FALSE, and doubling or halving GradScale also gives FALSE.

    Common error (Step size): A step that is large against the parameter misstates the slope. At the worked example, h of 0.05 gives a standard error of 0.0644 against 0.0635, and h of 0.5, above lambda itself, gives 0.2930. A step of 1E-13 loses digits to rounding and gives 0.06353 (all checked here).

    Common error (Kink at the estimate): The central difference returns a number at a kink, so nothing warns that the differentiability assumption has failed. At a tie in the larger of two equal inputs each slope reads 0.5, and the absolute value at zero reads a slope of 0 and a standard error of 0 (both derived, checked here). The reciprocal at zero returns an infinite estimate in R and raises ZeroDivisionError in Python.

    Common error (Scale of the covariance matrix): A fit can report its covariance matrix for transformed parameters, as with the log dispersion parameter lnalpha in the nlcom manual. Using such a matrix with a gradient taken in the untransformed parameters gives a wrong standard error with no warning, so the function passed to the procedure must take the parameters the matrix describes (derived).

    Source: StataCorp. nlcom, Nonlinear combinations of parameters. Stata Base Reference Manual, entry [R] nlcom, as posted on stata.com and read on 7 November 2026. Sections Options, on numerical derivatives under iterate, and Methods and formulas, on the variance G V G' with G the matrix of derivatives. Kearns B, Stevens J, Ren S, Brennan A. How uncertain is the survival extrapolation? A study of the impact of different parametric survival models on extrapolated uncertainty about hazard functions, lifetime mean survival and cost effectiveness. PharmacoEconomics. 2020;38(2):193-204. Table 1 for the Weibull survival function and the section Estimating Uncertainty About Hazard and Survival Estimates for the delta method with parametric survival models.

    S_hat = exp(-lambda * t^gamma); S_1u = exp(-(lambda + h) * t^gamma); S_1d = exp(-(lambda - h) * t^gamma); S_2u = exp(-lambda * t^(gamma + h)); S_2d = exp(-lambda * t^(gamma - h)); g_1 = (S_1u - S_1d) / (2 * h); g_2 = (S_2u - S_2d) / (2 * h); Var_S = g_1^2 * V_1 + g_2^2 * V_2 + 2 * g_1 * g_2 * C_12; SE_S = sqrt(Var_S)

Try this function

Implementations

  • Excel

    Two-input delta-method variance and standard error from named cells

    With the derivatives in GradFirst and GradSecond, the variances in VarFirst and VarSecond and the covariance in CovPair, the first formula goes in a cell named VarFunction and the second in SeFunction. A blank cell counts as 0, so an empty CovPair silently assumes independence. An inconsistent covariance can make VarFunction negative, and SeFunction then returns #NUM!.

    =GradFirst^2*VarFirst+GradSecond^2*VarSecond+2*GradFirst*GradSecond*CovPair; =SQRT(VarFunction)

Assumptions

  • Function differentiable in both inputs at the estimates

    Both partial derivatives exist at the estimates and describe g well over the plausible range of the pair. A ratio has an uncertain denominator, so the ICER case carries the further condition HE-AS-AN-003 on the effect difference.

  • Variances and covariance from one joint analysis of the two estimates

    Var_X, Var_Y and Cov_XY describe the same pair of estimators, for example costs and effects on the same patients, or coefficients from one regression whose covariance matrix is returned by the fit. With a valid covariance, whose square is at most Var_X times Var_Y, Var_g cannot be negative (derived, 0 negatives on a 2,205-point grid). A covariance taken from another study can break that bound.

  • Large-sample normality of the pair for a Wald interval

    A Wald interval from SE_g relies on the two estimates being jointly asymptotically normal, which Zepeda-Tello and colleagues give as the basis of the method. Small trials and rare events weaken it.

Worked examples

  • ICER gradient route to the article's variance of 69,000,000

    From the article, with illustrative inputs, an incremental cost of GBP 2,000 (standard error GBP 500) and an incremental effect of 0.10 QALYs (standard error 0.04), with a correlation of 0.25, give a covariance of 5. The derivatives at the estimates are 10 for cost and -200,000 for effect. The three terms are 25,000,000, 64,000,000 and -20,000,000, and the standard error of GBP 8,306.62 equals SE_R of HE-FM-AN-002. The Wald interval of HE-FM-AN-001 is about GBP 3,719 and GBP 36,281, whereas HE-FM-AN-003 gives about GBP 9,335 and GBP 84,499 per QALY.

    g_X = 10; g_Y = -200000; Var_X = 250000; Var_Y = 0.0016; Cov_XY = 5; Var_g = 69000000; SE_g = 8306.62
  • Linear net benefit as the exact limiting case of the two-input delta method

    From the article, with illustrative inputs, net benefit at GBP 25,000 per QALY has derivative 25,000 for effect and -1 for cost, both constant. The variance of 1,000,000 and standard error of GBP 1,000 are exact and equal SE_INB of HE-FM-AN-004, since no linearisation is involved.

    g_X = 25000; g_Y = -1; Var_X = 0.0016; Var_Y = 250000; Cov_XY = 5; Var_g = 1000000; SE_g = 1000
  • ICER gradient route with the covariance set to zero

    The first example with the covariance removed. The variance rises to 89,000,000 and the standard error to GBP 9,433.98, about 14% above the value with the covariance (derived), so independence is a substantive assumption for costs and effects measured on the same patients.

    g_X = 10; g_Y = -200000; Var_X = 250000; Var_Y = 0.0016; Cov_XY = 0; Var_g = 89000000; SE_g = 9433.98
  • Product of mean utility and mean survival in the two-input delta method

    A QALY estimate equal to a mean utility of 0.7 times a mean survival of 4 years, a function that is neither a ratio nor linear. All inputs are illustrative, with independent estimates, standard errors of 0.02 and 0.4, and derivatives 4 for utility and 0.7 for survival. The first-order variance is 0.0848. The exact variance of a product of independent estimates adds Var_X times Var_Y, here 0.000064, which is the term the tangent line drops (derived).

    g_X = 4; g_Y = 0.7; Var_X = 0.0004; Var_Y = 0.16; Cov_XY = 0; Var_g = 0.0848; SE_g = 0.2912

Common errors

  • Dropping the covariance term between costs and effects

    In the article's example the covariance term removes 20,000,000 from the variance, so leaving it out overstates the standard error at GBP 9,433.98 against GBP 8,306.62, about 14% (derived). With a negative covariance the same omission would understate it, because the sign of the term depends on the covariance and on both derivatives.

  • Fixing the sign of the covariance term without checking the derivatives

    The minus sign in the ICER variance comes from the negative derivative with respect to the effect. Writing a plus sign in the ICER example gives a variance of 109,000,000 and a standard error of GBP 10,440.31 against GBP 8,306.62. Entering the signed derivatives in the general form avoids the slip.

  • Entering a correlation in place of a covariance

    Cov_XY is a covariance. Entering the correlation 0.25 in place of the covariance of 5 in the ICER example makes the third term -1,000,000 instead of -20,000,000, and the standard error GBP 9,380.83 against GBP 8,306.62 (derived).

  • Taking a delta-method ICER interval as adequate because the variance is correct

    A correct first-order variance still gives a symmetric interval around the ratio. In the article's example its upper limit of about GBP 36,281 is less than half of the Fieller limit of about GBP 84,499 from HE-FM-AN-003, in line with the underestimated upper limit in HE-SR-AN-003. HE-ER-AN-005 makes the same point on the live ICER example, and HE-ER-AN-003 covers the case where the effect difference is not significant.

Sources

  • Zepeda-Tello and colleagues on the gradient form and the ratio of two means

    Zepeda-Tello R, Schomaker M, Maringe C, Smith MJ, Belot A, Rachet B, Schnitzer ME, Luque-Fernandez MA. The Delta-method and influence function in medical statistics: a reproducible tutorial. arXiv preprint 2206.15310v1; 30 June 2022. Preprint section 3.3 gives the gradient of a ratio of two means as 1 over the denominator and minus the numerator over the squared denominator, and eq. 28 gives the three-term variance with its covariance term, written for per-observation variances with a factor 1/n. The records here use the variance of each estimate, so that factor is already inside Var_X, Var_Y and Cov_XY. Preprint section 3.8, eq. 36, gives the variance of a function of regression coefficients as the gradient times the covariance matrix times the gradient.

    View source →

  • Feiveson on the vector form of the delta method

    Feiveson AH. Explanation of the delta method. Stata FAQ. College Station, TX: StataCorp; December 1999, minor revisions May 2005, updated June 2017. The FAQ extends the result to vector-valued functions of random vectors as Var(G(X)) = G'(mu) Var(X) [G'(mu)]T, with Var(X) the variance-covariance matrix and G'() the matrix of first derivatives. The two-input expression is that product written out for one output and two inputs (derived).

    View source →

  • StataCorp manual entry for nlcom on numerical derivatives and the variance formula

    StataCorp. nlcom, Nonlinear combinations of parameters. Stata Base Reference Manual, entry [R] nlcom, as posted on stata.com and read on 7 November 2026. Section Options, under iterate, refers to numerical derivatives of the transformation with respect to the original parameters, and section Methods and formulas gives the estimated variance as G V G' with G the matrix of derivatives and V the variance-covariance matrix of the estimates. HE-CF-DELM-001 draws on it.

    View source →

Canonical Identity

Stable URI · Machine-readable · Resolvable · CC BY 4.0

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/delta-method-variance-of-a-function-of-two-correlated-estimates

Delta-method variance of a function of two correlated estimates | HealthEconomics.wiki