1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
//! Component-wise gradient boosting and Bayesian regression for functional responses.
//!
//! Implements REG-06: FDboost-style penalized functional base-learner boosting,
//! GAMLSS distributional boosting, conjugate Gibbs Bayesian FOSR, and stability selection.
//!
//! # Methods
//!
//! - [`boost_fosr`] — Component-wise boosted function-on-scalar regression (REG-06-01)
//! - [`boost_fofr`] — Component-wise boosted function-on-function regression (REG-06-02)
//! - [`gamlss_fosr`] — GAMLSS distributional boosting: location + scale (REG-06-03)
//! - [`bayesian_fosr`] — Bayesian FOSR via conjugate Gibbs sampler (REG-06-04)
//! - [`stability_selection`] — FDboost-style stability selection (REG-06-05)
//!
//! # References
//!
//! Hothorn et al. (2010). Model-Based Boosting. *Journal of Statistical Software*.
//! Hofner et al. (2016). gamboostLSS. *Journal of Statistical Software*, 74(1).
//! Jiang et al. (2025). arXiv:2505.05633 (Bayesian FoSR).
//! Meinshausen & Bühlmann (2010). Stability Selection. *JRSS-B*, 72(4).
//!
//! Divergences from R baselines (FDboost 1.1-4, refund, stabs) documented per function.
use crateFdMatrix;
// ---------------------------------------------------------------------------
// Config structs
// ---------------------------------------------------------------------------
/// Configuration for component-wise gradient boosting (FOSR, FoFR, GAMLSS, stability).
///
/// All base-learners use the same `nbasis`, `order`, `lfd_order`, and `lambda`
/// to ensure equal effective degrees of freedom, preventing selection bias toward
/// more flexible learners (see Pitfall 4 in RESEARCH.md).
///
/// **Divergence from FDboost:** Fixed `nu` and `mstop` rather than CV-based early stopping;
/// the GCV path is tracked for diagnostic purposes but not used for stopping.
/// Configuration for the Bayesian FOSR Gibbs sampler (REG-06-04).
///
/// Uses conjugate Normal-Inverse-Gamma priors. Defaults match the weakly-informative
/// settings recommended by Jiang et al. (2025): `τ² = 100`, `IG(0.001, 0.001)`.
///
/// **Divergence from refund:** refund's Bayesian FOSR uses spline basis priors;
/// this implementation uses FPCA score compression via `fdata_to_pc_1d` for
/// simplicity and zero new dependencies.
/// Configuration for FDboost-style stability selection (REG-06-05).
///
/// Implements the Meinshausen-Bühlmann subsampling scheme with ⌊n/2⌋ rows
/// per replicate. The PFER bound `E[V] ≤ q² / ((2·π_thr − 1)·p)` is reported
/// as an informational diagnostic.
// ---------------------------------------------------------------------------
// Result structs
// ---------------------------------------------------------------------------
/// Result of component-wise boosted function-on-scalar regression (REG-06-01).
///
/// Follows the `FosrResult` field convention; adds the boosting path diagnostics
/// (`selected_learners`, `gcv_path`, `mstop`, `nu`).
///
/// **Divergence from FDboost:** fixed `mstop` / fixed `nu`; no CV-based early stopping.
/// GCV path is tracked for post-hoc diagnostics only (see `gcv_path`).
/// Result of component-wise boosted function-on-function regression (REG-06-02).
///
/// Functional predictors are compressed via FPCA score projection; the boosting
/// core operates on the resulting scalar design matrices (bfpc variant).
///
/// **Divergence from FDboost:** uses FPC score compression (`fdata_to_pc_1d`) rather
/// than FDboost's `bsignal` B-spline joint expansion. Simpler and dependency-free.
/// Result of GAMLSS-style distributional functional regression (REG-06-03).
///
/// Models a Gaussian functional response Y(t) with location μ(t) and scale σ(t).
/// Cyclic component-wise boosting alternates between boosting μ and log-σ.
///
/// **Divergence from gamboostLSS:** uses cyclic rather than noncyclic (non-cyclic
/// per-iteration selection is superior for variable selection but more complex).
/// Links: identity for μ, log for σ.
/// Result of Bayesian function-on-scalar regression via conjugate Gibbs (REG-06-04).
///
/// Posterior summaries are computed from thinned post-burn-in draws. Credible bands
/// are pointwise (not simultaneous) quantiles over the retained draws.
///
/// **Divergence from refund:** uses FPCA score compression via `fdata_to_pc_1d`
/// rather than spline basis priors. Pointwise credible bands only (no simultaneous bands).
/// Result of FDboost-style stability selection (REG-06-05).
///
/// Aggregates base-learner selection frequencies over B subsamples of size ⌊n/2⌋.
/// The PFER bound is informational: `E[V] ≤ q² / ((2·π_thr − 1)·p)`.
// ---------------------------------------------------------------------------
// Barrel re-exports
// ---------------------------------------------------------------------------
pub use bayesian_fosr;
pub use boost_fofr;
pub use boost_fosr;
pub use gamlss_fosr;
pub use stability_selection;