Skip to contents

Extract latent factor posteriors from fit

Usage

latent_factors(fit, summary = TRUE, probs = c(0.025, 0.5, 0.975))

Arguments

fit

A ratiod_fit object

summary

Logical; if TRUE, return summary statistics. If FALSE, return full posterior draws.

probs

Quantiles for summary. Default is c(0.025, 0.5, 0.975).

Value

If summary = TRUE, a data frame with columns for observation, factor, and summary statistics. If summary = FALSE, a matrix of posterior draws.

Examples

if (FALSE) { # \dontrun{
# After fitting with latent factors
fit <- tratio(
  count | total ~ x,
  data = df,
  family = ratiod_negbin_negbin(),
  latent = latent_factor(n_factors = 2)
)

# Get summary
factors <- latent_factors(fit)
head(factors)

# Get full posterior draws
factor_draws <- latent_factors(fit, summary = FALSE)
} # }