![]() This is what I ended up with: tspan11 = (0.0,81.0) The fit to the data is not great, but I still need to figure out my priors better and try a few of the different samplers. I also changed pred_sum as you suggested, which makes more sense, and now it works! I was getting a lot of numerical issue warnings but these were resolved by using BinomialLogit instead of Binomial. So I just assumed there needed to be some variance parameter in the likelihood without really thinking about it. I think I was confused by the Lotka-Volterra example above where there were priors for the ode model parameters, but then also one for the variance of the normal distribution in the likelihood. I think you may be right about not needing sigma. I’m still confused about how the prior σ enters into it (what I confusingly meant by prior variance of the binomial). So what I"ve done in the for loop is calculated the total number of larvae counted on a given day pred_sum (used as the number of trials), and the proportion of total larvae that are preinfective (U), pred_prob (used as the predicted success rate). R help cplot multinom trial#My understanding is that the probability of counting a preinfective larva (U) in one trial is initially distributed as Beta(1,1), and then this distribution is updated by calculating the likelihood for each observation (?) Pred_prob = predicted / sum(predicted) #Proportion of larvae that are Uĭata ~ Binomial(pred_sum,pred_prob) #likelihood of observing data assuming it was drawn from a binomial with # of trials (n) = pred_sum and success rate (p) = pred_prob Pred_sum = Int(round(sum(predicted))) #Total number of larvae predicted by model with given parameters Of course predicted needs to be used, I don’t know what I was thinking! Here is a more thoughtful attempt: function fit11_5(data) This is my first foray into Bayesian statistics, so any help would be greatly appreciated. I thought I might have more luck with Bayes since I have some prior information I could incorporate. ![]() I was having some issues with convergence while using MLE, probably because of the small sample sizes. This is a small part of a much more complicated fitting process. # data ~ MvNormal(predicted, σ) #This "works" with InverseGammaĭata ~ Multinomial(2, σ) #How do you incorporate σ into likelihood function? Does it act as the probability vector? Predicted = solve(prob11,Tsit5(),saveat=datax11) Prob11 = ODEProblem(DevDelay_simpODE,u0,tspan11,p11) ![]() Σ ~ Dirichlet(ones(2)/2) #But should be this if likelihood is Multinomial? #Data (number of U and I in a host on a given day post-infection)ĭatax11 =. J = p*γ - p*u*u #inject some larvae at very start of experimentĭu = dU = J - p*u*u - γ*u*S #preinfectiveĭu = dI = γ*u*S - p*u #infectiveĭu = dD = p*u*u p*u #dead #Model of the experimental infection protocol Using Turing, Distributions, DifferentialEquations I’m working off the Lotka-Volterra example at The data are not great, but I’m hoping to get some information on development rates and mortality rates for the larvae. └ AdvancedHMC C:\Users\alexa\.julia\packages\AdvancedHMC\P9wqk\src\hamiltonian.jl:47 My attempts at using Multinomial or Binomial likelihoods result in endless warnings: ┌ Warning: The current proposal will be rejected due to numerical error(s). I think the likelihood should be multinomial because at any given day there could be preinfective, infective, and/or dead larvae (although I don’t have data for the latter, so maybe Binomial? I get the same warnings in that case). The data are the number of preinfective larvae and infective larvae counted in multiple hosts at different days post-infection. ![]() How would one implement this? The answer is definitely “learn more about Bayesian statistics”, but getting this working will go a long way toward helping me understand what’s going on without having to second guess my code. My understanding is that I would then use a Dirichlet prior and a multinomial likelihood (?). It works fine if I use an InverseGamma distribution (i.e., resulting parameters seem reasonable), but since the data were drawn from a multinomial distribution, an InverseGamma prior and a MvNormal likelihood seem inappropriate. I’m trying to fit a parasite dynamic model to some experimental data using Turing.jl, but I’m having some trouble specifying the prior variance, σ. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |