How sims1253/bayesfam works
Main Components
a. Core Distribution Implementations
• Probability distributions (Beta, Gamma, Weibull, etc.) in a central component
• Each distribution should have its own sub-component showing the four essential functions:
• Density (d*)
• Random number generation (r*)
• Quantile function (q*)
• Distribution function (p*)
b. BRMS Integration Layer
• Connection to brms package
• Stanvars integration point
• Family constructors
c. Testing Framework
• Unit tests for each distribution
• Helper functions for testing
• Coverage reporting integration
Component Relationships
• Use a layered architecture approach with three main layers:
1. Distribution Implementation Layer (bottom)
2. BRMS Integration Layer (middle)
3. User Interface Layer (top)
• [User Interface Layer]
• ┌─────────────────────────┐
• Public API │
• (Family Constructors) │
• ┬──────────────┘
• ↓
• [BRMS Integration Layer]
• ┌─────────────────────────┐
• Stan Variables │
• Parameter Links │
• Family Definitions │
• ┬──────────────┘
• ↓
• [Distribution Implementation Layer]
• ┌─────────────────────────┐
• Distribution Functions │
• ┌─────┐ ┌─────┐ ┌─────┐│
• Beta │ │Gamma│ │Other││
• ┘ └─────┘ └─────┘│
• ┘
Important Details
• Stan integration points
• Distribution parameter relationships
• Error handling and validation flows
• Testing coverage paths
Implementation Notes
• How the family constructors (like betaprime()) connect to the Stan implementation
• Flow of stanvars from construction to model fitting
• Demonstrate how custom families extend brms' capabilities
External Dependencies
• Clear integration points with:
• brms package
• Stan framework
• R's base statistics functions
Keep the focus on the architectural components rather than individual function implementations, but maintain enough detail to show how the custom families are constructed and integrated with brms.
This design reflects the package's primary purpose of extending brms with additional probability distributions while maintaining a consistent interface for Bayesian modeling.