I am running my first nonlinear model in brms, and it is also multivariate. I am new to brms, so forgive me if I am missing something obvious. When I try to run this model, the parameter what1 is not recognized as a model parameter. Thank you if you can see what I am doing wrong. The data I have looks like this:
head(Obs)
x1 x2 x3 tx1 tx2 tx3 y1 y2 y3 yt1 yt2 yt3 E
1 10 10 10 0.4 0.5000000 0.6 18 17 15 0.4 0.4952381 0.6 0.1
2 18 17 15 0.4 0.4952381 0.6 31 28 22 0.4 0.4905329 0.6 0.1
3 31 28 22 0.4 0.4905329 0.6 53 45 32 0.4 0.4858837 0.6 0.1
4 53 45 32 0.4 0.4858837 0.6 89 70 46 0.4 0.4812898 0.6 0.1
5 89 70 46 0.4 0.4812898 0.6 143 105 64 0.4 0.4767507 0.6 0.1
6 143 105 64 0.4 0.4767507 0.6 219 147 85 0.4 0.4722655 0.6 0.1
mod_N1 <- bf(y1 ~ (((what1*exp((-(((w + (1-h21)*P) / (P+w)) * (E-tx1))^2) / (2*(P+w))))*x1) / (1 + a11*x1 + a12*x2 + a13*x3)),
a11~1,a12~1,a13~1,what1~1,w~1,P~1,h21~1,
nl=TRUE)
mod_N2 <- bf(y2 ~ (((what2*exp((-(((w + (1-h22)*P) / (P+w)) * (E-tx2))^2) / (2*(P+w))))*x2) / (1 + a22*x2 + a21*x1 + a23*x3)),
a22+a21+a23+what2+w+P+h22~1,
nl=TRUE)
mod_N3 <- bf(y3 ~ (((what3*exp((-(((w + (1-h23)*P) / (P+w)) * (E-tx3))^2) / (2*(P+w))))*x3) / (1 + a33*x3 + a31*x1 + a32*x2)),
a33+a31+a32+what3+w+P+h23~1,
nl=TRUE)
p <- get_prior(mod_N1 + mod_N2 + mod_N3, data = Obs)
# N1
p$prior[5] <- "beta(1, 10)" # a11
p$prior[7] <- "beta(1, 10)" # a12
p$prior[9] <- "beta(1, 10)" # a13
p$prior[11] <- "beta(2, 2)" # h21
p$prior[13] <- "gamma(0.5, 1)" # P
p$prior[15] <- "gamma(0.5, 1)" # w
p$prior[17] <- "normal(0, 2)" # what1
# N2
p$prior[20] <- "beta(1, 10)" # a21
p$prior[22] <- "beta(1, 10)" # a22
p$prior[24] <- "beta(1, 10)" # a23
p$prior[26] <- "beta(2, 2)" # h22
p$prior[28] <- "gamma(0.5, 1)" # P
p$prior[30] <- "gamma(0.5, 1)" # w
p$prior[32] <- "normal(0, 2)" # what2
# N3
p$prior[35] <- "beta(1, 10)" # a31
p$prior[37] <- "beta(1, 10)" # a32
p$prior[39] <- "beta(1, 10)" # a33
p$prior[41] <- "beta(2, 2)" # h23
p$prior[43] <- "gamma(0.5, 1)" # P
p$prior[45] <- "gamma(0.5, 1)" # w
p$prior[47] <- "normal(0, 2)" # what3
fit <- brm(mod_N1 + mod_N2 + mod_N3, data = Obs, chains = 2,inits=0,prior=p,family=gaussian(link = "identity"))
The error message is:
SAMPLING FOR MODEL ‘34a348d533a189f4c70d5b2c02df0bc6’ NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Error evaluating the log probability at the initial value.
Chain 1: Exception: multi_normal_cholesky_lpdf: Location parameter[1] is nan, but must be finite! (in ‘model70c542728a9c_34a348d533a189f4c70d5b2c02df0bc6’ at line 182)
[1] “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”
error occurred during calling the sampler; sampling not done
I have attached a .txt file with the data.
*OperatingSystem:Mac OS 10.13.6
*brms Version:2.9.0Obs.txt (83.7 KB)