# \#splines

**URL:** https://discourse.mc-stan.org/tag/splines/143.md

[Latest](https://discourse.mc-stan.org/latest.md) · [Categories](https://discourse.mc-stan.org/categories.md) · [Tags](https://discourse.mc-stan.org/tags.md)

---

## [Extracting default knot locations from fitted brms models](https://discourse.mc-stan.org/t/extracting-default-knot-locations-from-fitted-brms-models/39688)

<div class="topic-metadata">

**Author:** [@niklas191](https://discourse.mc-stan.org/u/niklas191)\
**Replies:** 4\
**Last updated:** [June 11, 2025, 12:01am UTC](https://discourse.mc-stan.org/t/extracting-default-knot-locations-from-fitted-brms-models/39688 "2025-06-11T00:01:31Z")

</div>

How can one extract default knot locations that were assigned during model fitting in brms? Using the example provided here but without custom knot locations, i.e. set.seed(2) dat \<- mgcv::gamSim(1,n=400,dist="normal",…

---

## [Advice on priorsense and splines](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945)

<div class="topic-metadata">

**Author:** [@andymilne](https://discourse.mc-stan.org/u/andymilne)\
**Replies:** 12\
**Last updated:** [November 11, 2024, 7:08pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945 "2024-11-11T19:08:41Z")

</div>

I am running a model in brms with a couple of smooth terms. I thought it would be interesting to use the priorsense package. It is finding several prior-data conflicts for the various smooth terms used in brms. Changing …

---

## [Help understanding spline and extreme estimations](https://discourse.mc-stan.org/t/help-understanding-spline-and-extreme-estimations/35988)

<div class="topic-metadata">

**Author:** [@rtpanik22](https://discourse.mc-stan.org/u/rtpanik22)\
**Replies:** 4\
**Last updated:** [August 8, 2024, 10:00pm UTC](https://discourse.mc-stan.org/t/help-understanding-spline-and-extreme-estimations/35988 "2024-08-08T22:00:38Z")

</div>

Hi, rstan and modeling pros – I am having issue with a count time series model that contains a spline producing one-off, extremely large estimates at certain instances. Here is some background: The data + model: My d…

---

## [Mvgam: an R package for time series modeling and forecasting](https://discourse.mc-stan.org/t/mvgam-an-r-package-for-time-series-modeling-and-forecasting/35065)

<div class="topic-metadata">

**Author:** [@nicholasjclark](https://discourse.mc-stan.org/u/nicholasjclark)\
**Replies:** 2\
**Last updated:** [June 26, 2024, 5:39am UTC](https://discourse.mc-stan.org/t/mvgam-an-r-package-for-time-series-modeling-and-forecasting/35065 "2024-06-26T05:39:51Z")

</div>

Happy to announce that I have released a new package to CRAN called mvgam. The goal of mvgam is to estimate parameters of Dynamic Generalized Additive Models (DGAMs) for time series with dynamic trend components. It…

---

## [Decoding smooth fits in brms](https://discourse.mc-stan.org/t/decoding-smooth-fits-in-brms/34473)

<div class="topic-metadata">

**Author:** [@harrelfe](https://discourse.mc-stan.org/u/harrelfe)\
**Replies:** 4\
**Last updated:** [March 27, 2024, 4:44am UTC](https://discourse.mc-stan.org/t/decoding-smooth-fits-in-brms/34473 "2024-03-27T04:44:19Z")

</div>

When using a thin-plate regression spline for a single predictor in brms, e.g. with a formula such as y ~ x1 + s(x2), how does one estimate the effective number of degrees of freedom for x2 and how does one construct a …

---

## [Gamma family puts plot\_nonlinear upside down](https://discourse.mc-stan.org/t/gamma-family-puts-plot-nonlinear-upside-down/34530)

<div class="topic-metadata">

**Author:** [@questionmark](https://discourse.mc-stan.org/u/questionmark)\
**Replies:** 1\
**Last updated:** [March 19, 2024, 4:31pm UTC](https://discourse.mc-stan.org/t/gamma-family-puts-plot-nonlinear-upside-down/34530 "2024-03-19T16:31:34Z")

</div>

Hi, I’m fitting a smooth, using stan\_gamm4, to all positive data and have played around a fair bit with different data transformations and families. From my trials it seems like the Gamma family is best suited for my da…

---

## [Y axis scale of plot\_nonlinear](https://discourse.mc-stan.org/t/y-axis-scale-of-plot-nonlinear/34333)

<div class="topic-metadata">

**Author:** [@questionmark](https://discourse.mc-stan.org/u/questionmark)\
**Replies:** 3\
**Last updated:** [March 19, 2024, 2:41pm UTC](https://discourse.mc-stan.org/t/y-axis-scale-of-plot-nonlinear/34333 "2024-03-19T14:41:32Z")

</div>

I’ve fit a stan\_gamm4 model using log transformed data (that is otherwise all positive) and gaussian family (link = ‘identity’) with one smooth and when I plot the smooth using plot\_nonlinear, the scale on the y-axis is …

---

## [Using the Apple M1 GPUs: question from a noob](https://discourse.mc-stan.org/t/using-the-apple-m1-gpus-question-from-a-noob/23089)

<div class="topic-metadata">

**Author:** [@Joshua\_Hartshorne](https://discourse.mc-stan.org/u/Joshua_Hartshorne)\
**Replies:** 46\
**Last updated:** [November 18, 2023, 3:50pm UTC](https://discourse.mc-stan.org/t/using-the-apple-m1-gpus-question-from-a-noob/23089 "2023-11-18T15:50:42Z")

</div>

Short summary of the problem I’m trying to run a suite of spline regressions using BRMS on some very large datasets. It’s painfully slow: a few hours per model if I pre-average across items (totaling about 2.5 days once…

---

## [Does brms have issues with (perfect) linear dependencies between (smooth) covariates?](https://discourse.mc-stan.org/t/does-brms-have-issues-with-perfect-linear-dependencies-between-smooth-covariates/22747)

<div class="topic-metadata">

**Author:** [@JFMeyer2k](https://discourse.mc-stan.org/u/JFMeyer2k)\
**Replies:** 4\
**Last updated:** [November 3, 2023, 10:21am UTC](https://discourse.mc-stan.org/t/does-brms-have-issues-with-perfect-linear-dependencies-between-smooth-covariates/22747 "2023-11-03T10:21:16Z")

</div>

Hello (my very first question in this forum :)), I have a data-set about an experiment, where the influence of time (t) on y is not linear (its about growth). For every individual, the data is observed with and without…

---

## [Usage of tau in B-splines model](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310)

<div class="topic-metadata">

**Author:** [@Loni92](https://discourse.mc-stan.org/u/Loni92)\
**Replies:** 4\
**Last updated:** [August 2, 2023, 7:36am UTC](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310 "2023-08-02T07:36:10Z")

</div>

Hi all, I have what’s probably a rather basic question. I was reading this article on B-splines regression https://mc-stan.org/users/documentation/case-studies/splines\_in\_stan.html which contains the following model: …

---

## [BRMS: Implementation of sum to zero constraints](https://discourse.mc-stan.org/t/brms-implementation-of-sum-to-zero-constraints/30738)

<div class="topic-metadata">

**Author:** [@niklas191](https://discourse.mc-stan.org/u/niklas191)\
**Replies:** 0\
**Last updated:** [March 15, 2023, 1:23pm UTC](https://discourse.mc-stan.org/t/brms-implementation-of-sum-to-zero-constraints/30738 "2023-03-15T13:23:42Z")

</div>

Hey, I am fitting a condition logit model with a factor smooth, i.e. bf( y ~ 1, nlf(mu1 ~ intercept + bdonation \* donation1), nlf(mu2 ~ intercept + bdonation \* donation2), intercept ~ 1 + s(t, id, bs = "fs", xt…

---

## [Predict cumulative cases in a range from a spline model in brms](https://discourse.mc-stan.org/t/predict-cumulative-cases-in-a-range-from-a-spline-model-in-brms/30124)

<div class="topic-metadata">

**Author:** [@Angelo\_D\_Ambrosio](https://discourse.mc-stan.org/u/Angelo_D_Ambrosio)\
**Replies:** 1\
**Last updated:** [February 2, 2023, 5:50pm UTC](https://discourse.mc-stan.org/t/predict-cumulative-cases-in-a-range-from-a-spline-model-in-brms/30124 "2023-02-02T17:50:42Z")

</div>

Hello, a simple question whose answer evades me. I have a count model with a continuous predictor modelled as a spline. I’d like to compute the predicted cumulative count given a range of the predictor. Example: Poiss…

---

## [Additive model hit the maximum treedepth, what could be wrong](https://discourse.mc-stan.org/t/additive-model-hit-the-maximum-treedepth-what-could-be-wrong/29778)

<div class="topic-metadata">

**Author:** [@TommasoGhilardi](https://discourse.mc-stan.org/u/TommasoGhilardi)\
**Replies:** 2\
**Last updated:** [January 23, 2023, 4:18pm UTC](https://discourse.mc-stan.org/t/additive-model-hit-the-maximum-treedepth-what-could-be-wrong/29778 "2023-01-23T16:18:08Z")

</div>

I am trying to run some additive models using brms. Some context: I am trying to model some infant pupillometry data (for info you can even see my previous post: Additive model with random smooth for participant). I ha…

---

## [Building a multilevel GAM model with multiple factors in brms](https://discourse.mc-stan.org/t/building-a-multilevel-gam-model-with-multiple-factors-in-brms/29168)

<div class="topic-metadata">

**Author:** [@cmagelssen](https://discourse.mc-stan.org/u/cmagelssen)\
**Replies:** 8\
**Last updated:** [November 15, 2022, 11:25am UTC](https://discourse.mc-stan.org/t/building-a-multilevel-gam-model-with-multiple-factors-in-brms/29168 "2022-11-15T11:25:06Z")

</div>

Hello, I have a large local positioning (LPS) dataset from a motor learning experiment with elite ski racers learning to pump in slalom. In the experiment, we instructed the skiers to ski straight down the hill (COURSE …

---

## [PC prior for P-Splines (in python)](https://discourse.mc-stan.org/t/pc-prior-for-p-splines-in-python/29438)

<div class="topic-metadata">

**Author:** [@jbaranowski](https://discourse.mc-stan.org/u/jbaranowski)\
**Replies:** 2\
**Last updated:** [November 11, 2022, 5:05pm UTC](https://discourse.mc-stan.org/t/pc-prior-for-p-splines-in-python/29438 "2022-11-11T17:05:39Z")

</div>

I’m trying to implement P-splines with PC prior in stan and results are less than stellar. In particular: The E-BFMI, 0.00, is below the nominal threshold of 0.30 which suggests that HMC may have trouble exploring the …

---

## [Additive model with random smooth for participant](https://discourse.mc-stan.org/t/additive-model-with-random-smooth-for-participant/29056)

<div class="topic-metadata">

**Author:** [@TommasoGhilardi](https://discourse.mc-stan.org/u/TommasoGhilardi)\
**Replies:** 3\
**Last updated:** [October 10, 2022, 7:29am UTC](https://discourse.mc-stan.org/t/additive-model-with-random-smooth-for-participant/29056 "2022-10-10T07:29:57Z")

</div>

Hi All, I am trying to model some pupillometry data that I collected from one of my studies. I have already modelled the data using mgcv and I woudl like to convert the model to brms. I am new to both brms and mgcv so…

---

## [User-defined recursive function error](https://discourse.mc-stan.org/t/user-defined-recursive-function-error/29073)

<div class="topic-metadata">

**Author:** [@ASvalova](https://discourse.mc-stan.org/u/ASvalova)\
**Replies:** 4\
**Last updated:** [October 9, 2022, 2:33pm UTC](https://discourse.mc-stan.org/t/user-defined-recursive-function-error/29073 "2022-10-09T14:33:17Z")

</div>

Dear reader, I am trying to fit a b-spline model, where I create a recursive function basis, however it doesn’t seem to be able to find itself or, potentially, go deep enough to reach the base case (degree=0) and solve…

---

## [Multinomial model with spline and interaction - getting output from continous and categorical variable together](https://discourse.mc-stan.org/t/multinomial-model-with-spline-and-interaction-getting-output-from-continous-and-categorical-variable-together/28155)

<div class="topic-metadata">

**Author:** [@MiaKronborg](https://discourse.mc-stan.org/u/MiaKronborg)\
**Replies:** 1\
**Last updated:** [July 27, 2022, 12:31pm UTC](https://discourse.mc-stan.org/t/multinomial-model-with-spline-and-interaction-getting-output-from-continous-and-categorical-variable-together/28155 "2022-07-27T12:31:57Z")

</div>

Hi, I am having issues with extracting specific output from the brms function. I want to model how the probability of being in one of three categories changes with both age and sex of an individual. But the output from …

---

## [Constraints for density estimation with splines](https://discourse.mc-stan.org/t/constraints-for-density-estimation-with-splines/25706)

<div class="topic-metadata">

**Author:** [@fm361](https://discourse.mc-stan.org/u/fm361)\
**Replies:** 0\
**Last updated:** [December 15, 2021, 12:59pm UTC](https://discourse.mc-stan.org/t/constraints-for-density-estimation-with-splines/25706 "2021-12-15T12:59:21Z")

</div>

Hello! This is more of a theoretical question – no Stan code yet! I am performing some kind of blind source separation, where I know that multiple components are mixed together at different proportions to produce multi…

---

## [Plotting smooth splines using conditional\_smooths in brms](https://discourse.mc-stan.org/t/plotting-smooth-splines-using-conditional-smooths-in-brms/25563)

<div class="topic-metadata">

**Author:** [@Gang](https://discourse.mc-stan.org/u/Gang)\
**Replies:** 3\
**Last updated:** [December 6, 2021, 1:08pm UTC](https://discourse.mc-stan.org/t/plotting-smooth-splines-using-conditional-smooths-in-brms/25563 "2021-12-06T13:08:05Z")

</div>

With the following model fit using smooth splines in brms library(brms) dat \<- mgcv::gamSim(1, n = 200, scale = 2) fit \<- brm(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat) we can show the fit of s(x2) through plo…

---

## [Splines GLM](https://discourse.mc-stan.org/t/splines-glm/25340)

<div class="topic-metadata">

**Author:** [@nipnipj](https://discourse.mc-stan.org/u/nipnipj)\
**Replies:** 1\
**Last updated:** [November 18, 2021, 10:47am UTC](https://discourse.mc-stan.org/t/splines-glm/25340 "2021-11-18T10:47:40Z")

</div>

Is using splines in models where the response follows a distribution different from normal a good practice? Are there benefits when doing this?

---

## [SPDE models in brms](https://discourse.mc-stan.org/t/spde-models-in-brms/17346)

<div class="topic-metadata">

**Author:** [@lionel68](https://discourse.mc-stan.org/u/lionel68)\
**Replies:** 11\
**Last updated:** [November 2, 2021, 2:45pm UTC](https://discourse.mc-stan.org/t/spde-models-in-brms/17346 "2021-11-02T14:45:46Z")

</div>

Spatial models can be implemented in brms thanks to the link with splines constructor from mgcv, see for instance this thread. In a recent articles Miller and colleagues showed how basis penalty smoothers can be interpre…

---

## [New paper on splines and data depth with cmdstanpy](https://discourse.mc-stan.org/t/new-paper-on-splines-and-data-depth-with-cmdstanpy/24482)

<div class="topic-metadata">

**Author:** [@jbaranowski](https://discourse.mc-stan.org/u/jbaranowski)\
**Replies:** 1\
**Last updated:** [September 20, 2021, 5:10pm UTC](https://discourse.mc-stan.org/t/new-paper-on-splines-and-data-depth-with-cmdstanpy/24482 "2021-09-20T17:10:28Z")

</div>

Together with my collegues Katarzyna Grobler-Dębska and Edyta Kucharska we have published a new paper titled " Recognizing VSC DC Cable Fault Types Using Bayesian Functional Data Depth" in the Energies journal. We use s…

---

## [How to define a array of parameter values](https://discourse.mc-stan.org/t/how-to-define-a-array-of-parameter-values/23832)

<div class="topic-metadata">

**Author:** [@JFMeyer2k](https://discourse.mc-stan.org/u/JFMeyer2k)\
**Replies:** 1\
**Last updated:** [August 24, 2021, 2:13pm UTC](https://discourse.mc-stan.org/t/how-to-define-a-array-of-parameter-values/23832 "2021-08-24T14:13:07Z")

</div>

Hello, even though I know the spline-function of the mgcv-package can be used for brms, I am trying to customize my fitting function, which is why I am defining my own function. The code-example should only exemplify my…

---

## [Numerical issue with computing the integral of an exponential spline](https://discourse.mc-stan.org/t/numerical-issue-with-computing-the-integral-of-an-exponential-spline/23292)

<div class="topic-metadata">

**Author:** [@pasjor](https://discourse.mc-stan.org/u/pasjor)\
**Replies:** 2\
**Last updated:** [July 2, 2021, 1:03pm UTC](https://discourse.mc-stan.org/t/numerical-issue-with-computing-the-integral-of-an-exponential-spline/23292 "2021-07-02T13:03:14Z")

</div>

Hello, I want to fit a (IRT-type) model involving a custom probability function. For this custom probability function (name: espl\_lpdf), I need to compute the integral of a function of type exp(c\*bspline(x)), wherein b…

---

## [Posterior probability for models with splines or: How to use posterior\_smooths?](https://discourse.mc-stan.org/t/posterior-probability-for-models-with-splines-or-how-to-use-posterior-smooths/22776)

<div class="topic-metadata">

**Author:** [@simpel](https://discourse.mc-stan.org/u/simpel)\
**Replies:** 2\
**Last updated:** [June 5, 2021, 8:32am UTC](https://discourse.mc-stan.org/t/posterior-probability-for-models-with-splines-or-how-to-use-posterior-smooths/22776 "2021-06-05T08:32:07Z")

</div>

@paul.buerkner suggested posterior\_smooths as a substitute/work-around for hypothesis() for models with splines (Using \*\*hypothesis()\*\* with \*\*s()\*\* from \*\*brms\*\*). However, I can‘t get to grips with this approach. I t…

---

## [Probability that the response is below a given value, conditional on x in a hurdle-lognormal model with spline](https://discourse.mc-stan.org/t/probability-that-the-response-is-below-a-given-value-conditional-on-x-in-a-hurdle-lognormal-model-with-spline/22094)

<div class="topic-metadata">

**Author:** [@tamas.ferenci](https://discourse.mc-stan.org/u/tamas.ferenci)\
**Replies:** 4\
**Last updated:** [May 3, 2021, 6:30pm UTC](https://discourse.mc-stan.org/t/probability-that-the-response-is-below-a-given-value-conditional-on-x-in-a-hurdle-lognormal-model-with-spline/22094 "2021-05-03T18:30:40Z")

</div>

Take the following simple hurdle lognormal model with splines: library(brms) set.seed(1) N \<- 1000 x \<- runif(N) pi \<- 0.18 + 0.1\*x mu\_log \<- 1.8 + 0.3 \* x + 12.1 \* x^2 sigma\_log \<- 0.37 y \<- (1 - rbinom(N, 1, prob …

---

## [Constrained non-parametric smooths](https://discourse.mc-stan.org/t/constrained-non-parametric-smooths/21670)

<div class="topic-metadata">

**Author:** [@famuvie](https://discourse.mc-stan.org/u/famuvie)\
**Replies:** 4\
**Last updated:** [April 26, 2021, 10:01pm UTC](https://discourse.mc-stan.org/t/constrained-non-parametric-smooths/21670 "2021-04-26T22:01:08Z")

</div>

Dear all, I’m trying to model a dataset that looks like this: The data is structured into 5 series from two groups. The thick lines in the figure are just empirical smooths of the groups. I have theoretical reasons…

---

## [Splines in the event submodel of stan\_jm()](https://discourse.mc-stan.org/t/splines-in-the-event-submodel-of-stan-jm/22087)

<div class="topic-metadata">

**Author:** [@clairvoyant](https://discourse.mc-stan.org/u/clairvoyant)\
**Replies:** 3\
**Last updated:** [April 26, 2021, 1:28am UTC](https://discourse.mc-stan.org/t/splines-in-the-event-submodel-of-stan-jm/22087 "2021-04-26T01:28:57Z")

</div>

I have trouble including a spline transformation to one of the variables in the ‘event’ submodel of a stan\_jm() joint model. No issues with splines in the longitudinal submodel as you can see with the model specificatio…

---

## [Using a spline in the longitudinal submodel of stan\_jm](https://discourse.mc-stan.org/t/using-a-spline-in-the-longitudinal-submodel-of-stan-jm/21260)

<div class="topic-metadata">

**Author:** [@wittja01](https://discourse.mc-stan.org/u/wittja01)\
**Replies:** 3\
**Last updated:** [March 13, 2021, 10:34pm UTC](https://discourse.mc-stan.org/t/using-a-spline-in-the-longitudinal-submodel-of-stan-jm/21260 "2021-03-13T22:34:57Z")

</div>

I’m wondering if it is possible to include a covariate in the longitudinal submodel of a joint model as a spline, probably with one or two knots at most, when using stan\_jm. The longitudinal covariate I’m working with h…

[Next page](https://discourse.mc-stan.org/tag/splines/143.md?match_all_tags=true&page=1&tags%5B%5D=splines)
