Step 1: Tell us about your data
What kind of outcome are you analyzing?
How many predictor variables do you have?
What's a typical range for your outcome?
What are priors?
Priors are your starting assumptions before looking at the data. They help guide the model, especially when you don't have a lot of data.
Think of it like this: if someone says 'guess a person's height,' you'd probably guess somewhere between 5 and 6 feet, not 1 foot or 20 feet. That's a prior - your reasonable expectations before seeing the actual person.
Don't worry! If your data strongly disagrees with your priors, the data will win. Priors just help keep the model sensible, especially with small datasets.
The Baseline (Intercept)
Your Baseline Distribution
The Effects (Coefficients)
Your Effects Distribution
The Noise Level (Residual Standard Deviation)
Your Noise Distribution
Your Custom Stan Model Code
Copy this code into a .stan file and use it with RStan or CmdStanR:
Download .stan FileWhat Do These Priors Mean in Plain English?
Next Steps
How to use this code:
- Save the code - Download the .stan file or copy the code above
- Prepare your data - Make sure you have your outcome (y) and predictors (X) ready in R
- Run the model - Use RStan or CmdStanR to fit the model:
- Check the results - Examine posterior distributions, convergence diagnostics (Rhat), and effective sample size
# Example with RStan
library(rstan)
fit <- stan(file = 'your_model.stan',
data = list(N = nrow(data),
K = 2,
X = X_matrix,
y = y_vector))