A simulated dataset of 96 LifeContract pairs registered in WaszKrak megapolis, containing the MedScore of each partner and their joint annual healthcare expenditure in WaszKrak credits. The dataset is designed to illustrate simple linear regression, the asymmetry of the regression model, confidence and prediction intervals, and the Box-Cox transformation for non-linear relationships.
What is a LifeContract?
In WaszKrak (2047), the legal institution of marriage was replaced by the algorithmically generated LifeContract — a resource-sharing agreement between two registered citizens, optimised by QuantumCorp's LifeCalc engine for joint healthcare allocation, credit access, and district reclassification eligibility. A LifeContract can be entered into with any other citizen: a friend, a colleague, a neighbour. Standard durations are 3, 5, or 10 years with an option to renew.
TierCare treats LifeContract Partners as a single allocation unit. Their MedScores are combined into a Shared Health Index — a weighted average that determines the pair's joint priority in the healthcare queue.
Contract Partners A and B
The contract designates two roles: Contract Partner A and Contract Partner B. Officially, the assignment is described as arbitrary. In practice, analysis of registration records shows that Partner A is the individual with the higher MedScore at time of signing in 94.3% of cases. The Shared Health Index weights Partner A's MedScore at 0.62 and Partner B's at 0.38 — a fact encoded in the TierCare allocation model but absent from the contract documentation.
The contract is nominally symmetric. The algorithm is not.
What is MedScore?
MedScore is a continuous index (0–200, approximately Gaussian) computed weekly by SynBio's TierCare diagnostic system from neural implant telemetry, biochemical markers, genetic risk profile, and historical healthcare utilisation. Higher values indicate better predicted health outcomes and lower expected healthcare costs. MedScore determines eligibility for TierCare treatment tiers, access to SynthOrgan transplants, and — through the Shared Health Index — the pair's joint allocation priority.
Statistical design
The dataset was used to investigate the relationship between the MedScores of the two partners within a LifeContract pair. The analysis proceeds in two stages:
Stage 1 — Partner MedScore correlation and simple regression. The MedScores of Partner A and Partner B are positively correlated (r ≈ 0.74): pairs tend to form within the same district, socioeconomic bracket, and statistical future. Simple regression of Partner B's MedScore on Partner A's MedScore — or vice versa — illustrates that the choice of response variable is not symmetric, even when the underlying relationship is.
Stage 2 — Healthcare expenditure and Box-Cox transformation.
Annual healthcare expenditure (health_expenses) is regressed on
MedScore. The relationship is not linear: expenditure explodes at the
low end of MedScore and flattens at the high end, producing a curve
that pretends to be a line. A Box-Cox profile log-likelihood identifies
lambda close to zero, justifying a log transformation of the response.
The transformed model is well-behaved; back-transformed predictions
reveal the exponential gap between low- and high-MedScore citizens.
Format
A data frame with 96 rows and 3 variables:
- partner_a
Numeric. MedScore of Contract Partner A at the time of the most recent TierCare assessment (0–200 scale, approximately Gaussian with mean ≈ 170 and SD ≈ 12). Partner A is, in 94.3% of registered pairs, the individual with the higher MedScore at contract signing. MedScore reflects predicted health outcomes and determines the pair's joint TierCare priority through the Shared Health Index (weight 0.62 for Partner A).
- partner_b
Numeric. MedScore of Contract Partner B at the time of the most recent TierCare assessment (0–200 scale). Partner B typically has a lower MedScore than Partner A within the same pair (weight 0.38 in the Shared Health Index). The positive correlation between
partner_aandpartner_b(r ≈ 0.74) reflects assortative pairing within districts and socioeconomic brackets, amplified by the algorithmic incentive structure of the LifeContract registration system.- health_expenses
Numeric. Joint annual healthcare expenditure for the pair in WaszKrak credits (strictly positive, heavy right tail). Expenditure is driven primarily by Partner B's MedScore — the lower-scoring partner generates the majority of healthcare costs. The relationship between MedScore and expenditure is non-linear: a Box-Cox transformation with lambda ≈ 0 (log transformation) is required to satisfy the assumptions of linear regression. After log-transformation, the model reads: \(\ln(\text{expenditure}) = 8.14 - 0.043 \times \text{MedScore}\).
Source
Simulated dataset generated by data-raw/generate_medscore.R.
The data structure is based on the chapters "Strong Enough" and
"The Shape of Cost" in
Equations from District 7: A Practical Guide to Linear Models
(BetaBit StatPunk universe). All values are fictional.
References
Box, G. E. P. and Cox, D. R. (1964). An analysis of transformations. Journal of the Royal Statistical Society, Series B, 26, 211–252.
Examples
data(medscore)
#> Warning: data set ‘medscore’ not found
# Basic summary
summary(medscore)
#> Error: object 'medscore' not found
# Partner MedScore correlation
cor(medscore$partner_a, medscore$partner_b)
#> Error: object 'medscore' not found
# Scatter plot of partner MedScores
plot(partner_b ~ partner_a, data = medscore,
xlab = "Partner A MedScore",
ylab = "Partner B MedScore",
main = "LifeContract pair MedScores (n = 96)")
#> Error in eval(m$data, eframe): object 'medscore' not found
# Simple regression: Partner A predicts Partner B
model1 <- lm(partner_b ~ partner_a, data = medscore)
#> Error in eval(mf, parent.frame()): object 'medscore' not found
summary(model1)
#> Error: object 'model1' not found
# Prediction interval for Partner B when Partner A = 170
predict(model1,
newdata = data.frame(partner_a = 170),
interval = "prediction",
level = 0.95)
#> Error: object 'model1' not found
# Note: regression is not symmetric
model2 <- lm(partner_a ~ partner_b, data = medscore)
#> Error in eval(mf, parent.frame()): object 'medscore' not found
coef(model1) # slope ≠ 1 / coef(model2)["partner_b"]
#> Error: object 'model1' not found
# Healthcare expenditure: non-linear relationship
plot(health_expenses ~ partner_b, data = medscore,
xlab = "Partner B MedScore",
ylab = "Healthcare expenditure (WaszKrak credits)",
main = "Expenditure vs MedScore — curve pretending to be a line")
#> Error in eval(m$data, eframe): object 'medscore' not found
# Box-Cox transformation
if (requireNamespace("MASS", quietly = TRUE)) {
model_raw <- lm(health_expenses ~ partner_b, data = medscore)
bc <- MASS::boxcox(model_raw, plotit = FALSE)
lambda_opt <- bc$x[which.max(bc$y)]
cat("Optimal lambda:", round(lambda_opt, 3), "\n")
# Log transformation (lambda ≈ 0)
model_log <- lm(log(health_expenses) ~ partner_b, data = medscore)
summary(model_log)
# Back-transformed predictions
scores <- c(30, 50, 80)
log_pred <- predict(model_log,
newdata = data.frame(partner_b = scores))
data.frame(partner_b = scores,
predicted_expenses = round(exp(log_pred), 0))
}
#> Error in eval(mf, parent.frame()): object 'medscore' not found