Displaying 20 results from an estimated 6000 matches similar to: "making uniroot a bit more robust?"
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
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
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
2003 Apr 23
1
Setting up Xemacs + Sweave
Dear list,
I have tried to setup my Xemacs for use with Sweave, which I indend to learn.
I have followed the instructions in the Sweave FAQ, that is to say, I put
(defun Rnw-mode ()
(require 'ess-noweb)
(noweb-mode)
(if (fboundp 'R-mode)
(setq noweb-default-code-mode 'R-mode)))
(add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(add-to-list
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,
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 is function of "t" , I need to find the
uniroot of
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)
>
2003 Oct 01
3
fitting Markov chains
I need to find a computationally simple process for the movement of
interest rates. In this simplified model, an interest rate can have
3--5 possible values, and its movement is characterized by a matrix of
transition probabilities (ie, it is a Markov process).
I would like to estimate this process from a given set of data.
For example, let the interest rate time series be:
7 3 8 2 5 9 6
2004 Apr 10
4
(offtopic) I need two sets of 5 different color scales
Hi,
I am plotting a policy function (result from a dynamic stochastic
optimization problem, discretized approximation). The policy function
maps from an 2 x 2 x 2 x 3 x B x F state space to a B x F state space
(B and F are usually between 4-6, and represent domestic and foreign
savings. The other variables are income (Y), inflation (Pi), domestic
and foreign interest rates (R and Z)). I
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 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/92407.html
but it is not very precise. Is there any
2003 Jul 12
2
using cut on matrices
Dear list,
I'd like to use the function cut() on matrices, ie that when I apply
it to a matrix, it would return a matrix of the same dimensions
instead of a vector.
I wonder if there is a better (more elegant) solution than
matrix(cut(a, ...), ncol=ncol(a), nrow=nrow(a))
because I would like to use cut on both vectors and matrices and avoid
testing whether a is a matrix.
Thanks,
Tamas
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
2004 Jul 05
1
general questions about R on debian/powerpc
Hi,
I am about to but a laptop, and have narrowed the choices down to a
Dell Latitude 600 and an Apple Powerbook G4 Aluminium (Princeton
provides these models at a discount for grad students).
I am biased towards the Powerbook, and would like to run Debian on it.
I have only used debian on i386 platforms so far. I use R quite
frequently, so I would be interested in your experience of running R
2003 Oct 06
1
visualizing transition probability matrices
Dear List,
I have a couple of (~200) 3x3 transition probability matrices (ie each
defines a Markov chain). They are all estimated from the same
underlying process, so it ie meaningful to take their elemetwise mean
and standard deviation. [1]
First question: supposing that they are given in a list l, how do I
get their elementwise mean and standard deviation? Fortunately, the
mean of trans. prob.
2003 Apr 17
1
Testing for whole numbers
Is there a way in R to test if a given number is an integer, ie a
whole number? I am not referring to the data type of a number, but to
its value.
That is to say, is.whole(pi-pi+2) would be TRUE, whereas is.whole(4/3)
would be false. At the moment I am using
is.whole <- function(a) { floor(a)==a }
which is OK for real numbers, but not for complex ones (a+bi would be
a whole number if both a
2004 Apr 27
5
parsing a data file
Hi,
I need to parse a data file (output of a measuring device) of the
following format:
BEGIN RECORD [first record data] RECORD [second
record data] RECORD
[third record data]
END
Line breaks can (and do ;-() occur anywhere. White space behaves very
much like TeX, eg it is not important whether there are one or more
spaces or linebreaks as long as there is one of them. It is a text
file, not
2004 Apr 25
7
R vs Matlab: which is more "programmer friendly"?
Hi,
The department of economics at our university (Budapest) is planning a
course on numerical methods in economics. They are trying to decide
which software to use for that, and I would like to advocate R. The
other alternative is Matlab.
I have found comparisons in terms of computational time for matrix
algebra, but I don't think that is relevant: the bottleneck for
economists is usually
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 message
that it can't calculate the root because f.upper * f.lower is greater
2004 May 21
2
Re: Windows versus Unix packages in CRAN ...
Janusz Kawczak wrote:
> You simply need to remove the stuff related to MS Win from zzz.R;
> in partricular the lines after if( .... ) to clear your message.
> As you can see, the info relates to the WinMenu under MS Win.
I think people have been more than a little disingenuous in claiming
that getting the Rmetrics package to go under Linux is transparent.
If you have to dig into the