search for: uniroot

Displaying 20 results from an estimated 237 matches for "uniroot".

2013 May 30
2
RFC: a "safe" uniroot() function for future R
...n the svn repository for R): ------------------------------------------------------------------------ r62834 | maechler | 2013-05-30 10:01:33 +0200 (Thu, 30 May 2013) | 1 line Changed paths: M doc/NEWS.Rd M src/library/stats/NAMESPACE M src/library/stats/R/nlm.R M src/library/stats/man/uniroot.Rd M tests/Examples/stats-Ex.Rout.save new "safe" uniroot() =: unirootS() [may change; see R-devel e-mail] ------------------------------------------------------------------------ The help file says ?unirootS()? is a ?safe? version of ?uniroot()?, built on ?uniroot()?, al...
2020 Oct 06
4
Solving a simple linear equation using uniroot give error object 'x' not found
Colleagues, I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message, Error in yfu n(x,10,20) : object 'x' not found. I hope someone can tell we how I can fix the problem if(...
2011 Apr 03
1
How do I modify uniroot function to return .0001 if error ?
I am calling the uniroot function from inside another function using these lines (last two lines of the function) : d <- uniroot(k, c(.001, 250), tol=.05) return(d$root) The problem is that on occasion there's a problem with the values I'm passing to uniroot. In those instances uniroot stops and sends a messag...
2020 Oct 06
0
Solving a simple linear equation using uniroot give error object 'x' not found
On 06/10/2020 11:00 a.m., Sorkin, John wrote: > Colleagues, > I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message, > Error in yfu n(x,10,20) : object 'x' not found. > > I hope someone can tell we how I can fix the...
2012 Nov 01
1
What does uniroot return when an error occurs
Hi, I'm using the uniroot function, and would like to detect an error which occurs, for instance, when the values at endpoints are not of opposite signs. For example: uniroot( function(x) x^2+1, lower=1, upper=2 ). I want to say something like: if "error in uniroot(...)" return NA else return uniroot$root Than...
2012 Jun 22
4
Uniroot error message with in intergration
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 thanks EXAMPLE BELOW: ## t = s...
2007 Apr 25
4
How to solve difficult equations?
This below is not solvable with uniroot to find "a": fn=function(a){ b=(0.7/a)-a (1/(a+b+1))-0.0025 } uniroot(fn,c(-500,500)) gives "Error in uniroot(fn, c(-500, 500)) : f() values at end points not of opposite sign" I read R-help posts and someone wrote a function: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/92...
2018 Jul 30
2
trace in uniroot() ?
In looking at rootfinding for the histoRicalg project (see gitlab.com/nashjc/histoRicalg), I thought I would check how uniroot() solves some problems. The following short example ff <- function(x){ exp(0.5*x) - 2 } ff(2) ff(1) uniroot(ff, 0, 10) uniroot(ff, c(0, 10), trace=1) uniroot(ff, c(0, 10), trace=TRUE) shows that the trace parameter, as described in the Rd file, does not seem to be functional except in limited...
2011 Apr 02
1
uniroot speed and vectorization?
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 version would be useful for an example such as of <- function(x,a) ( log(x)+x+a ) uniroot( of, c( 1e-7, 100 ), a=rnor...
2008 Dec 31
1
uniroot() problem
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 root of a function, it mu...
2011 Dec 14
1
uniroot function question
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 = integrate(f, p0, 1) p1 = p0 + .01 i = 1 n = (1 - p0)/.01 p1.vector = rep(0,n) p2.vector = rep(0,n) for (i in 1:n) { p1.vector[i] = p1 fcn = function(p2) p...
2012 Apr 07
1
Uniroot error
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 function calculates the intergrale which i...
2011 Sep 03
3
question with uniroot function
Dear all, I have the following problem with the uniroot function. I want to find roots for the fucntion "Fp2" which is defined as below. Fz <- function(z){0.8*pnorm(z)+p1*pnorm(z-u1)+(0.2-p1)*pnorm(z-u2)} Fp <- function(t){(1-Fz(abs(qnorm(1-(t/2)))))+(Fz(-abs(qnorm(1-(t/2)))))} Fp2 <- function(t) {Fp(t)-0.8*t/alpha} th <-...
2005 Mar 09
3
problem using uniroot with integrate
...an m-alternative forced choice experiment, given the probability of a correct response, Pc, a Gaussian assumption for the noise and no bias. The function that I wrote below gives me an error: Error in f(x, ...) : recursive default argument reference The problem seems to be at the statement using uniroot, because the furntion est.dp works fine outside of the main function. I've been using R for awhile but there are still many nuances about the scoping and the use of environments that I'm weak on and would like to understand better. I would appreciate any suggestions or solutions that anyon...
2018 Aug 13
1
trace in uniroot() ?
...d use the trace > function or otherwise modify the function handed to the operator.? You can print or plot the arguments or save them.? E.g., > >> trace(ff, print=FALSE, quote(cat("x=", deparse(x), "\n", sep=""))) > [1] "ff" >> ff0 <- uniroot(ff, c(0, 10)) > x=0 > x=10 > x=0.0678365490630423 > x=5.03391827453152 > x=0.490045026724842 > x=2.76198165062818 > x=1.09760394309444 > x=1.92979279686131 > x=1.34802524899502 > x=1.38677998493585 > x=1.3862897003949 > x=1.38635073555115 > x=1.3862897003949 &...
2011 May 06
1
Uniroot - error
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 10000 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 opposite sign I have also tried inte...
2018 Aug 13
0
trace in uniroot() ?
...d optimizers and instead use the trace function or otherwise modify the function handed to the operator. You can print or plot the arguments or save them. E.g., > trace(ff, print=FALSE, quote(cat("x=", deparse(x), "\n", sep=""))) [1] "ff" > ff0 <- uniroot(ff, c(0, 10)) x=0 x=10 x=0.0678365490630423 x=5.03391827453152 x=0.490045026724842 x=2.76198165062818 x=1.09760394309444 x=1.92979279686131 x=1.34802524899502 x=1.38677998493585 x=1.3862897003949 x=1.38635073555115 x=1.3862897003949 or > X <- numeric() > trace(ff, print=FALSE, quote(X[[l...
2006 Jul 29
1
uniroot
Hello, I am struggling to find the root of a exponent function. "uniroot" is complaining about a values at end points not of opposite sign? s<- sapply(1:length(w),function(i) + { + + + + + uniroot(saeqn,lower=-5000,upper=0.01036597923,l=list(t=w[i],gp=gp))$root + }) Error in uniroot(saeqn, lower = -5000, upper = 0.01036597923, l = list(t = w[i], :...
2007 Jan 31
2
what is the purpose of an error message in uniroot?
Hi all, This is probably a blindingly obvious question: Why does it matter in the uniroot function whether the f() values at the end points that you supply are of the same sign? For example: f <- function(x,y) {y-x^2+1} #this gives a warning uniroot(f,interval=c(-5,5),y=0) Error in uniroot(f, interval=c(-5, 5), y = 0) : f() values at end points not of opposite sign #this doesn...
2007 Mar 29
1
ansari.test.default: bug in call to uniroot?
A recent message on ansari.test() prompted me to play with the examples. This doesn't work for me in R version 2.4.1 R> ansari.test(rnorm(100), rnorm(100, 0, 2), conf.int = TRUE) Error in uniroot(ab, srange, tol = 1e-04, zq = qnorm(alpha/2, lower = FALSE)) : object "ab" not found It looks like there's a small typo in ccia() inside ansari.test.default() in which 'ab' is passed to uniroot rather than 'ab2'. The definition of ccia below was just copied from http...