Nonlinear model with grouped data and a single control, model specification problem in BRMS

Hello,
I am looking at a nonlinear model (simple first order on “Treatment”,
top - (top-bottom)exp(-rateTreatment) where top is the asymptote and “bottom” is a constant lifting the curve away from 0). Think of this as similar to rate kinetics and the “Treatment” could just be time. In my case Treatment is a supplement given in an animal trial that results in this curve shape. Here is some synthetic data:

Synthetic Data

library(tidyverse)
library(brms)
library(ggmcmc)

set.seed(1)

# set up Treatment levels
Treatment <- c(0, 2.1, 4.5, 6.5)

#replicates at each Treatment level
rep = 1:50

# lets also have a grouping G, so 50 are by G1 and 50 by G2
Group <- c("A","B")

# set up first order curve

#curve parameters: Response ~ top - ((top-bottom)*exp(-rate * Treatment)
top = 14
bottom = 8
rate = 0.22

# this is set up as continuous Response in "Response" 

SynthData <- expand_grid(Treatment, Group, rep) %>%
  mutate(Response = top - (top-bottom)*exp(-rate*Treatment)) %>%
  mutate(Response = ifelse(Group == "A",Response+0.5,Response )) %>% # +0.5 bias in A group
  rowwise() %>%
  mutate(Response = Response + rnorm(1,0,0.5)) %>%
  ungroup() %>%
  mutate(Control = "no")

So there is a grouping, perhaps one could think of the grouping factor as different animal houses resulting in a slight bias of around +0.5 for the “A” group. Secondly, I want to introduce a one level control. This could be an alternative formulation of the treatment added to the experiment at only one level to minimize costs of the trial:

# make a control group at a single Treatment level. 
# This is just treatment 2.1 shifted up by Y +2

Control <- SynthData %>%
  filter(Treatment == 2.1) %>%
  filter(Group == "A") %>%
  mutate(Control = "Yes") %>%
  mutate(Response = Response+2)
  
SynthData <- rbind(SynthData, Control)  

This lifts the response up by 2 units compared to the rest of the data.

Visualization:

ggplot(SynthData, aes(x=Treatment, y= Response))+
  geom_point(aes(color = Group, shape = Control))+
  theme_bw()

BRMS specification

# nonlinear, continuous scale for response
# Initial kicks
init_func <- function(chain_id=1) {
  list ( b_top  =  array(14) ,
         b_bottom  =  array(8.5) ,
         b_rate  =  array(0.2),
         b_Group = array(0.5),
         b_Control = array(2))
}

# setting up chains
init_list <- list(
  init_func(chain_id = 1),
  init_func(chain_id = 2),
  init_func(chain_id = 3),
  init_func(chain_id = 4)
)

# NUTS configuration
control <- list(
  adapt_engaged = TRUE,
  adapt_delta = 0.9, #increased from default of 0.8
  stepsize = 0.08, # 0.05 default
  max_treedepth = 15 # was 15
)

prior1 <- prior(normal(14, 1), nlpar = "top") + 
  prior(normal(8.0, 1), nlpar = "bottom")+         
  prior(normal(0.2, 0.1), nlpar = "rate")+
  prior(normal(0.5, 1), nlpar = "Group"  )+
  prior(normal(2, 1), nlpar = "Control"  )


fit1 <- brm(bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)) + Group + Control, top + bottom + rate + Group + Control ~ 1, nl = TRUE),
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit14"
)

# inspect results
summary(fit1)

Fitting results

Model seems to fit OK

Family: gaussian
Links: mu = identity; sigma = identity
Formula: Response ~ top - ((top - bottom) * exp(-rate * Treatment)) + Group + Control
top ~ 1
bottom ~ 1
rate ~ 1
Group ~ 1
Control ~ 1
Data: SynthData (Number of observations: 450)
Draws: 4 chains, each with iter = 4000; warmup = 2000; thin = 2;
total post-warmup draws = 4000

Regression Coefficients:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
top_Intercept 12.81 0.63 11.60 14.03 1.00 3131 3358
bottom_Intercept 8.10 0.62 6.91 9.30 1.00 3160 3361
rate_Intercept 0.41 0.03 0.35 0.47 1.00 3734 3380
Group_Intercept -0.63 0.77 -2.18 0.84 1.00 3385 3329
Control_Intercept 0.89 0.77 -0.61 2.40 1.00 3427 3075

Further Distributional Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sigma 0.82 0.03 0.77 0.87 1.00 3921 3192

..but the control group is not at +2
Chains do all seem to converge and the model is taking my initial values:

# fit process visualization
ggs(fit1, burnin = TRUE) %>%
  filter(Parameter == "b_Control_Intercept") %>% 
  mutate(chain = factor(Chain),
         intercept = value) %>% 
  
  ggplot(aes(x = Iteration, y = intercept, color = chain)) +
  geom_line()+
  ggtitle("default settings")+
  theme_bw()

Here is a visualization of the synthetic data overlayed with the predicted values from the model:

testPred <- predict(
  fit1,
  type = "response")

SynthData$Estimate <- testPred[,1]

#Visualize
ggplot(SynthData, aes(x=Treatment, y= Response))+
  geom_point(aes(color = Group, shape = Control))+
  geom_point(aes(x=Treatment, y=Estimate, color = Group, shape = Control), size = 6)+
  theme_bw()

I think this must be a simple model specification problem when I moved over to running nonlinear models. My actual data is ordinal, but I wanted to make sure the non-linear and grouping is correct before I move onto a logit response dataset. Can anyone point me in the right direction?
Thanks!

Oh, maybe I’ve found something wrong. It is to do with the model specification:

prior1 <- prior(normal(14, 1), nlpar = "top") + 
  prior(normal(8.0, 1), nlpar = "bottom")+         
  prior(normal(0.2, 0.1), nlpar = "rate")+
  prior(normal(2, 1), nlpar = "KG5"  )

# prior(normal(0.5, 1), nlpar = "Group"  )+

fit1 <- brm(bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)) + KG5, 
               top + bottom + rate ~ 1, 
               KG5 ~ 1 + Control, # < change here, now can add factor 
               nl = TRUE),        # drawing from "control" column
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit14"
)

Visualize

testPred <- predict(
  fit1,
  type = "response")

SynthData$Estimate <- testPred[,1]

#Visualize
ggplot(SynthData, aes(x=Treatment, y= Response))+
  geom_point(aes(color = Group, shape = Control))+
  geom_point(aes(x=Treatment, y=Estimate, color = Group, shape = Control), size = 6)+
  theme_bw()

So i can now see the control group correctly fitting.
My knowledge on formulating these BRMS models is a bit hit and miss. Does anyone know of a good resource that tackles this in a systematic way?

Thomas

Hi Thomas,

I’ve been there, struggling with where to place covariates in a nonlinear model. The key thing to grasp is that covariates are no longer part of the main formula.

we should think of non-linear parameters as placeholders for linear predictor terms rather than as parameters themselves link

So let’s assume for a moment, you have both control and, well, non-control, for both of your groups. Your non-linear model has three parameters (top, bottom, rate) and each has its own linear model, which can be intercept-only top ~ 1 etc or contain predictors. The a + b + c ~ 1 syntax is a convenience to indicate that all parameters are related to the same linear model.

That model would look like this:

bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)), 
               top ~ Group + Control + Group:Control, 
               bottom ~ Group + Control + Group:Control,
               rate ~ Group + Control + Group:Control,
               nl = TRUE)

However in your case, I am not sure that it makes sense to do anything other than:

  • estimate the non-linear relationship for the non-control cases
  • estimate the control/no-control difference for the level of treatment where you have both, in a separate model
1 Like

Oh, its still nock clicking with me. If I use this in the model specification it gives this error:

Error: The following priors do not correspond to any model parameter: 
b_Analyst ~ normal(0.5, 1)
b_KG5 ~ normal(2, 1)
Function 'default_prior' might be helpful to you.

Here is the snipit of code:

# nonlinear, continuous scale for response
# Initial kicks
init_func <- function(chain_id=1) {
  list ( b_top  =  array(14) ,
         b_bottom  =  array(8.5) ,
         b_rate  =  array(0.2),
         b_Group = array(0.5),
         b_Control = array(2))
}

# setting up chains
init_list <- list(
  init_func(chain_id = 1),
  init_func(chain_id = 2),
  init_func(chain_id = 3),
  init_func(chain_id = 4)
)

# NUTS configuration
control <- list(
  adapt_engaged = TRUE,
  adapt_delta = 0.9, #increased from default of 0.8
  stepsize = 0.08, # 0.05 default
  max_treedepth = 15 # was 15
)

prior1 <- prior(normal(14, 1), nlpar = "top") + 
  prior(normal(8.0, 1), nlpar = "bottom")+         
  prior(normal(0.2, 0.1), nlpar = "rate")+
  prior(normal(0.5, 1), nlpar = "Analyst")+
  prior(normal(2, 1), nlpar = "KG5"  )

# prior(normal(0.5, 1), nlpar = "Group"  )+

fit_Angelos <- brm(bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)), 
               top ~ Group + Control + Group:Control, 
               bottom ~ Group + Control + Group:Control,
               rate ~ Group + Control + Group:Control,
               nl = TRUE),
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit_Angelos"
)

I’ve tried replacing “Analyst” with “Group” and “KG5” with “Control” in the priors section but this then gives me:

Error: The following priors do not correspond to any model parameter: 
b_Group ~ normal(0.5, 1)
b_Control ~ normal(2, 1)
Function 'default_prior' might be helpful to you.

I suspect the problem is that neither Group nor Control is in a non-linear relationship. Both are in linear models for top, bottom, and rate. If that’s right then changing prior1 to


prior1 <- prior(normal(14, 1), nlpar = "top") + 
  prior(normal(8.0, 1), nlpar = "bottom")+         
  prior(normal(0.2, 0.1), nlpar = "rate")+
  prior(normal(0.5, 1), coef = "Group")+
  prior(normal(2, 1), coef = "Control")
```

I have used nl very little, so this could easily be completely off base.

top of the synthetic dataset looks like this:

This code seems to work:

# Initial kicks
init_func <- function(chain_id=1) {
  list ( b_top  =  array(14) ,
         b_bottom  =  array(8.5) ,
         b_rate  =  array(0.2),
         b_Group = array(0.5),
         b_Control = array(2))
}

# setting up chains
init_list <- list(
  init_func(chain_id = 1),
  init_func(chain_id = 2),
  init_func(chain_id = 3),
  init_func(chain_id = 4)
)

# NUTS configuration
control <- list(
  adapt_engaged = TRUE,
  adapt_delta = 0.9, #increased from default of 0.8
  stepsize = 0.08, # 0.05 default
  max_treedepth = 15 # was 15
)

prior1 <- prior(normal(14, 1), nlpar = "top") + 
  prior(normal(8.0, 1), nlpar = "bottom")+         
  prior(normal(0.2, 0.1), nlpar = "rate")+
  prior(normal(0.5, 1), nlpar = "Group")+
  prior(normal(2, 1), nlpar = "Control"  )

# prior(normal(0.5, 1), nlpar = "Group"  )+

fit1 <- brm(bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)) + Group + Control, 
               top + bottom + rate ~ 1, 
               Control ~ 1, 
               Group ~ 1,
               nl = TRUE),
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit14"
)

The bf statement for the nonlinear equation does seem to need references to the factors Group and Control. I am not clear on the second set of formulae:

top + bottom + rate ~ 1, 
               Control ~ 1, 
               Group ~ 1,

I thought this just specified that all these variables just affects the intercepts, but you have a more complex set of formulae:

top ~ Group + Control + Group:Control, 
               bottom ~ Group + Control + Group:Control,
               rate ~ Group + Control + Group:Control,

This looks like each parameter in the main nonlinear formula is getting its own formula outlining its relationship to the factor columns in data. Maybe I am having a glimer of understanding to the statement:

we should think of non-linear parameters as placeholders for linear predictor terms rather than as parameters themselves link

Thomas

In a non-linear model, you no longer have the implicit intercept-slope combo that you get when you specify a linear model using the lme4-type syntax. You are explicitly defining the non-linear relationship, naming all its parameters and then each of these parameters needs its own linear model. Adding the covariates in the non-linear formula does not do what you think it does.

Your non-linear relationship is of the form:

y = a - (a - b) \cdot e^{-c \cdot x}

If you just add group in your formula, you have now changed that equation to

y = a - (a - b) \cdot e^{-c \cdot x} + d

you’ve just given d the name Group, same as you named a top.

What you want to do instead, is specify that a, b and c take different values for one group than for the other. So top + bottom + rate ~ group (or written out top ~ group, bottom ~ group, rate ~ group) will estimate these parameters for the reference group and the difference of the parameters in the other group.

As a simpler example, here are three different ways to specify the same linear model, with the standard linear syntax and the non-linear syntax.

Does that help?

Yes this helps!

so if all those parameters, top, bottom and rate are affected by group we have:

top + bottom + rate ~ group

but if I know rate is the same for both groups, but the position of top and bottom will change (i.e. the whole curve just shifts on the y axis then:

top + bottom ~ group

if top and bottom is also affected by some other groupings we could put this:

top + bottom ~ group + anotherGroup + andAnother

Thanks For speaking slowly!

Thomas

Ok still having problems.

Thanks kholsinger, I had Group and Control as nlpar’s not plain vanilla coef’s in the prior’s declarations.

I’ve added the brms formula

bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)), 
               top + bottom + rate ~ Group, 
               top + bottom + rate ~ Control,
               nl = TRUE)

…according to amynang

But this is now giving me this error:

Here is the complete model code (same synthetic dataset as at the top of the thread).

# Initial kicks
init_func <- function(chain_id=1) {
  list ( b_top  =  array(14) ,
         b_bottom  =  array(8.5) ,
         b_rate  =  array(0.2),
         b_Group = array(0.5),
         b_Control = array(2)
         )
}

# setting up chains
init_list <- list(
  init_func(chain_id = 1),
  init_func(chain_id = 2),
  init_func(chain_id = 3),
  init_func(chain_id = 4)
)

# NUTS configuration
control <- list(
  adapt_engaged = TRUE,
  adapt_delta = 0.9, #increased from default of 0.8
  stepsize = 0.08, # 0.05 default
  max_treedepth = 15 # was 15
)

prior1 <- prior(normal(14, 1), nlpar = "top") + 
  prior(normal(8.0, 1), nlpar = "bottom")+         
  prior(normal(0.2, 0.1), nlpar = "rate")+
  prior(normal(0.5, 1), coef = "Group")+
  prior(normal(2, 1), coef = "Control"  )

# prior(normal(0.5, 1), nlpar = "Group"  )+

fit1 <- brm(bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)), 
               top + bottom + rate ~ Group, 
               top + bottom + rate ~ Control,
               nl = TRUE),
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit14"
)

You are all being very helpful please keep sending me suggestions!

Thomas

And if I run it like this:

fit1 <- brm(bf(Response ~ top - ((top-bottom)*exp(-rate * Treatment)), 
               top ~ Group + Control, 
               bottom ~ Group + Control, 
               rate ~ Group + Control,
               nl = TRUE),
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit14"
)

I get this error:

image

Might I suggest that you follow through with that default_prior hint that brms has been giving you? ;)

I will repeat that adding the control/nocontrol thing to the model does not make sense with your data. I would suggest figuring things out first without the control portion of the data.

Right. I have no problems splitting out the data and running a simpler model on the nonlinear data. Problems start when linear and nonlinear terms are mixed. Probably a way to do it but maybe not within the BRMS wrapper?..and like you said, the control data are just single levels, so it doesent make a lot of sense to try forcing it into the nonlinear treatment. Maybe I was being lazy and hoping to get all the terms to pop out of a single summary table!

Unfortunately I’ve run out of time in this particular case and will have to come back to it later after learning some of the underlying STAN code as the current documentation in BRMS seems unavailable.

Yes deleting out the control group works fine and there are vignettes out there on constructing these very simple data structures and running a simple single nonlinear relationship in BRMS.

No, all the data set of a DOE should go into the regression analysis, but it does have to be coded correctly and have the correct attribute columns in the dataset to specify the grouping. Besides, why shouldn’t it work?

Here is an interesting discussion on a very similar problem:

Declaration Nonlinear mixed effects model in BRMS

Funnily enough there is a recommendation that a fixed effect can just get inserted into the nonlinear formula. Works as you showed in your equations and my initial attempt. Quite valid if this is just a constant getting added dependent on some grouping factor….and yes this does work for this synthetic dataset, but I can definitely see the advantages of adding this in its own formula (like what if the rate also is affected, dumping this into one huge formula would make it unreadable). I just cant seem to get BRMS to accept the coding. I think its something to do with the specification of the priors.

In the above reference mmihaylova added a fixed effect “Cat” as a test out…but there must have been an addition to the priors section for “Cat” that is not mentioned.

Here is the brm coding so far:

I’ve simplified the formula (same synthetic data though):

# taking linear terms out of nonlinear formula

# nonlinear, continuous scale for response
# Initial kicks
init_func <- function(chain_id=1) {
  list ( b_Asym  =  array(14) ,
         b_A  =  array(6) ,
         b_rate  =  array(0.2),
         #b_Group = array(0.5),
         b_Control = array(2)
         )
}

# setting up chains
init_list <- list(
  init_func(chain_id = 1),
  init_func(chain_id = 2),
  init_func(chain_id = 3),
  init_func(chain_id = 4)
)

# NUTS configuration
control <- list(
  adapt_engaged = TRUE,
  adapt_delta = 0.9, #increased from default of 0.8
  stepsize = 0.08, # 0.05 default
  max_treedepth = 15 # was 15
)

prior1 <- prior(normal(14, 1), nlpar = "Asym") + 
  prior(normal(6, 1), nlpar = "A")+         
  prior(normal(0.2, 0.1), nlpar = "rate")+
  prior(normal(0.4,0.03 ), class="b", group="Control", nlpar="Asym")
  

# prior(normal(0.5, 1), nlpar = "Group"  )+

fit1 <- brm(bf(Response ~ Asym - ((A)*exp(-rate * Treatment)), 
               Asym ~ 1 + Control, # + Group,
               A ~ 1,
               rate ~ 1,
               nl = TRUE),
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit14"
)

summary(fit1)

# fit process visualization
ggs(fit1, burnin = TRUE) %>%
  filter(Parameter == "b_KG5_Intercept") %>% 
  mutate(chain = factor(Chain),
         intercept = value) %>% 
  
  ggplot(aes(x = Iteration, y = intercept, color = chain)) +
  geom_line()+
  ggtitle("default settings")+
  theme_bw()
```

I’ve commented out “Group” out of the model and priors & initial values. Its only a small effect in the synthetic data. I’m making some guesses here. The grouping has to be declared in the prior, so that presumably “group=”Control”, and I am assuming this has to be tied to a parameter in the nonlinear formula declaration and this is the nlpar=”Asym”.

There is definitely something wrong in the prior:

image

This ref too:

Specifying a nonlinear mixed effects model in BRMS

looking at adding random effects to a nonlinear model, no fixed effect though.

I think I must be getting close. Here is another similar query:

posted here: Non-linear mixed effects model specification

Mysteriously the coef call has an added suffix “M” or “P”. But this is the first time i’ve seen fixed effects called in a nonlinear setup. I’ve also trawled through set_prior manual but, although a lot of this is going over my head, I’m not seeing anything there that wouldnt make “normal(xbar,sd”, class”b”, coef=”groupingName”, nlpar=”ref nlpar parameter here”) the logical syntax.

However when I use this syntax, it looks like STAN spits back this to brms:

pretty obvious its croaking on the priors syntax.

Thomas

@amyang

I did try default_prior function:

clear as mud.

help anyone?

Thomas

OK, apologies for my previous cranky comment. This is not intuitive. What the default_prior output shows you, is that some priors need to be identified both by their coef and nlpar labels. And their proper labels are indicated by the output. So in your last example one is identified by coef=“ControlYes” and nlpar=“Asym”.

However, you could just provide priors for the nonlinear parameters alone, i.e. this

prior1 <- prior(normal(14, 1), nlpar = "Asym") + 
  prior(normal(6, 1), nlpar = "A")+         
  prior(normal(0.2, 0.1), nlpar = "rate")

should be enough.

Regarding your all-in-one model, as I understand it, you are making the strong assumption that the difference of this “alternative formulation of the treatment” is constant across the levels of treatment.

leaving out the prior for “Control” allowed BRMS to write the STAN code, but during the run I get this failure:

SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
Chain 1: Unrecoverable error evaluating the log probability at the initial value.
Chain 1: Exception: mismatch in dimension declared and found in context; processing stage=parameter initialization; variable name=b_Asym; position=0; dims declared=(2); dims found=(1) (in 'string', line 20, column 2 to column 24)
[1] "Error : Exception: mismatch in dimension declared and found in context; processing stage=parameter initialization; variable name=b_Asym; position=0; dims declared=(2); dims found=(1) (in 'string', line 20, column 2 to column 24)"
[2] "In addition: Warning messages:"                                                                                                                                                                                                      
[3] "1: package 'rstan' was built under R version 4.4.3 "                                                                                                                                                                                 
[4] "2: package 'StanHeaders' was built under R version 4.4.3 "                                                                                                                                                                           
[1] "error occurred during calling the sampler; sampling not done"
```

and the code including commenting out of the fixed effects priors:

init_func <- function(chain_id=1) {
  list ( b_Asym  =  array(14),
         b_A  =  array(6),
         b_rate  =  array(0.2) #,
        # b_Control = array(2)
         )
}

# setting up chains
init_list <- list(
  init_func(chain_id = 1),
  init_func(chain_id = 2),
  init_func(chain_id = 3),
  init_func(chain_id = 4)
)

# NUTS configuration
control <- list(
  adapt_engaged = TRUE,
  adapt_delta = 0.9, #increased from default of 0.8
  stepsize = 0.08, # 0.05 default
  max_treedepth = 15 # was 15
)

prior1 <- prior(normal(14, 1), nlpar = "Asym") + 
  prior(normal(6, 1), nlpar = "A")+         
  prior(normal(0.2, 0.1), nlpar = "rate") #+
  #prior(normal(0.4,0.03 ), class="b", coef="Control", nlpar="Asym")
  

get_prior(
  bf(Response ~ Asym - ((A)*exp(-rate * Treatment)), 
     Asym ~ 1 + Control, # + Group,
     A ~ 1,
     rate ~ 1,
     nl = TRUE),
  data = SynthData, 
  prior = prior1,
  #family = cumulative(link="logit", threshold="flexible"),
  iter = 4000 , warmup = 2000, thin = 2,
  chains = 4, cores=6,
  init = init_list, 
  control = control,
  #file = "./model/fit14"
)


# prior(normal(0.5, 1), nlpar = "Group"  )+

fit1 <- brm(bf(Response ~ Asym - ((A)*exp(-rate * Treatment)), 
               Asym ~ 1 + Control, # + Group,
               A ~ 1,
               rate ~ 1,
               nl = TRUE),
            data = SynthData, 
            prior = prior1,
            #family = cumulative(link="logit", threshold="flexible"),
            iter = 4000 , warmup = 2000, thin = 2,
            chains = 4, cores=6,
            init = init_list, 
            control = control,
            #file = "./model/fit14"
)

Any thoughts here?

Thomas

Of course you are generally right about the structure of the DOE. Note that in a situation like this a single level treatment is usually of a positive control, so by definition it would have a very well known effect in the application from previous animal studies.

I suppose I could have chosen the “Group” factor in the synthetic dataset, as that affects all the treatment levels and would have been better form perhaps? Anyway, this is just synthetic data to try and understand how BRMS works before launching into the real larger dataset that takes near two hours to process.

Thomas