Computes a tidy per-cf data.table of career indicators from a
vecshift output. career_profile() is the single entry point that
replaces the legacy family of calculate_career_*_metrics() functions
in longworkR v0.9.0. It always returns a core set of six indicators
and accepts an indicators vector to opt into optional groups.
Usage
career_profile(
data,
indicators = "core",
quality_source = "survival",
reference_date = NULL
)Arguments
- data
A
data.table(orvecshift_result) produced byvecshift::vecshift(). Must contain at leastcf,inizio,fine,durata,arco,over_id, andprior.- indicators
Character vector. Which indicator groups to include.
"core"is always returned. Valid values:c("core", "stability", "complexity", "transitions", "wages", "all")."all"expands to all four optional groups. Defaults to"core".- quality_source
Character scalar. How
contract_qualityis computed. Only"survival"is accepted in v0.9.0; any other value errors with a message flagging the reserved future-release API.- reference_date
Optional
Dateor date-coercible scalar used as the right-censoring anchor foremployment_rateandgap_share. Defaults tomax(data$fine).
Value
A data.table with one row per cf, keyed by cf. Columns
depend on indicators:
Core (always returned)
cfPerson identifier.
n_periodsDistinct consolidated employment periods (
uniqueN(over_id[arco >= 1])).total_days_employedTotal days spent in
arco >= 1spells.employment_ratetotal_days_employed / observation_window, clamped to[0, 1].contract_qualityDuration-weighted mean of survival-derived quality scores per contract type (
arco >= 1rows only).intensityDuration-weighted mean of
priorwherearco >= 1.
Stability ("stability" or "all")
spell_cvCoefficient of variation of per-
over_idtotal durations.gap_shareShare of observation window in unemployment (
arco == 0).max_tenure_daysLongest single
over_idcumulative duration.
Complexity ("complexity" or "all")
n_contract_typesNumber of distinct contract-type codes.
employer_hhiHerfindahl index over employer durata-weighted shares.
NAif no employer column is detected.type_entropyShannon entropy (natural log) of contract-type duration shares.
Transitions ("transitions" or "all")
n_upwardCount of consecutive
over_idpairs where contract quality increases.n_downwardCount of consecutive pairs where it decreases.
quality_slopeOLS slope of quality against
over_idrank.NAif fewer than twoover_ids.
Wages ("wages" or "all")
wage_meanDuration-weighted mean wage.
wage_medianDuration-weighted median wage (via
matrixStats::weightedMedian).wage_growth(last - first) / firstwhere the wage is computed perover_id;NAwith fewer than twoover_ids.
Details
Contract quality is derived from survival analysis only: per project
policy (CLAUDE.md CRITICAL CORRECTION), fixed weights are forbidden.
The shared survival-based lookup is built once via
.build_contract_quality_lookup() and
reused across all indicator groups.
Boundary with analyze_employment_transitions()
The "transitions" group returns only per-cf summaries
(n_upward, n_downward, quality_slope). Full pairwise transition
matrices and network objects remain the responsibility of
analyze_employment_transitions().
Class preservation
career_profile() is an aggregation: it collapses the input to one
row per cf. The result is therefore a plain data.table (keyed by
cf), even when the input carries the vecshift_result S3 class.
Period-level vecshift metadata does not apply to the aggregated output.
See also
analyze_employment_transitions() for full transition
matrices, estimate_contract_survival_optimized() for the underlying
survival estimator.
Examples
if (FALSE) { # \dontrun{
sample_data <- readRDS(system.file("extdata", "sample.rds",
package = "longworkR"))
# Core only
core <- career_profile(sample_data)
# Core + stability
stab <- career_profile(sample_data, indicators = c("core", "stability"))
# Everything
full <- career_profile(sample_data, indicators = "all")
} # }