Hi all,
I am still learning how to formulate models in brms (and lme4 syntax generally), so any help would be greatly appreciated. I am trying to model the following relationship:
q_z~N(q_CPT,sig_within) #within-CPT variability
q_CPT~N(q_site,sig_between) #spatial variability across site
q_site~N(q_site_lowest,standard_error) #bias site representative qc
I am trying to predict occurrences of liquefaction at a site based on various predictor variables. One of the predictor variable is normalized tip resistance, qc1ncs, which is measured (rather, calculated) from CPT tests performed within a site. A CPT test is performed by drilling into the ground and collecting data with depth. So for each CPT, there will be an array of q_z data. At each site, there could be multiple CPT tests performed. So, I am trying obtain a latent variable of qc1ncs, q_site that accounts for the within and spatial variability of qc1ncs. Additionally, I believe that q_site is likely closer to the lowest qc1ncs across all CPTs (i.e., q_site_lowest), and that the lowest qc1ncs data may even be missing from the data, alas I assign epistemic uncertainty to its estimate defined by standard_error.
I have the group factor case_id which is assigned to all q_z that belongs to the same site. So far, I have something like the following:
data = data.frame(case_id,A_est,sig_A,q_z,q_site_lowest,standard_error)
formula <- bf(y | (A - ( b0 + (1/b1)) ) / C,
b0 ~ 1,
b1 ~ 0 + I(1/me(q_site, standard_error)),
A~ 0 + me(A_est,sig_A),
C ~ 1,
q_site~ 0 + offset(q_site_lowest),
q_z ~ 0 + q_site+ (1 | case_id),
nl = TRUE)
c(prior(normal(-2.5,0.5), nlpar="b0"),
prior(normal(110.0,10.0), nlpar="b1", lb=0),
prior(cauchy(0,1), nlpar="C", lb=0),
prior(constant(1.0), nlpar="A"),
prior(exponential(1), class = "sigma", resp = "q_z "),
prior(normal(0, 0.15), class = "sd", group ="case_id", resp = "q_z "),
prior(normal(0, 0.3), class = "b", nlpar = "q_site")
)
fit<- brm(formula , data=data, prior=prior, family=bernoulli(link="probit"), iter=4000, seed=123)
Evidently, I am getting an error saying that q_z is not a valid distributional or non-linear parameter because of the nl=TRUE term. Wondering if there is a right way to achieve the aforementioned relationship?
- Operating System: Windows 11
- brms Version: 2.23
Again, any help would be greatly appreciated. Thanks!