# ERROR: \[Turing\] MH doesn't support vectorizing assume statement

**URL:** https://discourse.julialang.org/t/error-turing-mh-doesnt-support-vectorizing-assume-statement/29646
**Category:** Probabilistic Programming
**Created:** [October 8, 2019, 9:42am UTC](https://discourse.julialang.org/t/error-turing-mh-doesnt-support-vectorizing-assume-statement/29646 "2019-10-08T09:42:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jdhooghe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdhooghe/32/9976_2.png) [@jdhooghe](https://discourse.julialang.org/u/jdhooghe)
#### Post date: [October 8, 2019, 9:42am UTC](https://discourse.julialang.org/t/error-turing-mh-doesnt-support-vectorizing-assume-statement/29646/1 "2019-10-08T09:42:39Z")

</div>

Hello again.

I am using Turing to re-create Facebook’s Prophet trend model. My model is:

```julia
@model Trend(Years, y) = begin
    NumberOfChangepoints ~ DiscreteUniform(1, 5) 
    s = collect(range(Years[1], length=1+NumberOfChangepoints, stop=Years[end]))[2:end]
    k ~ Normal(0., 5.) #Initial Rate
    m ~ Normal(0., 5.) #Initial Intercept
    λ ~ InverseGamma(1.5, 1.) #Diversity Prior
    δ = Vector{Float64}(undef, NumberOfChangepoints) #Correction to initial rate for each changepoint
    δ ~ [Laplace(0., λ)]
    A = repeat(Years', NumberOfChangepoints)'
    A = hcat(Array([A[:, i] .> s[i] for i in 1:NumberOfChangepoints] * 1)...)
    γ = -[s[i]*δ[i] for i in 1:NumberOfChangepoints]
    Slopes = A*δ .+ k
    Intercepts = A*γ .+ m
    Trend = Slopes .* Years .+ Intercepts
    sd ~ InverseGamma(1.5, 1.)
    for i in 1:size(y)[1]
        y[i] ~ Normal(Trend[i], sd)
    end
end

```

The issue is that I recieve the error

```julia
ERROR: [Turing] MH doesn't support vectorizing assume statement

```

My best guess is that it doesn’t like my δ vector. My sampler is such

```julia
chn = Turing.sample(Model, MH(), 10000)[3000:100:end]

```

since I’m unsure of how to implement PG along with NUTS. Thank you for your help 🙂

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [October 8, 2019, 12:15pm UTC](https://discourse.julialang.org/t/error-turing-mh-doesnt-support-vectorizing-assume-statement/29646/2 "2019-10-08T12:15:17Z")

</div>

What is `Model`? Your code is not runnable. Please see [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757).

---

<div class="post-metadata">

### Author: ![jdhooghe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdhooghe/32/9976_2.png) [@jdhooghe](https://discourse.julialang.org/u/jdhooghe)
#### Post date: [October 8, 2019, 4:35pm UTC](https://discourse.julialang.org/t/error-turing-mh-doesnt-support-vectorizing-assume-statement/29646/3 "2019-10-08T16:35:43Z")

</div>

Model is

```julia
Model = Trend(Years, y)

```

I am concerned about what that error message means not if the Model is able to run

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [October 8, 2019, 11:08pm UTC](https://discourse.julialang.org/t/error-turing-mh-doesnt-support-vectorizing-assume-statement/29646/4 "2019-10-08T23:08:14Z")

</div>

The error comes from `δ ~ [Laplace(0., λ)]`. This syntax is not supported for MH. Use a loop instead. Note that this syntax will change soon-ish when [https://github.com/TuringLang/Turing.jl/issues/476](https://github.com/TuringLang/Turing.jl/issues/476) is closed.

---

<div class="post-metadata">

### Author: ![cpfiffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpfiffer/32/208747_2.png) [@cpfiffer](https://discourse.julialang.org/u/cpfiffer)
#### Post date: [October 9, 2019, 2:57pm UTC](https://discourse.julialang.org/t/error-turing-mh-doesnt-support-vectorizing-assume-statement/29646/5 "2019-10-09T14:57:18Z")

</div>

You can use `PG` and `NUTS` together with

```julia
sampler = Gibbs(PG(100, :NumberOfChangePoints), NUTS(500, 0.65, :k, :m, :λ, :δ, :sd))
chn = sample(Model, sampler, 10000)

```

10,000 will probably take a long time to run with this model and sampler pair, so you might consider stepping the number of iterations down a little.
