Parameter estimation with ODEProblem/Turing error

A partial solution for posterity:

It seems the tutorials online seem to be needing a slight modification (see below). Type inference in Turing seems to require the ODE parameter set to be of type “T”. SMC still not happy but NUTS() is good as well as MH().


@model function basiclogist(y, prob, ::Type{T}=Float64 ) where T
  r ~ Normal( 1.0, 0.5 )
  y0 ~ Beta(1.0, 1.0 )
  sigma ~ truncated( Cauchy(0.0, 0.5), 1e-5, 0.5 )
  p = T[r, y0]
  odesol = solve(prob, Tsit5(); p=p, saveat=0.1 )
  if odesol.retcode !== :Success
    Turing.@addlogprob! -Inf
    return nothing
  end

  for i in 1:length(times)
    j = findall(t -> t==times[i], odesol.t)
    if length(j) > 0
      y[i] ~ Normal( odesol.u[j[1]][1] , sigma )
    end
  end
end

1 Like