Re: [R] uniroot

2021-08-27 Thread Rui Barradas
Hello, Yes, it's FAQ 7.31 but it's not uniroot's fault. The proper way of checking the result would be to call the function fun, not to take the digits output by the print method and compute the function's expression with them. rui@rui:~$ R -q -f rhelp.R fun <- function(x) {x^x -23} #

Re: [R] uniroot

2021-08-27 Thread Jeff Newmiller
Yes. This kind of issue is covered in any decent undergraduate course in numerical methods... it is not specific to R. It is also related to FAQ 7.31. https://en.m.wikipedia.org/wiki/Root-finding_algorithms

[R] uniroot

2021-08-27 Thread Thomas Subia via R-help
Colleagues, I've been using uniroot to identify a root of an equation. As a check, I always verify that calculated root. This is where I need some help. Consider the following script fun <- function(x) {x^x -23} # Clearly the root lies somewhere between 2.75 and 3.00 uniroot(fun, lower =

Re: [R] uniroot problem

2018-12-19 Thread Troels Ring
Thanks a lot - f was renamed FF and things are OK BW Troels -Oprindelig meddelelse- Fra: Berwin A Turlach Sendt: 19. december 2018 10:27 Til: Troels Ring Emne: Re: [R] uniroot problem G'day Troels, On Wed, 19 Dec 2018 10:03:09 +0100 "Troels Ring" wrote: > Dear friend

[R] uniroot problem

2018-12-19 Thread Troels Ring
Dear friends and helpers - in the script below, uniroot is called with a function CHB that calls a function, Charge. On its own, CHB apparently does what is expected, but from within uniroot, problems appear. An error is thrown Error in f(lower, ...) : could not find function "f" So CHB is not

Re: [R] Uniroot error message with in intergration

2012-06-23 Thread jeka12386
Many thanks Ellison I have modified it as you suggested but I have this error message Error in f(lower, ...) : unused argument(s) (N = 54) I am not sure which arguments I have missed? *y - function(t,n){ diff - 0.5 df1 - 2*n-2 ncp1 - sqrt((diff^2*n)/2) p - 1- pt(t,df=df1) test -

[R] Uniroot error message with in intergration

2012-06-22 Thread jeka12386
Dear all I am trying to calculate the value of n using uniroot. Here is the message I am having: Error in uniroot(integ, lower = 0, upper = 1000, n) : 'interval' must be a vector of length 2 Please would you be able to give me an indication on why I am having this error message. Many

Re: [R] Uniroot error message with in intergration

2012-06-22 Thread R. Michael Weylandt
On Fri, Jun 22, 2012 at 4:00 PM, jeka12386 jeka12...@hotmail.co.uk wrote: Dear all I am trying to calculate the value of n using uniroot.  Here is the message I am having: Error in uniroot(integ, lower = 0, upper = 1000, n) :  'interval' must be a vector of length 2 Please  would you

Re: [R] Uniroot error message with in intergration

2012-06-22 Thread jeka12386
I have defined t at the beginning of my query. I have added n on uniroot below and still getting the same error message uniroot(integ,lower=0,upper=1000,n) -- View this message in context: http://r.789695.n4.nabble.com/Uniroot-error-message-with-in-intergration-tp4634247p4634264.html Sent

Re: [R] Uniroot error message with in intergration

2012-06-22 Thread S Ellison
Error in uniroot(integ, lower = 0, upper = 1000, n) : 'interval' must be a vector of length 2 Please would you be able to give me an indication on why I am having this error message. Because uniroot has a second parameter called 'interval' which overrides lower and upper and you have

[R] Uniroot error

2012-04-07 Thread jeka12386
Dear All I am trying to find a uniroot of a function within another function (see example) but I am getting an error message (f()values at end points not of opposite sign). I was wondering if you would be able to advise how redefine my function so that I can find the solution. In short my first

Re: [R] Uniroot error

2012-04-07 Thread Berend Hasselman
On 07-04-2012, at 19:48, jeka12386 wrote: Dear All I am trying to find a uniroot of a function within another function (see example) but I am getting an error message (f()values at end points not of opposite sign). I was wondering if you would be able to advise how redefine my function so

[R] uniroot function question

2011-12-14 Thread kchkchkch
I have one equation, two unknowns, so I am trying to build the solution set by running through possible values for one unknown, and then using uniroot to solve for the accompanying second solution, then graphing the two vectors. p0 = .36 f = function(x) 0.29 * exp(5.66*(x - p0)) f.integral =

Re: [R] uniroot function question

2011-12-14 Thread Berend Hasselman
kchkchkch wrote I have one equation, two unknowns, so I am trying to build the solution set by running through possible values for one unknown, and then using uniroot to solve for the accompanying second solution, then graphing the two vectors. p0 = .36 f = function(x) 0.29 *

Re: [R] uniroot function question

2011-12-14 Thread kchkchkch
Heh. Yes, Berend Hasselman wrote Shouldn't the line with uniroot be (why try as function?) sol = uniroot(fcn, lower = p1, upper = 1) Before the line with for(i in 1:n) insert the following fcn = function(p2) p1*f(p1) + (.20/5.66)*(exp(5.66*(p2 - p0)) - exp(5.66*(p1 - p0))) + (1 -

Re: [R] uniroot function question

2011-12-14 Thread Berend Hasselman
kchkchkch wrote Heh. Yes, Berend Hasselman wrote Shouldn't the line with uniroot be (why try as function?) sol = uniroot(fcn, lower = p1, upper = 1) Before the line with for(i in 1:n) insert the following fcn = function(p2) p1*f(p1) + (.20/5.66)*(exp(5.66*(p2 - p0)) -

[R] Uniroot - error

2011-05-06 Thread CarJabo
Hi, I have tried to use uniroot to solve a value (value a in my function) that gives f=0, and I repeat this process for 1 times(stimulations). However error occures from the 4625th stimulation - Error in uniroot(f, c(0, 2), maxiter = 1000, tol = 0.001) : f() values at end points not of

Re: [R] Uniroot - error

2011-05-06 Thread Duncan Murdoch
You should ask your instructor or teaching assistant for help. R-help is not for doing homework. Duncan Murdoch On 06/05/2011 9:00 AM, CarJabo wrote: Hi, I have tried to use uniroot to solve a value (value a in my function) that gives f=0, and I repeat this process for 1

Re: [R] Uniroot - error

2011-05-06 Thread CarJabo
sorry I am not asking someone to do my homework, as I have finished all the procedure. I am just wondering why this technical error occurs, so I can fix it myself. By the way i don't have any instructor or teaching assistant for help, so any suggestion for the error will be appreciated. Thanks

Re: [R] Uniroot - error

2011-05-06 Thread Joshua Wiley
On Fri, May 6, 2011 at 6:33 AM, CarJabo carly_...@hellokitty.com wrote: sorry I am not asking someone to do my homework, as I have finished all the procedure. I am just wondering why this technical error occurs, so I can fix it myself. My guess would be it has something to do with the random

[R] uniroot speed and vectorization?

2011-04-02 Thread ivo welch
curiosity---given that vector operations are so much faster than scalar operations, would it make sense to make uniroot vectorized? if I read the uniroot docs correctly, uniroot() calls an external C routine which seems to be a scalar function. that must be slow. I am thinking a vectorized

Re: [R] uniroot speed and vectorization?

2011-04-02 Thread Petr Savicky
On Sat, Apr 02, 2011 at 08:24:07AM -0400, ivo welch wrote: curiosity---given that vector operations are so much faster than scalar operations, would it make sense to make uniroot vectorized? if I read the uniroot docs correctly, uniroot() calls an external C routine which seems to be a scalar

Re: [R] uniroot

2011-02-07 Thread dpender
Thanks for your advice. There was an error in the equation that is was copying. Doug -- View this message in context: http://r.789695.n4.nabble.com/uniroot-tp3260090p3264288.html Sent from the R help mailing list archive at Nabble.com. __

[R] uniroot

2011-02-04 Thread dpender
Hi, I am using the uniroot function in order to carry out a bivariate Monte Carlo simulation using the logistics model. I have defined the function as: BV.FV - function(x,y,a,A) (((x^(-a^-1)+y^(-a^-1))^(a-1))*(y^(a-1/a))*(exp(-((1^(-a^-1)+y^(-a^-1))^a)+y^-1)))-A and the procedure is as

Re: [R] uniroot

2011-02-04 Thread Berend Hasselman
dpender wrote: Hi, I am using the uniroot function in order to carry out a bivariate Monte Carlo simulation using the logistics model. I have defined the function as: BV.FV - function(x,y,a,A) (((x^(-a^-1)+y^(-a^-1))^(a-1))*(y^(a-1/a))*(exp(-((1^(-a^-1)+y^(-a^-1))^a)+y^-1)))-A

Re: [R] uniroot

2011-02-04 Thread Petr Savicky
On Fri, Feb 04, 2011 at 04:35:00AM -0800, dpender wrote: Hi, I am using the uniroot function in order to carry out a bivariate Monte Carlo simulation using the logistics model. I have defined the function as: BV.FV - function(x,y,a,A)

[R] uniroot vs.optimize

2009-11-19 Thread rkevinburton
I looked at the descriptions for uniroot and optimize and they are somewhat different but the book reference is the same and I am wondering if there are reasons to pick one over the other? Thank you. Kevin __ R-help@r-project.org mailing list

Re: [R] uniroot vs.optimize

2009-11-19 Thread Don MacQueen
Well, there is a difference between finding a root, and finding a minimum or a maximum. So you would use one or the other depending on which you need to do. -Don At 7:00 PM -0800 11/19/09, rkevinbur...@charter.net wrote: I looked at the descriptions for uniroot and optimize and they are

[R] Uniroot and Newton-Raphson Anomaly

2009-03-16 Thread Doran, Harold
I have the following function for which I need to find the root of a: f - function(R,a,c,q) sum((1 - (1-R)^a)^(1/a)) - c * q To give context for the problem, this is a psychometric issue where R is a vector denoting the percentage of students scoring correct on test item i in class j, c is the

Re: [R] Uniroot and Newton-Raphson Anomaly

2009-03-16 Thread Ravi Varadhan
-help-boun...@r-project.org] On Behalf Of Doran, Harold Sent: Monday, March 16, 2009 10:34 AM To: r-help@r-project.org Subject: [R] Uniroot and Newton-Raphson Anomaly I have the following function for which I need to find the root of a: f - function(R,a,c,q) sum((1 - (1-R)^a)^(1/a)) - c * q To give

Re: [R] uniroot() problem

2009-02-09 Thread megh
Thanks for this reply. Here I was trying to calculate implied volatility using BS formula. This is my code : oo = 384.40 # traded option price uu = 1563.25 # underlying price tt = 0.656 # time to maturity in year ii = 2.309/100 # interest rate, annualized th.price = function(x)

Re: [R] uniroot() problem

2009-02-09 Thread megh
Sorry, in my previous post I forgot to include strike price, which is K = 1160 megh wrote: Thanks for this reply. Here I was trying to calculate implied volatility using BS formula. This is my code : oo = 384.40 # traded option price uu = 1563.25 # underlying price tt = 0.656

Re: [R] uniroot() problem

2009-02-09 Thread Ravi Varadhan
Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of megh Sent: Monday, February 09, 2009 4:27 AM To: r-help@r-project.org Subject: Re: [R] uniroot() problem Thanks for this reply. Here I was trying to calculate implied volatility using BS formula

[R] uniroot() problem

2008-12-30 Thread megh
I have a strange problem with uniroot() function. Here is the result : uniroot(th, c(-20, 20)) $root [1] 4.216521e-05 $f.root [1] 16.66423 $iter [1] 27 $estim.prec [1] 6.103516e-05 Pls forgive for not reproducing whole code, here my question is how f.root can be 16.66423? As it is finding

Re: [R] uniroot() problem

2008-12-30 Thread Albyn Jones
One can't tell for sure without seeing the function, but I'd guess that you have a numerical issue. Here is an example to reflect upon: f=function(x) (exp(x)-exp(50))*(exp(x)+exp(50)) uniroot(f,c(0,100)) $root [1] 49.7 $f.root [1] -1.640646e+39 $iter [1] 4 $estim.prec [1]