Skip to contents

A simulated dataset of 5,000 WaszKrak residents scored by the fictional LifeCalc algorithm (QuantumCorp, 2047). The dataset is designed to illustrate multicollinearity, model selection, and regularisation in the context of algorithmic social scoring.

Each row represents one resident. The outcome variable SocialScore is generated by a sparse true model dominated by DistrictScore and prior_flag. The remaining 22 predictors are organised into correlated clusters — education, employment, health, and behaviour — that introduce structured multicollinearity, mimicking a real system where every subscore feeds every other subscore in a reinforcing loop.

The true model

SocialScore ≈ 0.40 × DistrictScore
16   × prior_flag
3.5  × gender
             + 0.18 × EmploymentScore
             + 0.12 × EducationScore
             + 0.10 × MedicalScore
             + 0.08 × MobilityScore
0.10 × age
             + 0.06 × NutritionScore
0.05 × ChronicLoadScore
             + ε,   ε ~ N(0, 5)

All other variables are correlated proxies that LASSO regularisation should eliminate when the optimal penalty is chosen by cross-validation.

Correlation clusters

ClusterVariables
EducationEducationScore, LiteracyScore, CuriosityScore, VerificationScore
EmploymentEmploymentScore, NetworkScore, ConsumptionScore, MobilityScore
HealthMedicalScore, SleepScore, RecoveryScore, NutritionScore, StressIndex, GeneticRiskScore, ChronicLoadScore
BehaviourComplianceScore, NarrativeScore, RoutineScore, AttentionScore, DisplacementScore

Usage

lifecalc

Format

A data frame with 5,000 rows and 25 variables:

SocialScore

Outcome. LifeCalc master social score (0–100). Determines TierCare tier, credit access, and district reclassification eligibility. Generated by the true model described above.

age

Integer. Resident age in years (18–75).

gender

Binary. 0 = Female, 1 = Male.

DistrictScore

Continuous (5–95). Geographic district quality index. Higher values correspond to wealthier districts (District 23 ≈ 85, District 7 ≈ 30). The single strongest predictor in the true model.

prior_flag

Binary. 1 if any parent recorded EmploymentScore < 25 during the resident's childhood (ages 0–18). Permanent and non-reversible once set. Coefficient −16 in the true model — the dominant individual predictor after DistrictScore.

EducationScore

Continuous (5–95). Composite education index. Strongly correlated with DistrictScore (r ≈ 0.68). Anchor of the education cluster.

EmploymentScore

Continuous (0–95). Algorithmic employment score (four-layer LifeCalc index). Correlated with EducationScore (r ≈ 0.68) and DistrictScore (r ≈ 0.78). Penalised by prior_flag.

LiteracyScore

Continuous (5–95). Capacity to parse algorithmic decisions and contracts. Follows EducationScore (r ≈ 0.83).

CuriosityScore

Continuous (5–95). Frequency of spontaneous information-seeking outside agent recommendations. Follows EducationScore (r ≈ 0.74); reduced by agent exposure and prior_flag.

VerificationScore

Continuous (5–95). Frequency of cross-checking agent-provided information. Follows EducationScore (r ≈ 0.71).

NetworkScore

Continuous (5–95). Quality-weighted social contact index. Correlated with EmploymentScore (r ≈ 0.80) and DistrictScore (r ≈ 0.78).

ConsumptionScore

Continuous (5–95). Consumption pattern alignment with algorithmic profile. Correlated with EmploymentScore (r ≈ 0.84) and DistrictScore (r ≈ 0.76).

MobilityScore

Continuous (0–95). Algorithmic probability of district reclassification. Correlated with DistrictScore and EmploymentScore; penalised by prior_flag and gender.

GeneticRiskScore

Continuous (5–95). Predicted probability of costly medical conditions from genetic profile. Inversely correlated with DistrictScore (r ≈ −0.41) — a selection artefact from 14 years of training data.

NutritionScore

Continuous (5–95). Weekly nutritional status index from AI health checks. Follows DistrictScore (r ≈ 0.59).

SleepScore

Continuous (5–95). Sleep regularity and duration from neural implant and smart-device logs. Follows DistrictScore and NutritionScore.

StressIndex

Continuous (5–95). Biomarker-derived stress index. Inversely correlated with DistrictScore (r ≈ −0.57); elevated by prior_flag.

RecoveryScore

Continuous (5–95). Speed of return to baseline health after illness or injury. Follows DistrictScore and NutritionScore; reduced by StressIndex.

ChronicLoadScore

Continuous (5–95). Accumulated health-system burden over five years. Inversely correlated with DistrictScore (r ≈ −0.68) and EducationScore (r ≈ −0.58).

MedicalScore

Continuous (5–95). Composite health outcome index. Correlated with SleepScore (r ≈ 0.68), NutritionScore (r ≈ 0.69), and RecoveryScore; reduced by GeneticRiskScore and StressIndex.

ComplianceScore

Continuous (5–95). Alignment of daily behaviour with algorithmic recommendations. Follows DistrictScore; inversely related to CuriosityScore.

NarrativeScore

Continuous (5–95). Internal coherence of beliefs and stated preferences. Follows DistrictScore and LiteracyScore.

RoutineScore

Continuous (5–95). Predictability of daily patterns (routes, purchases, contacts). Follows DistrictScore and ComplianceScore.

AttentionScore

Continuous (5–95). Sustained task-focus duration from productivity logs. Follows EducationScore and SleepScore; reduced by StressIndex.

DisplacementScore

Continuous (5–95). Frequency of movement outside predicted daily range. Inversely related to DistrictScore; follows MobilityScore.

Source

Simulated dataset generated by data-raw/generate_lifecalc.R. All values are fictional. The dataset is designed for pedagogical use in the context of the BetaBit StatPunk universe.

Examples

data(lifecalc)

# Basic summary
summary(lifecalc$SocialScore)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>    0.00   21.33   35.40   34.31   47.59   85.10 

# Correlation of all variables with SocialScore
cors <- cor(lifecalc)[, "SocialScore"]
sort(abs(cors), decreasing = TRUE)
#>       SocialScore   EmploymentScore     MobilityScore     DistrictScore 
#>        1.00000000        0.85691216        0.84508857        0.84282836 
#>  ConsumptionScore      NetworkScore      MedicalScore        prior_flag 
#>        0.77249534        0.74193704        0.67211614        0.65837659 
#>    EducationScore     RecoveryScore    CuriosityScore     LiteracyScore 
#>        0.65436660        0.63747316        0.63075376        0.61068055 
#>    NutritionScore        SleepScore  ChronicLoadScore       StressIndex 
#>        0.59240309        0.58138592        0.58096628        0.50479675 
#> VerificationScore    NarrativeScore    AttentionScore      RoutineScore 
#>        0.50016925        0.48931294        0.47544205        0.40301191 
#>  GeneticRiskScore   ComplianceScore            gender               age 
#>        0.33950987        0.31622404        0.11055654        0.06246445 
#> DisplacementScore 
#>        0.05125876 

# OLS model — all predictors
model_full <- lm(SocialScore ~ ., data = lifecalc)
summary(model_full)
#> 
#> Call:
#> lm(formula = SocialScore ~ ., data = lifecalc)
#> 
#> Residuals:
#>      Min       1Q   Median       3Q      Max 
#> -19.9585  -3.2525  -0.0908   3.3225  17.3919 
#> 
#> Coefficients:
#>                     Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)        7.506e+00  7.996e-01   9.387  < 2e-16 ***
#> age               -1.052e-01  6.192e-03 -16.995  < 2e-16 ***
#> gender            -3.164e+00  1.441e-01 -21.961  < 2e-16 ***
#> DistrictScore      3.655e-01  1.199e-02  30.494  < 2e-16 ***
#> prior_flag        -1.496e+01  2.221e-01 -67.368  < 2e-16 ***
#> EducationScore     1.104e-01  1.181e-02   9.354  < 2e-16 ***
#> EmploymentScore    1.877e-01  1.010e-02  18.583  < 2e-16 ***
#> LiteracyScore      2.870e-03  9.034e-03   0.318 0.750722    
#> CuriosityScore     1.787e-02  8.252e-03   2.166 0.030343 *  
#> VerificationScore  1.762e-03  7.364e-03   0.239 0.810927    
#> NetworkScore      -3.455e-03  8.019e-03  -0.431 0.666582    
#> ConsumptionScore  -9.047e-04  8.916e-03  -0.101 0.919182    
#> MobilityScore      8.463e-02  9.033e-03   9.369  < 2e-16 ***
#> GeneticRiskScore  -2.966e-03  6.427e-03  -0.462 0.644448    
#> NutritionScore     4.913e-02  7.724e-03   6.360 2.20e-10 ***
#> SleepScore        -6.124e-03  8.085e-03  -0.757 0.448793    
#> StressIndex        6.370e-03  6.369e-03   1.000 0.317258    
#> RecoveryScore      9.785e-04  8.406e-03   0.116 0.907334    
#> ChronicLoadScore  -4.090e-02  6.987e-03  -5.853 5.13e-09 ***
#> MedicalScore       1.186e-01  1.090e-02  10.882  < 2e-16 ***
#> ComplianceScore    2.687e-02  7.186e-03   3.740 0.000186 ***
#> NarrativeScore     8.737e-03  7.207e-03   1.212 0.225485    
#> RoutineScore      -2.459e-03  7.214e-03  -0.341 0.733202    
#> AttentionScore    -3.887e-03  8.634e-03  -0.450 0.652526    
#> DisplacementScore  3.583e-03  5.796e-03   0.618 0.536431    
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 4.993 on 4975 degrees of freedom
#> Multiple R-squared:  0.9245,	Adjusted R-squared:  0.9241 
#> F-statistic:  2538 on 24 and 4975 DF,  p-value: < 2.2e-16
#> 

# Check multicollinearity
if (requireNamespace("car", quietly = TRUE)) {
  car::vif(model_full)
}
#>               age            gender     DistrictScore        prior_flag 
#>          1.002543          1.040943          8.995438          1.815496 
#>    EducationScore   EmploymentScore     LiteracyScore    CuriosityScore 
#>          5.425246          6.057183          3.329393          2.476873 
#> VerificationScore      NetworkScore  ConsumptionScore     MobilityScore 
#>          1.892479          3.102793          3.784418          4.264902 
#>  GeneticRiskScore    NutritionScore        SleepScore       StressIndex 
#>          1.394617          2.176529          2.312153          1.659922 
#>     RecoveryScore  ChronicLoadScore      MedicalScore   ComplianceScore 
#>          2.624592          1.960989          3.795749          1.308751 
#>    NarrativeScore      RoutineScore    AttentionScore DisplacementScore 
#>          1.534019          1.366199          1.709999          1.045497 

# LASSO variable selection
if (requireNamespace("glmnet", quietly = TRUE)) {
  X <- model.matrix(SocialScore ~ ., data = lifecalc)[, -1]
  y <- lifecalc$SocialScore
  cv_fit <- glmnet::cv.glmnet(X, y, alpha = 1)
  coef(cv_fit, s = "lambda.min")
}
#> 25 x 1 sparse Matrix of class "dgCMatrix"
#>                      lambda.min
#> (Intercept)         7.713393676
#> age                -0.100663011
#> gender             -3.052693670
#> DistrictScore       0.362950477
#> prior_flag        -14.827263522
#> EducationScore      0.109412275
#> EmploymentScore     0.186707917
#> LiteracyScore       0.001487630
#> CuriosityScore      0.015847622
#> VerificationScore   .          
#> NetworkScore        .          
#> ConsumptionScore    .          
#> MobilityScore       0.086696799
#> GeneticRiskScore   -0.001175283
#> NutritionScore      0.047095131
#> SleepScore          .          
#> StressIndex         .          
#> RecoveryScore       .          
#> ChronicLoadScore   -0.039190690
#> MedicalScore        0.112641475
#> ComplianceScore     0.022037314
#> NarrativeScore      0.006470467
#> RoutineScore        .          
#> AttentionScore      .          
#> DisplacementScore   .