Errors with non-linear formulas in multinomial model

I have some data from a behavioural experiment with multiple potential choice options that I want to fit with a non-linear model. To ensure I am setting the appropriate priors, I’m attempting to use get_prior to get a handle on which parameters need priors. However, this seems to give me the error message, “Error: The parameter ‘name’ is not a valid distributional or non-linear parameter. Did you forget to set ‘nl = TRUE’?”, and I’m not sure why.

Here is a reproducible example of the issue:

tmp <- data.frame(X = sample(c("condition1", "condition2"), size=1000, replace=TRUE))
tmp$weight1 <- ifelse(tmp$X=="condition1",
                      rnorm(1000, 1, 1)+rnorm(1000, 0.5, 1),
                      rnorm(1000, 1, 1))
tmp$weight2 <- ifelse(tmp$X=="condition1",
                      rnorm(1000, 1, 1),
                      rnorm(1000, 1, 1)+rnorm(1000, 0.5, 1))
tmp$weight3 <- rnorm(1000, 0.5, 1)
tmp$response <- ""
for (i in 1:1000){
  tmp$response[i] <- sample(c("response1", "response2", "response3"),
                       size=1,
                       prob=c(exp(tmp$weight1[i])/
                                (exp(tmp$weight1[i]) + exp(tmp$weight2[i]) + exp(tmp$weight3[i])),
                              exp(tmp$weight2[i])/
                                (exp(tmp$weight1[i]) + exp(tmp$weight2[i]) + exp(tmp$weight3[i])),
                              exp(tmp$weight3[i])/
                                (exp(tmp$weight1[i]) + exp(tmp$weight2[i]) + exp(tmp$weight3[i]))))
}

testFormula <- bf(response ~ x1 + x2,
                  muresponse2 ~ x1 + x3,
                  muresponse3 ~ x4,
                  x1 ~ 1,
                  x2 ~ X,
                  x3 ~ X,
                  x4 ~ 1,
                  nl=TRUE,
                  family = categorical(link="logit"))
get_prior(testFormula, data=tmp)
> Error: The parameter 'x1' is not a valid distributional or non-linear parameter. Did you forget to set 'nl = TRUE'?

One variation I tried was specifying the different responses within nlf() (as per the post here). This gives the same error, but concerning a different parameter:

testFormula <- bf(response ~ x1 + x2,
                  nlf(muresponse2 ~ x1 + x3),
                  nlf(muresponse3 ~ x4),
                  x1 ~ 1,
                  x2 ~ X,
                  x3 ~ X,
                  x4 ~ 1,
                  nl=TRUE,
                  family = categorical(link="logit"))
get_prior(testFormula, data=tmp)
> Error: The parameter 'x2' is not a valid distributional or non-linear parameter. Did you forget to set 'nl = TRUE'?

However, if I comment out the non-linear formula for the third response (and the associated x4 parameter), get_prior works:

testFormula <- bf(response ~ x1 + x2,
                  nlf(muresponse2 ~ x1 + x3),
                  #nlf(muresponse3 ~ x4),
                  x1 ~ 1,
                  x2 ~ X,
                  x3 ~ X,
                  #x4 ~ 1,
                  nl=TRUE,
                  family = categorical(link="logit"))
get_prior(testFormula, data=tmp)
> prior class        coef group resp dpar nlpar lb ub       source
 (flat)     b                                              default
 (flat)     b                                x1            default
 (flat)     b   Intercept                    x1       (vectorized)
 (flat)     b                                x2            default
 (flat)     b   Intercept                    x2       (vectorized)
 (flat)     b Xcondition2                    x2       (vectorized)
 (flat)     b                                x3            default
 (flat)     b   Intercept                    x3       (vectorized)
 (flat)     b Xcondition2                    x3       (vectorized)

This is also the case if I comment out the formula for the second response (and associated x3 parameter):

testFormula <- bf(response ~ x1 + x2,
                  #nlf(muresponse2 ~ x1 + x3),
                  nlf(muresponse3 ~ x4),
                  x1 ~ 1,
                  x2 ~ X,
                  #x3 ~ X,
                  x4 ~ 1,
                  nl=TRUE,
                  family = categorical(link="logit"))
get_prior(testFormula, data=tmp)
> prior class        coef group resp dpar nlpar lb ub       source
 (flat)     b                                              default
 (flat)     b                                x1            default
 (flat)     b   Intercept                    x1       (vectorized)
 (flat)     b                                x2            default
 (flat)     b   Intercept                    x2       (vectorized)
 (flat)     b Xcondition2                    x2       (vectorized)
 (flat)     b                                x4            default
 (flat)     b   Intercept                    x4       (vectorized)

I am clearly doing something wrong, but I can’t see what it is, so would appreciate any assistance a set of fresh eyes could provide.

I’ve still not figured out what is behind this problem, but I have been able to circumvent it by setting the response with the simplest formula (e.g., response3 in my reproducible example above) as the reference category. I don’t know why this works, but it seems to! Hopefully this information will be useful if anyone else runs across a similar problem in future.