# In Julia Turing: getting AssertionError: model isa Model

**URL:** https://discourse.julialang.org/t/in-julia-turing-getting-assertionerror-model-isa-model/76927
**Category:** Probabilistic Programming
**Tags:** turing
**Created:** [February 22, 2022, 6:14pm UTC](https://discourse.julialang.org/t/in-julia-turing-getting-assertionerror-model-isa-model/76927 "2022-02-22T18:14:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rkmalaiya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rkmalaiya/32/31236_2.png) [@rkmalaiya](https://discourse.julialang.org/u/rkmalaiya)
#### Post date: [February 22, 2022, 6:14pm UTC](https://discourse.julialang.org/t/in-julia-turing-getting-assertionerror-model-isa-model/76927/1 "2022-02-22T18:14:34Z")

</div>

Hi All,  
I am executing below code mentioned in the [Turing.jl Guide](https://turing.ml/dev/docs/using-turing/guide#querying-probabilities-from-model-or-chain). This code can be used to calculate likelihood for the Turing model. However I am getting below mentioned error. Please let me know what I may be doing wrong. Thanks for all the help!

**Code for model:**

> using Turing  
> @model function gdemo(x, y)  
> s² ~ InverseGamma(2, 3)  
> m ~ Normal(0, sqrt(s²))  
> x ~ Normal(m, sqrt(s²))  
> y ~ Normal(m, sqrt(s²))  
> end

**Code to get likelihood**

> prob"x = 1.0, y = 1.0 | model = gdemo, s = 1.0, m = 1.0"

**Error that I am getting:**

> AssertionError: model isa Model
> 
> Stacktrace:  
> [1] probtype(ntl::NamedTuple{(:x, :y), Tuple{Float64, Float64}}, ntr::NamedTuple{(:model, :s, :m), Tuple{typeof(gdemo), Float64, Float64}})  
> @ DynamicPPL C:\Users.….julia\packages\DynamicPPL\hglyy\src\prob\_macro.jl:66  
> [2] logprob(ex1::NamedTuple{(:x, :y), Tuple{Float64, Float64}}, ex2::NamedTuple{(:model, :s, :m), Tuple{typeof(gdemo), Float64, Float64}})  
> @ DynamicPPL C:\Users.….julia\packages\DynamicPPL\hglyy\src\prob\_macro.jl:25  
> [3] top-level scope  
> @ In[117]:7  
> [4] eval  
> @ .\boot.jl:373 [inlined]  
> [5] include\_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)  
> @ Base .\loading.jl:1196

---

<div class="post-metadata">

### Author: ![zhangxiubo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangxiubo/32/4357_2.png) [@zhangxiubo](https://discourse.julialang.org/u/zhangxiubo)
#### Post date: [February 22, 2022, 7:36pm UTC](https://discourse.julialang.org/t/in-julia-turing-getting-assertionerror-model-isa-model/76927/2 "2022-02-22T19:36:03Z")

</div>

See [https://github.com/TuringLang/DynamicPPL.jl/issues/182](https://github.com/TuringLang/DynamicPPL.jl/issues/182)

~~Though I am not sure how one should provide the observations — as part of the model or in the string macro?~~ So the following works for me:

```julia
using Turing
@model function gdemo(x, y)
	s² ~ InverseGamma(2, 3)
	m ~ Normal(0, sqrt(s²))
	x ~ Normal(m, sqrt(s²))
	y ~ Normal(m, sqrt(s²))
end

model = gdemo(missing, missing)
prob"x = 3.0, y = 3.0 | model = model, s = 1.0, m = 1.0"

```

---

<div class="post-metadata">

### Author: ![rkmalaiya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rkmalaiya/32/31236_2.png) [@rkmalaiya](https://discourse.julialang.org/u/rkmalaiya)
#### Post date: [February 25, 2022, 5:55pm UTC](https://discourse.julialang.org/t/in-julia-turing-getting-assertionerror-model-isa-model/76927/3 "2022-02-25T17:55:42Z")

</div>

> [@zhangxiubo](#):
>
> `model = gdemo(missing, missing)`

This worked for me too. Thanks for the help!
