similar to: How do I modify uniroot function to return .0001 if error ?

Displaying 20 results from an estimated 8000 matches similar to: "How do I modify uniroot function to return .0001 if error ?"

2013 May 30
2
RFC: a "safe" uniroot() function for future R
With main R releases only happening yearly in spring, now is good time to consider *and* discuss new features for what we often call "R-devel" and more officially is R Under development (unstable) (.....) -- "Unsuffered Consequences" Here is one such example I hereby expose to public scrutiny: A few minutes ago, I've committed the following to R-devel (the
2023 Feb 20
1
uniroot violates bounds?
Le 18/02/2023 ? 21:44, J C Nash a ?crit?: > I wrote first cut at unirootR for Martin M and he revised and put in > Rmpfr. > > The following extends Ben's example, but adds the unirootR with trace > output. > > c1 <- 4469.822 > c2 <- 572.3413 > f <- function(x) { c1/x - c2/(1-x) }; uniroot(f, c(1e-6, 1)) > uniroot(f, c(1e-6, 1)) > library(Rmpfr) >
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 interval of (lower=min(U), upper=max(U)) and it won't work as well.
2008 Apr 12
1
R and Excel disagreement - Goal Seek versus uniroot
Dear friends - occurring in Windows R2.6.2 I am modeling physical chemistry in collaboration with a friend who has preferred working in Excel. I used uniroot, and find a solution to a two buffer problem in acid-base chemistry which I believe is physiologically sensible. Using "goal seek" in Excel my friend found another plausible root, quite close to zero, and a plot of the function
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
2018 Aug 13
1
trace in uniroot() ?
Despite my years with R, I didn't know about trace(). Thanks. However, my decades in the minimization and root finding game make me like having a trace that gives some info on the operation, the argument and the current function value. I've usually found glitches are a result of things like >= rather than > in tests etc., and knowing what was done is the quickest way to get there.
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't give a
2023 Feb 18
1
uniroot violates bounds?
I wrote first cut at unirootR for Martin M and he revised and put in Rmpfr. The following extends Ben's example, but adds the unirootR with trace output. c1 <- 4469.822 c2 <- 572.3413 f <- function(x) { c1/x - c2/(1-x) }; uniroot(f, c(1e-6, 1)) uniroot(f, c(1e-6, 1)) library(Rmpfr) unirootR(f, c(1e-6, 1), extendInt="no", trace=1) This gives more detail on the iterations,
2018 Aug 13
0
trace in uniroot() ?
I tend to avoid the the trace/verbose arguments for the various root finders and 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))
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
2017 Dec 25
3
plot representation of calculated value known to be 7.4
Dear friends - merry Christmas and thanks a lot for much help during the year! In the example below I fail to understand how the calculated value pH is represented in a simple plot - also included. The calculations are useful in practice and likely to be right in principle but I cannot see how this occurs: why a calculated value of 7.4 known as numeric is not simply plotted as such. It
2006 Apr 05
0
uniroot warning (lack of) (PR#8750)
Full_Name: Chris Andrews Version: 2.2.1 OS: Windows Submission from: (NULL) (128.205.94.95) The function page for uniroot indicates If the algorithm does not converge in 'maxiter' steps, a warning is printed and the current approximation is returned. I have not been able to get a warning message even when I think I should get one (see code below). Perhaps the bug is in the
2017 Dec 25
0
plot representation of calculated value known to be 7.4
Dear friends - copy paste missed SID <- c() before the first loop - sorry BW Troels Den 25-12-2017 kl. 19:12 skrev Troels Ring: > > Dear friends - merry Christmas and thanks a lot for much help during > the year! > > In the example below I fail to understand how the calculated value pH > is represented in a simple plot - also included. The calculations are > useful
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 must be near Zero. Am I missing something? -- View this message
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 <- uniroot(Fp2, lower =0, upper =1,
2017 Dec 26
2
plot representation of calculated value known to be 7.4
Thanks a lot - formatting the ordinate as ylim=c(4,10) before plotting pH also removed the problem, and options(digits=10) confirmed that pH was not all exactly 7.4 - as I knew. Still I wonder just why R chooses to plot(ATOT,pH) as shown with repeated "7.4" instead of some more detailed representation. Thanks a gain and happy New Year! Troels Den 26-12-2017 kl. 01:03 skrev Bert
2011 Sep 11
3
(no subject)
Dear all, Can anyone take a look at my program below? There are two functions: f1 (lambda,z,p1) and f2(p1,cl, cu). I fixed p1=0.15 for both functions. For any fixed value of lambda (between 0.01 and 0.99), I solve f1(p1=0.15, lambda=lambda, z)=0 for the corresponding cl and cu values. Then I plug the calculated cl and cu back into the function f2. Eventually, I want to find the lambda value
2023 Nov 06
2
non-linear regression and root finding
Dear friends - I have a function for the charge in a fluid (water) buffered with HEPES and otherwise only containing Na and Cl so that [Na] - [Cl] = SID (strong ion difference) goes from -1 mM to 1 mM. With known SID and total HEPES concentration I can calculate accurately the pH if I know 3 pK values for HEPES by finding the single root with uniroot Now, the problem is that there is some
2009 Sep 23
1
Maximum Likelihood Est. regarding the degree of freedom of a multivariate skew-t copula
Hello, I have a bigger problem in calculating the Maximum Likelihood Estimator regarding the degree of freedom of a multivariate skew-t copula. First of all I would like to describe what this is all about, so that you can understand my problem: I have 2 time series with more than 3000 entries each. I would like to calculate a multivariate skew-t Copula that fits this time series. Notice:
2023 Nov 06
1
non-linear regression and root finding
? Mon, 6 Nov 2023 17:53:49 +0100 Troels Ring <tring at gvdnet.dk> ?????: > Hence I wonder if I could somehow have non linear regression to find > the 3 pK values. Below is HEPESFUNC which delivers charge in the > fluid for known pKs, HEPTOT and SID. Is it possible to have > root-finding in the formula with nls? Sure. Just reformulate the problem in terms of a function that