Call a function with multiple arguments inside uniroot in R -


I am trying to call functions with many arguments within uniroot, to solve the value of x and find for. The code below

  mean1 = 0 means2 = 1 sigma1 = 0.5 sigma2 = 0.5 priors1 = 0.6 priors2 = 0.1 threshold = function (mu1, sigma1, mu2, sigma2, prior1, prior2, x) {(Dnorm (x, mu1, sigma1) * prior1 - dnorm (x, mu2, sigma2) * pre 2)} uniroot (threshold (meaning 1, sigma1, mean2, sigma2, prior 1, priusus2), c (0,5))  

But uniroot failed to call, function is expected to pass X as well, how do I solve it?

Wrap your function in a function, which takes an argument:

  uniroot (function (x) threshold (mean 1, sigma1, mean2, sigma2, prerears 1, prerequires 2, x), c (0,5))  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -