Learn R Programming

cosmic (version 0.5)

outlier_report: Create an outlier-focused report table

Description

Filters and reorders officer summaries to show only officers whose top-tail or bottom-tail posterior rank probability exceeds a chosen cutoff. The returned data frame is designed to be passed directly to knitr::kable(), kableExtra::kbl(), or xtable::xtable().

Usage

outlier_report(x, prob_outlier = 0.8)

Value

A filtered data frame with class c("cosmic_outlier_report", "data.frame"). When available, the report includes both idOffOrig and idOff.

Arguments

x

A "cosmic_officer_summary" object returned by officer_summary.

prob_outlier

Probability cutoff used to flag an outlier. Default is 0.8. Set to 0 to return all officers.

Examples

Run this code
# \donttest{
d <- data.frame(
  id = c(1,1,2,2),
  idOff = c(1,2,1,2),
  y = c(1,2,1,3)
)
fit <- cosmic(d, id, idOff, y, iter = 300, chains = 1, cores = 1, threads = 1)
off_summary <- officer_summary(fit)

outliers <- outlier_report(off_summary)
outliers

# For a nicer looking report use kable()
# knitr::kable(outliers)
# }

Run the code above in your browser using DataLab