Fits a Bayesian Flexible Adaptation to Climate Trends (BFACT) latent factor model to data. This is the core fitting function that runs MCMC to estimate posterior distributions of latent factors and model weights.
Value
A list containing:
H: fitted H value
posterior: list with samples for beta, U, phi, sigma2
metrics: list with RMSE and other diagnostics
settings: list of input parameters
Details
The BFACT model represents observations as: z_t = mu + U %*% beta_t + epsilon_t
where U is a basis matrix (n_time × H), beta_t are time-varying weights, and epsilon_t is Gaussian error.
Examples
if (FALSE) { # \dontrun{
sim <- simulate_data(H_true = 2, K = 20)
fit <- fit_bfact_model(sim, H = 2, nsim = 5000)
} # }