Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Control variate adjustment of a Monte Carlo estimate using an output of known mean

v(Y_i, X_i, mu_X, c_f, c_h) = (mu_hat, b_hat, SE_reg, b_opt, Var_opt, R_eff)

Takes a target output and a control output from the same n independent replications of a simulation, the known expected value of the control and the computing cost of each, and returns the adjusted estimate of the expected target with its standard error, the coefficient that scales the correction and the ratio that shows whether the control repays its cost. In the article's example the survival times come from HE-FM-DES-001 and the discounted life years take the form of HE-FM-YLL-003 with a simulated survival time in place of its L. Antithetic sampling (HE-FM-ANTV-001) changes how the draws are made, whereas these records leave the sampling unchanged and work on the outputs after the run. Notation follows the Control Variates article.

  • Control variate regression estimator at a fixed coefficient

    mu_b = Y_bar - b * (X_bar - mu_X)

    Corrects the plain mean of a target output using a control from the same replications whose expected value is known. The gap X_bar minus mu_X shows how far the run has drifted by chance, and subtracting b times that gap moves the estimate back towards the expected target. Because the expected value of X_bar equals mu_X, the estimate is unbiased for any fixed b, with b at 0 giving the plain Monte Carlo mean and b at 1 the difference estimator. The expression has the same linear form as HE-FM-MREG-005, whose inputs are a fitted treatment effect, an interaction coefficient, the covariate value of the decision population and the mean covariate of the trials; here Y_bar and X_bar are simulated means and mu_X is the known expectation of the control.

  • Variance-minimising control coefficient, minimum variance and equivalent replications

    b_opt = Cov_YX / Var_X; rho = Cov_YX / sqrt(Var_X * Var_Y); Var_opt = Var_Y / n * (1 - rho^2); SE_plain = sqrt(Var_Y / n); SE_opt = sqrt(Var_opt); n_eq = n / (1 - rho^2)

    Gives the coefficient that minimises the variance of HE-FM-CONV-001 and the variance it then reaches, the variance of one target output over n multiplied by 1 minus rho squared. The factor is never above 1, so with this coefficient the estimate is never worse than the plain mean, and a negatively correlated control helps as much as a positively correlated one since b_opt takes the sign of the covariance. SE_plain is the form of HE-FM-ANTV-002 with one observation per replication, and the factor differs from the 1 plus within-pair correlation of HE-FM-ANTV-001 and HE-FM-ANTV-003, which concern antithetic pairs. With several controls the asymptotic variance is multiplied by 1 minus R squared, which equals 1 minus rho squared for one control. The equivalent replications n_eq are the plain replications that would match the precision of n adjusted ones, the reciprocal of the same factor times n (derived).

  • Efficiency ratio and minimum correlation for a control variate with its computing cost

    R_eff = (1 - rho^2) * (c_f + c_h) / c_f; rho_min = sqrt(c_h / (c_f + c_h))

    A control multiplies the variance by 1 minus rho squared and the cost per replication by c_f plus c_h over c_f. R_eff is the product of the two, the computing time needed for a given precision relative to the plain estimate at the coefficient of HE-FM-CONV-002 (derived), so the control repays its cost when R_eff is below 1. Rearranged, that requires the absolute correlation to exceed rho_min. With several controls R squared replaces rho squared and the condition takes the same form with c_h as their combined extra cost, so J controls each costing as much as the model need R squared above J over J plus 1.

  • Control variate estimate and intercept standard error by regression on the centred control

    b_hat = S_XY / S_XX; mu_hat = Y_bar - b_hat * (X_bar - mu_X); RSS = S_YY - b_hat * S_XY; SE_reg = sqrt(RSS / (n - 2) * (1 / n + (X_bar - mu_X)^2 / S_XX))

    Applies when the optimal coefficient is not known. The slope b_hat from the run's sums is ordinary least squares with one regressor. It takes the form of the matrix step in HE-CF-CJA-001, which computes it only for dummy-coded attributes, and the same form holds for one numeric control (derived). The estimate mu_hat is HE-FM-CONV-001 evaluated at b_hat. Regressing the target on the control with its known mean subtracted gives the same slope with mu_hat as the fitted intercept, and SE_reg is the usual standard error of that intercept (derived, and checked against R lm). The result carries a small bias from fitting b on the same run, of order 1 over n against a random error of order 1 over the root of n.

This set of formulae 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/concept/control-variates/formulae