I learned the picewise regression in brms by 1 and 2.
But I still don’t get how build the formula in brms.
This is my date
date.csv (129.1 KB)
first I fitted a simple model like this:
fit<-brm(Length~type*num+(1|location)+(1|G),
family = gaussian(link="identity"),
data=data,
seed=1,
cores = getOption("mc.cores", 10),
chains=4,
iter=5000,
warmup=2000,
thin=1)
Now, I want to break up the num to 0-20, 20-35, 35-70 using piecewise regeression with a interaction efffect (type), I tried several times, bu failed all of them.
How should I fit it?
Thank you guys!