Mamba - lognormal survival with right censoring

question

#1

Please can someone suggest where I might be going wrong with the following model that simply looks to find the mean survival from a lognormal distribution that has censoring? I have the version without censoring running included in the comments, which runs fine. I am pretty sure that the problem lies with the definition of t, but have failed to see what it is so far…

## Data
notmice = Dict{Symbol, Any}(
  :torig => [183.5, 4.0, 90.7, 1041.5, 10.4, 75.9, 1416.1, 133.6, 26.8, 134.6, 392.4, 28.9, 54.3, 31.9, 46.2, 15.7, 22.9, 1372.2, 124.2, 499.3, 23.5, 33.6, 39.1, 607.3, 9.1, 34.5, 196.5, 805.1, 70.6, 57.1, 452.8, 15238.4, 53.5, 42.5, 2.2, 740.8, 3884.4, 18.3, 402.8, 391.3, 467.4, 6.7, 535.2, 2890.4, 316.0, 597.9, 87.3, 164.8, 50.0, 14.5],
  :t =>
    [183.5, 4.0, 90.7, NaN, 10.4, 75.9, NaN, 133.6, 26.8, 134.6, 392.4, 28.9, 54.3, 31.9, 46.2, 15.7, 22.9, NaN, 124.2, NaN, 23.5, 33.6, 39.1, NaN, 9.1, 34.5, 196.5, NaN, 70.6, 57.1, NaN, NaN, 53.5, 42.5, 2.2, NaN, NaN, 18.3, NaN, 391.3, NaN, 6.7, NaN, NaN, 316.0, NaN, 87.3, 164.8, 50.0, 14.5],
  :tcensor =>
    [0., 0, 0, 400, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 0, 400, 0, 0, 0, 400, 0, 0, 0, 400, 0, 0, 400, 400, 0, 0, 0, 400, 400, 0, 400, 0, 400, 0, 400, 400, 0, 400, 0, 0, 0, 0]
)
notmice[:N] = size(notmice[:t], 2)


## Model Specification
model = Model(

  t = Stochastic(1,
    (tcensor, b1, sig, N) ->
      UnivariateDistribution[
        Truncated(LogNormal(b1, sig), tcensor[i], Inf) for i in 1:N
      ],
    false
  ),

  # torig = Stochastic(1,
  #   (b1, sig) -> LogNormal(b1, sig),
  #   false
  # ),

  b1 = Stochastic(
    () -> Normal(0, 10)
  ),

  sig = Stochastic(
    () -> Truncated(Cauchy(0, 7), 0, Inf)
  )

)


## Initial Values
inits = [
  Dict{Symbol, Any}(
    :torig => notmice[:torig],
    :t => notmice[:t],
    :b1 => rand(Distributions.Normal(0, 1)),
    :sig => rand(Distributions.Gamma(1, 1)))
for i in 1:1] # placeholder for multichain


## Sampling Scheme
scheme = [Mamba.NUTS(:b1),
          Slice(:sig, 3.0)]
setsamplers!(model, scheme)


## MCMC Simulations
sim = mcmc(model, notmice, inits, 1000, burnin=250, thin=2, chains=1)
describe(sim)

The error that I get back from Julia for the above is:

ERROR: LoadError: MethodError: no method matching ScalarStochastic(::Int64)
Closest candidates are:
  ScalarStochastic(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\Users\mjones\.julia\packages\Mamba\qNBKz\src\Mamba.jl:100
  ScalarStochastic(::T<:Number) where T<:Number at boot.jl:725
  ScalarStochastic(::Float64, ::Symbol, ::Array{Int64,1}, ::Function, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Distribution{Univariate,S} where S<:ValueSupport) at C:\Users\mjones\.julia\packages\Mamba\qNBKz\src\Mamba.jl:100
  ...
Stacktrace:
 [1] convert(::Type{ScalarStochastic}, ::Int64) at .\number.jl:7
 [2] zero(::Type{ScalarStochastic}) at .\number.jl:263
 [3] cdf at C:\Users\mjones\.julia\packages\Distributions\WHjOk\src\univariate\continuous\lognormal.jl:102 [inlined]
 [4] Truncated(::LogNormal{ScalarStochastic}, ::Float64, ::Float64) at C:\Users\mjones\.julia\packages\Distributions\WHjOk\src\truncate.jl:26
 [5] (::getfield(Main, Symbol("##221#224")))(::Array{Float64,1}, ::ScalarStochastic, ::ScalarStochastic, ::Int64) at C:\Users\mjones\telethon\code\simstudy_02\survlognorm.jl:35
 [6] (::getfield(Main, Symbol("##227#228")))(::Model) at .\array.jl:0
 [7] setinits!(::ArrayStochastic{1}, ::Model, ::Array{Float64,1}) at C:\Users\mjones\.julia\packages\Mamba\qNBKz\src\model\dependent.jl:169
 [8] setinits!(::Model, ::Dict{Symbol,Any}) at C:\Users\mjones\.julia\packages\Mamba\qNBKz\src\model\initialization.jl:11
 [9] setinits!(::Model, ::Array{Dict{Symbol,Any},1}) at C:\Users\mjones\.julia\packages\Mamba\qNBKz\src\model\initialization.jl:24
 [10] #mcmc#23(::Int64, ::Int64, ::Int64, ::Bool, ::Function, ::Model, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}, ::Int64) at C:\Users\mjones\.julia\packages\Mamba\qNBKz\src\model\mcmc.jl:30
 [11] (::getfield(Mamba, Symbol("#kw##mcmc")))(::NamedTuple{(:burnin, :thin, :chains),Tuple{Int64,Int64,Int64}}, ::typeof(mcmc), ::Model, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}, ::Int64) at .\none:0
 [12] top-level scope at none:0
in expression starting at C:\Users\mjones\telethon\code\simstudy_02\survlognorm.jl:75

#2

Still haven’t figured out what I am doing wrong. If anyone has any insight it would be most appreciated.