Cannot replica a nls result


#1

Hello, I am getting two completely different result when using nls (where I get the correct answer) and brms (where I cannot). The data is this

> r3
aux pin1 aux1 pin
1 1.388655 6.591023 1.385943 6.503267
2 1.370443 6.503267 1.388655 6.469410
3 1.382679 6.469410 1.370443 6.405328
4 1.347952 6.405328 1.382679 6.420060
5 1.357052 6.420060 1.347952 6.422814
6 1.275295 6.422814 1.357052 6.383797
7 1.186480 6.383797 1.275295 6.375547
8 1.212150 6.375547 1.186480 6.442755
9 1.257206 6.442755 1.212150 6.459890
10 1.234539 6.459890 1.257206 6.362459
11 1.288101 6.362459 1.234539 6.407614
12 1.347652 6.407614 1.288101 6.438193
13 1.367419 6.438193 1.347652 6.462612
14 1.325210 6.462612 1.367419 6.315244
15 1.403423 6.315244 1.325210 6.291391
16 1.276356 6.291391 1.403423 6.398825
17 1.343016 6.398825 1.276356 6.290331
18 1.290664 6.290331 1.343016 6.257015
19 1.201854 6.257015 1.290664 6.305973

this is running nls:

> nls(aux ~ (k * pin1 * aux1) / (k*pin + 0.0045), data = r3,start = list(k=1))

Nonlinear regression model
  model: aux ~ (k * pin1 * aux1)/(k * pin + 0.0045)
   data: data.frame(r3)
      k 
0.06409 
 residual sum-of-squares: 0.06201

Number of iterations to convergence: 7 
Achieved convergence tolerance: 7.261e-08

the value of k is the expected one.

While with brms:

prior1 <- prior(normal(0, 1), nlpar = "k", lb=0)
fit1 <- brm(bf(aux ~ (k * pin1 * aux1) / (k*pin + 0.0045), k~ 1, nl = TRUE), data = r3, prior = prior1)
> fit1
    Population-Level Effects: 
                Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
    k_Intercept     0.75      0.59     0.05     2.20       2138 1.00

    Family Specific Parameters: 
          Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
    sigma     0.06      0.01     0.05     0.09       1655 1.00

any ideas?

thans


#2

On what basis do you call the nls result “expected”? By quickly running the model it seems as if k is barely identified by the data, let alone precisely located at about 0.06.

Also, the posterior distribution of k is skewed so that the mode may very well be around 0.06 while the mean is much higher. See plot(fit1)


#3

thanks, I suppose the model is simply badly specified