Hello,

I have a simple piecewise equation, but when I try to add BSV, it says that the gradient is exactly zero in Ω²_R0 indicating that Ω²_R0 is not identified. I clearly have the BSV identified, but I am thinking that something about the piecewise equations restricts the model fitting. Is there a better way to do this sort of thing?

To explain the data better, I have 16 IDs that are labeled CATEGORY=“NOOCC” and 16 IDs that are labeled CATEGORY=“OCC”. The NOOCC data should be fit with the regular equation: R*(1-exp(-k*(t))) while the OCC data has some effect on that equation.

Here is my model:

```
model_vitro = @model begin
@param begin
tv_R0 ∈ RealDomain(lower = 0.0000000001) # ug/cm2-hr
tv_kout ∈ RealDomain(lower = 0.0000000001) # 1/hr
tv_EFF_OCC ∈ RealDomain(lower = 0.0000000001)
tv_EFF_RMOCC ∈ RealDomain(lower = 0.0000000001)
Ω²_R0 ∈ RealDomain(lower=0.0001)
Ω²_kout ∈ RealDomain(lower=0.0001)
Ω²_EFF_OCC ∈ RealDomain(lower = 0.0000000001)
Ω²_EFF_RMOCC ∈ RealDomain(lower = 0.0000000001)
σ²_add ∈ RealDomain(lower = 0.0000000001)
end
@random begin
η_R0 ~ Normal(0,sqrt(Ω²_R0))
η_kout ~ Normal(0,sqrt(Ω²_kout))
η_EFF_OCC ~ Normal(0,sqrt(Ω²_EFF_OCC))
η_EFF_RMOCC ~ Normal(0,sqrt(Ω²_EFF_RMOCC))
end
@covariates CATEGORY
@pre begin
R = tv_R0 * exp(η_R0)
k = tv_kout * exp(η_kout)
EFF_OCC = tv_EFF_OCC * exp(η_EFF_OCC)
EFF_RMOCC = tv_EFF_RMOCC * exp(η_EFF_RMOCC)
slope = CATEGORY == "OCC" && t >= 7 && t<10 ? R*(1-exp(-k*(7))) + EFF_OCC*(t-7) :
CATEGORY == "OCC" && t >= 10 ? R*(1-exp(-k*(7))) + EFF_OCC*(10-7) + EFF_RMOCC*(t-10) :
R*(1-exp(-k*(t)))
end
@derived begin
flux_vitro = @. slope # amount in the reciever per unit area
FLUX ~ @. Normal(flux_vitro, sqrt(σ²_add))
end
end
param_vitro = (
tv_R0 = 0.15,
tv_kout = 0.1,
tv_EFF_OCC = 0.1,
tv_EFF_RMOCC = 0.7,
Ω²_R0 = 0.1,
Ω²_kout = 0.1,
Ω²_EFF_OCC = 0.1,
Ω²_EFF_RMOCC = 0.1,
σ²_add = 0.01
)
```