Functions & Formulae

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

Autoregressive correlation function for repeated health measurements

Corr(Y_ij, Y_ik) = rho^abs(j - k); Var(sum_j w_j * Y_ij) = sigma2 * sum_j sum_k w_j * w_k * rho^abs(j - k)

Maps the correlation between adjacent measurements on the same patient, and the distance between two measurements, to the correlation between them under a first-order autoregressive (AR(1)) structure. The correlation falls by the same factor with each step, so one parameter describes the whole within-patient correlation matrix. Combined with a common variance at every visit, the structure gives the variance of any weighted total or difference of the repeated measurements, such as a trial QALY total or a change in utility from baseline. In time-series notation the same pattern comes from the error process e_t = rho * e_(t-1) + u_t, which for a stationary series gives a correlation of rho^s between errors s periods apart.

  • AR(1) correlation between measurements s visit steps apart

    r = rho^s

    Gives the correlation between two outcomes of the same patient, for example utilities or costs, measured s equally spaced visits apart, when the correlation between adjacent visits is rho. With rho between 0 and 1 the correlation is highest for adjacent visits and falls geometrically towards zero as the gap grows. For four visits the correlation matrix has 1 on the diagonal, rho beside it, then rho^2 and rho^3 in the corners.

  • Continuous-time AR(1) correlation for unequally spaced visits

    r = phi^d

    Uses elapsed time instead of visit steps, so a 3-month gap and a 6-month gap receive different correlations. phi is the correlation between two measurements one time unit apart and d is the elapsed time between them in that unit. With equally spaced visits it reduces to HE-FM-AR1-001, with rho equal to phi raised to the visit interval.

  • Variance of a three-visit QALY total under AR(1) correlation

    Var_Q = sigma2 * (w_1^2 + w_2^2 + w_3^2 + 2 * (w_1 * w_2 * rho + w_2 * w_3 * rho + w_1 * w_3 * rho^2))

    Gives the variance of a patient's 12-month QALY total, calculated by the trapezium rule from utilities at baseline, 6 and 12 months, when the utilities share a common variance sigma2 and follow AR(1) correlation with adjacent-visit correlation rho. It is the general double sum, sigma2 times the sum over all pairs of visits of w_j * w_k * r_jk, written out for three visits: the squared weights, plus twice the cross-products for the two adjacent pairs at rho and for the outer pair at rho^2.

  • Variance of a change between two visits under AR(1) correlation

    Var_D = 2 * sigma2 * (1 - rho^s)

    Gives the variance of the difference between a patient's outcomes at two visits s steps apart, such as the change in utility from baseline to 12 months, when both visits share a common variance sigma2 and the correlation follows AR(1). Because the correlation falls with distance, the variance of a change grows with the gap between the visits, which is where the choice of correlation structure matters most.