moneca creates weighted networks from mobility tables and uses cliques to identify discrete and nested clusters of social positions with high internal mobility. The package provides comprehensive tools for analyzing social mobility patterns through graph-theoretic approaches with modern visualization capabilities.
Details
The moneca package implements a sophisticated hierarchical clustering algorithm that detects mobility patterns in social networks. It identifies segments with high internal mobility by finding cliques in weighted network representations of mobility data, creating nested hierarchical structures that reveal the underlying organization of social mobility.
Key Features:
Network-based clustering using relative risk matrices
Hierarchical segmentation with multiple nested levels
Modern visualization with ggraph and ggplot2
Synthetic data generation for testing and demonstrations
Quality metrics for assessing segmentation performance
Multiple visualization types (network, ego, stair plots)
Flexible input formats with automatic data validation
Core Functions:
moneca: Main clustering algorithmfind.segments: Core segmentation identificationweight.matrix: Relative risk matrix calculationsegment.membership: Extract cluster memberships
Modern Visualization (Recommended):
plot_moneca_ggraph: Network visualization with ggraphplot_ego_ggraph: Ego network analysisplot_stair_ggraph: Multi-level segmentation plots
Legacy Visualization (Backward Compatibility):
gg.moneca: Original ggplot2-based visualizationmoneca.plot: Base R network plottingego.plot: Legacy ego network plotsstair.plot: Legacy stair plots
Data Generation:
generate_mobility_data: Create synthetic mobility tables
Package Dependencies
Required packages:
igraph(>= 1.3.0): Network analysis with compatibility layerggplot2(>= 3.4.0): Graphics and plottingRColorBrewer: Color palettes for visualizationsscales: Scale transformations and formatting
Modern visualization packages:
ggraph(>= 2.0.0): Advanced network visualizationtidygraph(>= 1.2.0): Tidy graph manipulationdplyr(>= 1.0.0): Data manipulation
Additional packages:
grid: Low-level graphicstoOrdinal: Ordinal number formatting
Color Vision Deficiency (CVD) Accessibility
All modern visualization functions use CVD-safe defaults:
Default discrete palette is the 8-color Okabe-Ito palette (
color_palette = "okabe-ito"), distinguishable under deuteranopia, protanopia, and tritanopia.Continuous gradients use perceptually uniform viridis scales.
Diverging scales use a PuOr (purple-orange) scheme that remains discriminable under common CVD types.
plot_moneca_ggraph()supportsnode_shape = "segment"for shape-based redundant encoding alongside color.All hardcoded fill and reference-line colors use CVD-safe hex values.
Users who prefer other palettes can override with color_palette = "Set3"
or any RColorBrewer/viridis palette name.
Author
Maintainer: Giampaolo Montaletti giampaolo.montaletti@gmail.com (ORCID)
Authors:
Jonas Touboel jt@soc.ku.dk (Original algorithm and methodology)
Other contributors:
Anton Grau Larsen agl.ioa@cbs.dk (Original package development) [contributor]