Skip to contents

Overview

Posterior draws for respondent-level probabilities can be large. lx_prune() lets you reduce model size by subsampling draws, averaging them to point estimates, and dropping optional components such as simulated responses.

Subsampling draws

The default compression mode is "subsample". Use size to keep a fraction or a fixed number of draws. size = 1 keeps all draws.

model <- example_lx_model

model_half <- lx_prune(model, size = 0.5)
model_60  <- lx_prune(model, size = 60)

Subsampling produces the same kind of model object as before, just with fewer draws for the public and private probabilities. Downstream summaries and plots still work, but use this option only if you’re comfortable trading some quality for size. Simulated answers are dropped by default; we do not yet provide any summary helpers for them.

Averaging draws

If you only need point estimates, set compress = "mean". This replaces each draws matrix with a single column of per-respondent means.

model_mean <- lx_prune(model, compress = "mean")

This is useful when you only care about point estimates. For example, lx_predict_for_cohorts() will still run with a mean-compressed model, but the reported lower/upper values should be ignored because they do not represent meaningful uncertainty intervals.

Dropping optional components

By default, lx_prune() drops simulated responses (sim_public and sim_private). You can also drop observed responses and diagnostics if you don’t need them:

model_light <- lx_prune(
  model,
  drop_sim = TRUE,
  drop_responses = TRUE,
  drop_diagnostics = TRUE
)

Exporting point estimates

Use lx_export() to produce a compact JSON payload with per-respondent means for public and private probabilities. This uses mean compression internally.

lx_export(model, "model_means.json")