Signature
S_10 = S_00 * exp(b_1); S_01 = S_00 * exp(b_2); S_11 = S_00 * exp(b_1 + b_2); T = n_00 * S_00 + n_10 * S_10 + n_01 * S_01 + n_11 * S_11; AF_U1 = (n_10 * (S_10 - S_00) + n_11 * (S_11 - S_01)) / T; AF_L1 = (n_10 + n_11) * (S_10 - S_00) / T; AF_U2 = (n_01 * (S_01 - S_00) + n_11 * (S_11 - S_10)) / T; AF_L2 = (n_01 + n_11) * (S_01 - S_00) / T; AF_C = (n_10 * (S_10 - S_00) + n_01 * (S_01 - S_00) + n_11 * (S_11 - S_00)) / T
| Inputs | Definition | Unit |
|---|---|---|
S_00 | Predicted spending per person with neither condition, the scale factor c times exp(beta_0) of the exponential mean model | currency per person |
b_1 | Coefficient of the first condition, at least 0 | log of a ratio of means |
b_2 | Coefficient of the second condition, at least 0 | log of a ratio of means |
n_00 | Number of people with neither condition | people |
n_10 | Number of people with the first condition only | people |
n_01 | Number of people with the second condition only | people |
n_11 | Number of people with both conditions | people |
S_10 | Predicted spending per person with the first condition only | currency per person |
|---|---|---|
S_01 | Predicted spending per person with the second condition only | currency per person |
S_11 | Predicted spending per person with both conditions | currency per person |
T | Total predicted spending with conditions as observed | currency |
AF_U1 | Fall in spending when the first condition is removed first, over T | proportion |
AF_L1 | Fall in spending when the first condition is removed last, over T | proportion |
AF_U2 | Fall in spending when the second condition is removed first, over T | proportion |
AF_L2 | Fall in spending when the second condition is removed last, over T | proportion |
AF_C | Fall in spending when both conditions are removed at once, over T | proportion |
Function
Attributable cost estimation function by counterfactual prediction, removal order and extra stay
Maps the fitted coefficients of a spending model, a table of people by condition, or the hazards of a hospital multistate model to the spending attributable to a disease, condition or infection, each as a difference from a counterfactual that cannot be observed for the same people. HE-FM-ACE-001 compares two predictions for one person from a two-part regression, and the mean over people with the disease is the treated-mix average of HE-FM-ATE-002 with those differences as subgroup effects, while the total is HE-FM-COI-001. The attributable-fraction route is HE-FM-COI-002 for each condition, added by HE-FM-COI-003, with the fraction taken from the attributable fraction concept, so it has no separate record here. HE-FM-ACE-002 and HE-FM-ACE-003 deal with conditions that occur together, and HE-FM-ACE-004 gives the extra stay from a hospital infection, valued in bed days as in HE-FM-ALOS-006. Notation follows the Attributable Cost Estimation article.
Computational function
Computational function for upper, lower and redistributed fractions over a table of conditions
Takes a table of people by every combination of K conditions, the exponential mean coefficients and the spending of a person with no condition, and returns each condition's upper fraction, lower fraction and redistributed fraction with the combined fraction. It extends HE-FM-ACE-002 and HE-FM-ACE-003 from two conditions to the 2 to the power K classes of the complete cross-classification of Trogdon and colleagues, where the shares of equation (1) run over the conditions held by each class. The calculator line writes out three conditions; other sizes are in the Excel layout (three) and the R and Python code (any K).
Inputs and outputs:
S_0is predicted spending per person with no condition;b_1tob_3are the coefficients;n_000ton_111count people by class, the digits marking the first, second and third conditions;f_kis the factor exp(b_k) andw_kis f_k minus 1;Tis observed predicted spending;U_k,L_kandX_kare the upper, lower and redistributed fractions of condition k;A_Cis the combined fraction, all as proportions. Above the calculator's three conditions the code takesbas a list and, in Python,countsas a dictionary keyed by tuples of 0 and 1; in R,nis inexpand.gridorder with the first condition changing fastest.Assumption: The assumptions of HE-FM-ACE-002 and HE-FM-ACE-003 hold. The calculator line needs at least one positive coefficient in each pair of conditions it divides by; the code gives a class with no positive weight a share of 0, and such a class has no excess spending when its coefficients are 0.
Worked example (Three illustrative conditions): Illustrative table of 1,000 people. The upper fractions add to 38.63%, the lower to 27.64% and the redistributed to the combined 32.95%.
S_0 = 1000; b_1 = 0.7; b_2 = 0.4; b_3 = 0.2; n_000 = 500; n_100 = 100; n_010 = 150; n_001 = 80; n_110 = 40; n_101 = 30; n_011 = 50; n_111 = 50; f_1 = 2.01375; f_2 = 1.49182; f_3 = 1.22140; w_1 = 1.01375; w_2 = 0.49182; w_3 = 0.22140; T = 1491386.70; U_1 = 0.1954; L_1 = 0.1495; X_1 = 0.1808; U_2 = 0.1367; L_2 = 0.0956; X_2 = 0.1115; U_3 = 0.0542; L_3 = 0.0312; X_3 = 0.0372; A_C = 0.3295Worked example (Table 1 of Trogdon and colleagues as a three-condition table): The published table with an empty third condition. The upper fractions are 66.67% as published and the redistributed fractions 44.44% each, which add to the combined 88.89% (derived).
S_0 = 1; b_1 = 1.6094379; b_2 = 1.6094379; b_3 = 0; n_000 = 100; n_100 = 100; n_010 = 100; n_001 = 0; n_110 = 100; n_101 = 0; n_011 = 0; n_111 = 0; f_1 = 5; f_2 = 5; f_3 = 1; w_1 = 4; w_2 = 4; w_3 = 0; T = 3600; U_1 = 0.6667; L_1 = 0.2222; X_1 = 0.4444; U_2 = 0.6667; L_2 = 0.2222; X_2 = 0.4444; U_3 = 0; L_3 = 0; X_3 = 0; A_C = 0.8889Excel: Enter the eight classes in rows 2 to 9 with flags 0 or 1 in columns A, B and C (named FlagFirst, FlagSecond, FlagThird) and counts in column D (ClassCount). With SpendBase, CoefFirst, CoefSecond and CoefThird, cells WeightFirst, WeightSecond and WeightThird hold
=EXP(CoefFirst)-1and its like. Enter=SpendBase*EXP(A2*CoefFirst+B2*CoefSecond+C2*CoefThird)in E2 (ClassSpend),=D2*(E2-SpendBase)in F2 (ClassExcess),=A2*WeightFirst+B2*WeightSecond+C2*WeightThirdin G2, and=IF(G2=0,0,A2*WeightFirst/G2)in H2 (ShareFirstColumn), with like columns for the other two conditions, and fill down. TotalSpendCF holds=SUMPRODUCT(ClassCount,ClassSpend). For the first condition, UpperFirstCF holds=SUMPRODUCT(FlagFirst,ClassCount,ClassSpend)*(1-EXP(-CoefFirst))/TotalSpendCF, LowerFirstCF holds=SUMPRODUCT(FlagFirst,ClassCount)*SpendBase*WeightFirst/TotalSpendCFand CrossFirstCF holds=SUMPRODUCT(ClassExcess,ShareFirstColumn)/TotalSpendCF. CombinedCF holds=1-SUM(ClassCount)*SpendBase/TotalSpendCF. An empty table returns #DIV/0!.R:
removal_fractions <- function(b, S0, n) { K <- length(b); g <- as.matrix(expand.grid(rep(list(0:1), K))); f <- exp(g %*% b)[, 1]; T <- S0*sum(n*f); w <- exp(b)-1; den <- as.vector(g %*% w); up <- lo <- cross <- numeric(K); for (k in 1:K) { on <- g[, k] == 1; sh <- ifelse(den != 0, w[k]/den, 0); up[k] <- S0*sum(n[on]*f[on])*(1-exp(-b[k]))/T; lo[k] <- S0*w[k]*sum(n[on])/T; cross[k] <- S0*sum((n*(f-1)*sh)[on])/T }; list(upper = up, lower = lo, cross = cross, combined = 1-S0*sum(n)/T) }Called asremoval_fractions(c(log(5), log(5)), 1, rep(100, 4))it gives upper fractions of 0.6667, lower of 0.2222, cross of 0.4444 and a combined fraction of 0.8889; an empty table returns NaN.Python:
def removal_fractions(b, S0, counts): import math, itertools; K = len(b); w = [math.exp(x)-1 for x in b]; rows = [(c, math.exp(sum(x*y for x, y in zip(b, c)))) for c in itertools.product([0, 1], repeat=K)]; n = lambda c: counts.get(c, 0); T = S0*sum(n(c)*f for c, f in rows) or float('nan'); den = lambda c: sum(w[j] for j in range(K) if c[j]); share = lambda c, k: w[k]/den(c) if den(c) != 0 else 0; up = [S0*sum(n(c)*f for c, f in rows if c[k])*(1-math.exp(-b[k]))/T for k in range(K)]; lo = [S0*w[k]*sum(n(c) for c, f in rows if c[k])/T for k in range(K)]; cross = [S0*sum(n(c)*(f-1)*share(c, k) for c, f in rows if c[k])/T for k in range(K)]; return up, lo, cross, 1-S0*sum(n(c) for c, f in rows)/TStandard library only. Withb = [math.log(5)]*2,S0 = 1and 100 in each of the four classes it returns 0.6667, 0.2222, 0.4444 and 0.8889, and an empty dictionary returns nan rather than an error.Test (Redistributed fractions add to the combined fraction): With the first worked example, the three cross cells are compared with CombinedCF at a tolerance of 0.0001. Expected result TRUE. FALSE shows the upper cells in their place, which add to 0.3863 against 0.3295, and CrossFirstCF doubled (0.3616, a sum of 0.5103) or halved (0.0904, a sum of 0.2391). Excel check
=ABS(CrossFirstCF+CrossSecondCF+CrossThirdCF-CombinedCF)<0.0001Test (Published upper fraction): With the second worked example, UpperFirstCF is compared with 2,400 over 3,600, 0.6667, at a tolerance of 0.0005. Expected result TRUE. FALSE shows the lower fraction, 0.2222, and a doubled (1.3333) or halved (0.3333) cell. Excel check
=ABS(UpperFirstCF-0.6667)<0.0005Common error (Searching every removal order): Trogdon and colleagues count more than 3 million orderings for 10 conditions. The first and last removal bound each condition without searching them, so only one pass over the table is needed for each condition.
Common error (One redistribution share for every class): Equation (1) runs over the conditions a class holds. Using the three-condition share for the class holding the first two conditions in the first worked example leaves part of its excess spending unallocated, so the redistributed fractions add to 0.3226 against the combined 0.3295 (derived).
Source: Trogdon JG, Finkelstein EA, Hoerger TJ. Use of econometric models to estimate expenditure shares. Health Services Research. 2008;43(4):1442-1452. Section Recommendations, subsections Sequential Attributable Fractions and Complete Cross-Classification, equation (1), on 390 observed combinations of 1,024, and Table 2.
f_1 = exp(b_1); f_2 = exp(b_2); f_3 = exp(b_3); w_1 = f_1 - 1; w_2 = f_2 - 1; w_3 = f_3 - 1; T = S_0 * (n_000 + n_100 * f_1 + n_010 * f_2 + n_001 * f_3 + n_110 * f_1 * f_2 + n_101 * f_1 * f_3 + n_011 * f_2 * f_3 + n_111 * f_1 * f_2 * f_3); U_1 = S_0 * w_1 * (n_100 + n_110 * f_2 + n_101 * f_3 + n_111 * f_2 * f_3) / T; L_1 = S_0 * w_1 * (n_100 + n_110 + n_101 + n_111) / T; X_1 = S_0 * (n_100 * w_1 + n_110 * (f_1 * f_2 - 1) * w_1 / (w_1 + w_2) + n_101 * (f_1 * f_3 - 1) * w_1 / (w_1 + w_3) + n_111 * (f_1 * f_2 * f_3 - 1) * w_1 / (w_1 + w_2 + w_3)) / T; U_2 = S_0 * w_2 * (n_010 + n_110 * f_1 + n_011 * f_3 + n_111 * f_1 * f_3) / T; L_2 = S_0 * w_2 * (n_010 + n_110 + n_011 + n_111) / T; X_2 = S_0 * (n_010 * w_2 + n_110 * (f_1 * f_2 - 1) * w_2 / (w_1 + w_2) + n_011 * (f_2 * f_3 - 1) * w_2 / (w_2 + w_3) + n_111 * (f_1 * f_2 * f_3 - 1) * w_2 / (w_1 + w_2 + w_3)) / T; U_3 = S_0 * w_3 * (n_001 + n_101 * f_1 + n_011 * f_2 + n_111 * f_1 * f_2) / T; L_3 = S_0 * w_3 * (n_001 + n_101 + n_011 + n_111) / T; X_3 = S_0 * (n_001 * w_3 + n_101 * (f_1 * f_3 - 1) * w_3 / (w_1 + w_3) + n_011 * (f_2 * f_3 - 1) * w_3 / (w_2 + w_3) + n_111 * (f_1 * f_2 * f_3 - 1) * w_3 / (w_1 + w_2 + w_3)) / T; A_C = 1 - S_0 * (n_000 + n_100 + n_010 + n_001 + n_110 + n_101 + n_011 + n_111) / T
Try this function
Implementations
Excel
Upper and lower attributable fractions from named cells
With the counts in CountNeither, CountFirstOnly, CountSecondOnly and CountBoth, the spending of a person with neither condition in SpendNeither and the coefficients in CoefFirst and CoefSecond, the formulas fill SpendFirstOnly, SpendSecondOnly, SpendBoth and TotalSpendObserved, then UpperFractionFirst, LowerFractionFirst, UpperFractionSecond, LowerFractionSecond and CombinedFraction in that order. All counts blank or zero return #DIV/0!.
=SpendNeither*EXP(CoefFirst); =SpendNeither*EXP(CoefSecond); =SpendNeither*EXP(CoefFirst+CoefSecond); =CountNeither*SpendNeither+CountFirstOnly*SpendFirstOnly+CountSecondOnly*SpendSecondOnly+CountBoth*SpendBoth; =(CountFirstOnly*(SpendFirstOnly-SpendNeither)+CountBoth*(SpendBoth-SpendSecondOnly))/TotalSpendObserved; =(CountFirstOnly+CountBoth)*(SpendFirstOnly-SpendNeither)/TotalSpendObserved; =(CountSecondOnly*(SpendSecondOnly-SpendNeither)+CountBoth*(SpendBoth-SpendFirstOnly))/TotalSpendObserved; =(CountSecondOnly+CountBoth)*(SpendSecondOnly-SpendNeither)/TotalSpendObserved; =(CountFirstOnly*(SpendFirstOnly-SpendNeither)+CountSecondOnly*(SpendSecondOnly-SpendNeither)+CountBoth*(SpendBoth-SpendNeither))/TotalSpendObserved
Assumptions
Exponential mean for spending across two conditions
Predicted spending takes the form c exp(beta_0) exp(beta_1 d_1) exp(beta_2 d_2) that Trogdon and colleagues print, so a person with both conditions costs S_00 times both factors, with other covariates held fixed for each type. They note that least squares on log positive spending, nonlinear least squares and generalised linear models with a log link are all multiplicative, and that the same intuition carries to a two-part model.
Removal reclassifies people without changing their number
Removing a condition moves people to the type without it, as in Table 1 of Trogdon and colleagues, and all fractions are reported against spending with conditions as observed. The lower fraction predicts with and without the condition after every other condition has been set to zero.
Fractions read as reductions and not as shares
Each fraction says how much lower spending would be without the condition, all else constant. Trogdon and colleagues state that the fractions can be read as shares only if the underlying function is additively separable or the conditions are mutually exclusive. With one coefficient negative, the other positive and people holding both conditions, the condition removed first gives the smaller fraction (derived), so the bound labels need both coefficients at 0 or above.
Worked examples
Two-condition table of Trogdon and colleagues
Table 1 of Trogdon and colleagues, 100 people of each type spending 1, 5, 5 and 25 (c = 1, beta_0 = 0, both coefficients the natural log of 5). Spending is 3,600 and removing either condition first gives 2,400 or 67%, summing to 133%. The lower bound of 22.2% and the combined fraction of 88.9% follow from the same table (derived); the table's 400 of other spending is 11.1%.
n_00 = 100; n_10 = 100; n_01 = 100; n_11 = 100; S_00 = 1; b_1 = 1.6094379; b_2 = 1.6094379; S_10 = 5; S_01 = 5; S_11 = 25; T = 3600; AF_U1 = 0.6667; AF_L1 = 0.2222; AF_U2 = 0.6667; AF_L2 = 0.2222; AF_C = 0.8889
Illustrative two-condition table with unequal coefficients
Illustrative counts and coefficients for 1,000 people. The first condition gets 13.88% as an upper bound and 11.92% as a lower bound, the second 9.67% and 7.71%. Together the conditions account for 21.59%, less than the 23.55% the upper fractions add to.
n_00 = 700; n_10 = 100; n_01 = 150; n_11 = 50; S_00 = 1000; b_1 = 0.7; b_2 = 0.4; S_10 = 2013.75; S_01 = 1491.82; S_11 = 3004.17; T = 1275357.28; AF_U1 = 0.1388; AF_L1 = 0.1192; AF_U2 = 0.0967; AF_L2 = 0.0771; AF_C = 0.2159
Two mutually exclusive conditions in the spending table
Limiting case with nobody holding both conditions. Upper and lower fractions coincide, at 12.40% and 6.02%, and they add to the combined 18.42%, the mutually exclusive case in which Trogdon and colleagues say fractions can be read as shares.
n_00 = 700; n_10 = 150; n_01 = 150; n_11 = 0; S_00 = 1000; b_1 = 0.7; b_2 = 0.4; S_10 = 2013.75; S_01 = 1491.82; S_11 = 3004.17; T = 1225836.61; AF_U1 = 0.1240; AF_L1 = 0.1240; AF_U2 = 0.0602; AF_L2 = 0.0602; AF_C = 0.1842
Common errors
Upper attributable fractions summed across conditions
The standard fractions double-count joint spending. In Table 1 of Trogdon and colleagues they sum to 133%, and to 144% once the other spending is added. For prescription spending on 10 conditions in their Table 2 they sum to 105.45% while removing all 10 at once gives 70.36%. Trogdon and colleagues conclude that condition-specific shares from multiplicative models should not be summed.
Double counting assumed to need correlated conditions
Trogdon and colleagues note that double counting occurs even when conditions are independent, as in their Table 1, because the conditions only need to occur jointly. The form of HE-FM-PR-003, used separately for two independent conditions with exp(b) in the place of PR, gives the upper fractions (derived) and so carries the same excess, 133% against 88.9% in that table.
Lower attributable fraction divided by spending after removal
Trogdon and colleagues report sequential reductions relative to initial predicted spending. Dividing the 800 lower-bound reduction of Table 1 by the 1,200 of spending left after the other condition is removed gives 66.7% instead of 22.2% (derived), and such fractions do not add up against any single total.
One bound reported as the attributable fraction of a condition
The two bounds can be far apart. Trogdon and colleagues report that lower-bound fractions in their Table 2 fall by more than 50% on average against the upper-bound fractions, and they recommend reporting both bounds. One figure alone does not say which removal order it assumes.
Sources
Trogdon and colleagues on standard and sequential attributable fractions of spending
Trogdon JG, Finkelstein EA, Hoerger TJ. Use of econometric models to estimate expenditure shares. Health Services Research. 2008;43(4):1442-1452. Section Attributable Fractions: Definitions and Properties, the unnumbered expression for the fraction and Table 1 (67% each, 133% summed, 144% with other expenditures); section Multiplicative Models with Exponential Means, the unnumbered exponential mean expression; section Recommendations, subsection Sequential Attributable Fractions, on removing a condition first or last and on removing all at once; Table 2, 105.45, 47.14 and 70.36.
Eide and Gefeller on sequential and average attributable fractions
Eide GE, Gefeller O. Sequential and average attributable fractions as aids in the selection of preventive strategies. Journal of Clinical Epidemiology. 1995;48(5):645-655. Outlines a stepwise calculation of attributable fractions to study the effect on risk of disease of preventing several exposures one at a time in different orderings, and introduces sequential and average attributable fractions.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0
