---
title: "Backend Portability and Installation"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Backend Portability and Installation}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(gp3bayes)
```

The advanced extension supports the two backends officially exposed by brms:
`rstan` and `cmdstanr`. The model family, formula, priors, and algorithm remain
restricted by gp3bayes. Only the implementation backend is selectable.

## Audit installed components

```{r}
bayesian_backend_capabilities()
```

## CmdStanR setup

Install CmdStanR from the Stan R-universe repository:

```{r, eval=FALSE}
install.packages(
  "cmdstanr",
  repos = c(
    "https://stan-dev.r-universe.dev",
    getOption("repos")
  )
)
```

Then check the C++ toolchain and install CmdStan:

```{r, eval=FALSE}
cmdstanr::check_cmdstan_toolchain()
cmdstanr::install_cmdstan(cores = 2)
check_cmdstan_backend(strict = TRUE)
```

The gp3bayes installer never installs or repairs CmdStan automatically unless
that explicit option is enabled.

## Full MCMC only

```{r, eval=FALSE}
fit <- fit_duration_model_backend(
  specification = duration_spec,
  backend = "cmdstanr",
  chains = 2,
  iter = 2000,
  warmup = 1000,
  seed = 2026
)
```

Variational inference, Pathfinder, Laplace approximation, arbitrary Stan code,
and arbitrary backend arguments remain outside this wrapper.
