# Turing.jl: fix some parameters to prior distribution

**URL:** <https://discourse.julialang.org/t/turing-jl-fix-some-parameters-to-prior-distribution/41095>\
**Category:** Probabilistic Programming\
**Created:** [June 9, 2020, 9:11pm UTC](https://discourse.julialang.org/t/turing-jl-fix-some-parameters-to-prior-distribution/41095 "2020-06-09T21:11:44Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![MFairley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mfairley/32/8599_2.png) [@MFairley](https://discourse.julialang.org/u/MFairley)\
**Post date:** [June 9, 2020, 10:07pm UTC](https://discourse.julialang.org/t/turing-jl-fix-some-parameters-to-prior-distribution/41095/7 "2020-06-09T22:07:52Z")

</div>

> [@trappmartin](#):
>
> Every ~ indicates that we perform inference for that parameter and that we account for it in the joint probability. But you can simply draw beta using the rand function ~~and add its log probability to the joint.~~
> 
> Does that help?  
> May I also ask why you don’t want to update the prior?

Great, so something like this:

```julia
@model bayes_sir(y) = begin
    # Calculate number of timepoints
    l = length(y)
    i₀ ~ Uniform(0.0,1.0)
    β = rand(Uniform(0.0,1.0))
    I = i₀*1000.0
    u0=[1000.0-I,I,0.0,0.0]
    p=[β,10.0,0.25]
    tspan = (0.0,float(l))
    prob = ODEProblem(sir_ode!,
            u0,
            tspan,
            p)
    sol = solve(prob,
                Tsit5(),
                saveat = 1.0)
    sol_C = Array(sol)[4,:] # Cumulative cases
    sol_X = sol_C[2:end] - sol_C[1:(end-1)]
    l = length(y)
    for i in 1:l
      y[i] ~ Poisson(sol_X[i])
    end
end;

```

and then use the trick from [Is there a turing alternative to pm.Deterministic from pymc3? - #3 by torfjelde](https://discourse.julialang.org/t/is-there-a-turing-alternative-to-pm-deterministic-from-pymc3/38667/3) to keep track of the samples from beta?

There are a couple of applications I had in mind:

1. For computational efficiency, when I know that a parameter has no influence on the likelihood.

2. When the prior was estimated using some external source that I think is more reliable than my own data. For example, say I observe deaths in patients from treatments A and B. A clinical trial reports a hazard rate ratio (hr) for the effectiveness of A vs. B. I assume the likelihood is: deaths\_a ~ Poisson(lambda \* hr) and deaths\_b ~ Poisson(lambda). I want to run inference on lambda but I want to leave hr unchanged from its prior.

---

_[View the full topic](https://discourse.julialang.org/t/turing-jl-fix-some-parameters-to-prior-distribution/41095)._
