I’m hardly expert on this issue given that I’m stuck with my own non-linear model, but I see two improvements that will get yours to fit.
1) Strengthen the prior on “lambda”
\mathcal{N}(-1,10) is pretty weak, and as I understand it non-linear models need extra attention to the prior specification in order to converge. How you go about this might be a bit more challenging. It’s clear how to proceed if, say, lambda = 10
is biologically unreasonable in your study system. But if those extreme values are plausible, others would have to weigh in.
2) Rescale model parameters
From another post, @paul.buerkner recommends:
Putting the two together, I come to:
fit_lactin <- brm(
bf(growthrate ~ exp(rho*temperature) - exp(rho*TmaxSC*10 - (TmaxSC*10-temperature)/delta) + lambdaSC/10,
rho ~ 1,
TmaxSC ~ 1,
delta ~ 1,
lambdaSC ~ 1,
nl = TRUE),
data = ryandata, family = gaussian(),
prior = c(
prior(normal(0.1,10), nlpar = "rho"),
prior(normal(4.2,1.0), nlpar = "TmaxSC", lb = 0.1, ub = 5.0),
prior(normal(7,10), nlpar = "delta"),
prior(normal(-10,2), nlpar = "lambdaSC")
),
warmup = 5000, iter = 10000, chains = 2, cores = 2,
control = list(adapt_delta = 0.95)
)
You can see that I’ve just multiplied Tmax
and divided lambda
—both in the model formula and in the priors—to bring them onto a similar order of magnitude as the other parameters. I append “SC” as a suffix to remind myself that the posteriors for these parameters need to be back-transformed. Although it’s a bit harder to see because of this scaling, I’ve also dramatically narrowed the prior on lambda
. This fits reasonably quickly and gives the following:
Population-Level Effects:
Estimate Est.Error l-95% CI
rho_Intercept 0.08 0.01 0.07
TmaxSC_Intercept 4.38 0.01 4.35
delta_Intercept 7.07 0.56 5.94
lambdaSC_Intercept -9.52 0.62 -10.52
u-95% CI Eff.Sample Rhat
rho_Intercept 0.09 1902 1.00
TmaxSC_Intercept 4.40 3831 1.00
delta_Intercept 8.03 2010 1.00
lambdaSC_Intercept -8.01 2593 1.00
Family Specific Parameters:
Estimate Est.Error l-95% CI u-95% CI
sigma 0.17 0.02 0.14 0.22
Eff.Sample Rhat
sigma 4260 1.00
These correspond (after backtransforming the “SC” parameters) quite nicely to the estimates from nls
:
Parameters:
Estimate Std. Error t value Pr(>|t|)
rho 0.073298 0.006612 11.086 2.57e-13 ***
Tmax 43.789369 0.148651 294.579 < 2e-16 ***
delta 6.928933 0.858966 8.067 1.13e-09 ***
lambda -0.980015 0.044927 -21.813 < 2e-16 ***
I hope this helps in your case, but so far these “tricks” haven’t gotten me out of my issue. I would also be keen to learn about the strategies for re-parameterization. I also haven’t been able to find specific, practical suggestions on this front. Perhaps these strategies could help you make use of weaker priors that you may have to use when fitting other data to this model.