0
votes

I am trying to optimize a function in Julia using following code, but getting LoadError. can anyone tell me what is the problem in my code?

data = readdlm("RGPSLessData.csv", ';')
using Optim
function f(x::Vector,n11,E)
     return sum(-log((x[5] * dnbinom(n11, x[1], x[2]/(x[2]+E)) + (1-x[5]) * dnbinom(n11, x[3], x[4]/(x[4]+E)))))
end
res = optimize(x -> f(x,data[:,1],data[:,2]),[0.2,0.06,1.4,1.8,0.1])
1
@rickhg12hs, thanks for replying. I am new to all this thing. can you tell me what all changes i have to do? thanks in advanceKushal
It's not clear to me what you want to do given that the newton method examples are so very different from your example code.rickhg12hs
@Vincent Zoonekynd thanks for replying, i have updated my code.. which i have updated in my question but still it is showing loadError please help me out..Kushal

1 Answers

0
votes

dnbinom isn't a function in Julia (in the comments it appears to be from R). Probability distributions are provided by the Distributions.jl package. Instead of

dnbinom(n11, x[1], x[2]/(x[2]+E))

You can use

pdf(NegativeBinomial(x[1], x[2]/(x[2]+E)), n11)