Displaying 20 results from an estimated 3000 matches similar to: "vectorized uni-root?"
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
2010 Aug 25
4
Secant Method Convergence (Method to replicate Excel XIRR/IRR)
Hi,
I am new to R, and as a first exercise, I decided to try to implement an XIRR function using the secant method. I did a quick search and saw another posting that used the Bisection method but wanted to see if it was possible using the secant method.
I would input a Cash Flow and Date vector as well as an initial guess. I hardcoded today's initial date so I could do checks in Excel.
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.
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(
1999 Apr 23
1
[S] uniroot -- doesn't work recursively
Dear Prof Azzalini,
You have an interesting example of recursive use of uniroot().
[re-cited at the end]
However, note that R currently has the same problem as S-plus:
Uniroot() doesn't work reliably, recursively.
When you found it to be better, you were just lucky.
The relevant file in R's source, src/main/optimize.c
says
/* WARNING : As things stand, these routines should
2003 Nov 20
2
reading data rows
I have problems reading a file with more than one row
to carry out mathematical calculations
I have a a file of the form
mu1 mu2 alpha beta Wsigma sigmaA b r
25 15 .05 .05 22 3 .3 .5
30 20 .1 .2 22 .3 .3 .5
I intend to read one row , carry out the calculations
and then the next row with which I intend to do the
same calculations.
I do the following.
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 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))
2011 Jul 02
5
%dopar% parallel processing experiment
dear R experts---
I am experimenting with multicore processing, so far with pretty
disappointing results. Here is my simple example:
A <- 100000
randvalues <- abs(rnorm(A))
minfn <- function( x, i ) { log(abs(x))+x^3+i/A+randvalues[i] } ?## an
arbitrary function
ARGV <- commandArgs(trailingOnly=TRUE)
if (ARGV[1] == "do-onecore") {
?library(foreach)
?discard <-
2007 Apr 20
2
Using power.t.test over a range of conditions
R-Helpers:
I would like to perform sample size calculations for an experiment. As
part of this process, I would like to know how various assumptions
affect the sample size calculation. For instance, one thing that I
would like to know is how the calculated sample size changes as I vary
the difference that I would like to detect. I tried the following
first, but got the associated error
2010 Sep 10
3
Is there a bisection method in R?
Dear fellow R-users,
Is there a function that does the bisection method? I was unable to find one.
Thanks in advance.
Gregory
[[alternative HTML version deleted]]
2009 Mar 16
1
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 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 proportion correct on the test by student k,
and q is the number of items on the test in total.
I
2010 Dec 21
3
how to see what's wrong with a self written function?
Hi all,
I am writing a simple function to implement regularfalsi (secant) method.
###################################################
regulafalsi=function(f,x0,x1){
x=c()
x[1]=x1
i=1
while ( f(x[i])!=0 ) {
i=i+1
if (i==2) {
x[2]=x[1]-f(x[1])*(x[1]-x0)/(f(x[1])-f(x0))
} else {
x[i]=x[i-1]-f(x[i-1])*(x[i-1]-x[i-2])/(f(x[i-1])-f(x[i-2]))
}
}
x[i]
}
2013 Apr 01
2
Is DUD available in nls()?
SAS has DUD (Does not Use Derivatives)/Secant Method for nonlinear
regression, does R offer this option for nonlinear regression?
I have read the helpfile for nls() and could not find such option, any
suggestion?
Thanks,
Derek
[[alternative HTML version deleted]]
2011 Sep 22
1
nlm's Hessian update method
Hi R-help!
I'm trying to understand how R's nlm function updates its estimate of the Hessian matrix. The Dennis/Schnabel book cited in the references presents a number of different ways to do this, and seems to conclude that the positive-definite secant method (BFGS) works best in practice (p201). However, when I run my code through the optim function with the method as "BFGS",
2004 Nov 01
2
non-linear solve?
hi: could someone please point me to a function that allows me to
solve general non-linear functions?
> irr.in <- function(r, c1, c2, c3 ) { return(c1+c2/(1+r) +
c3/(1+r)^2); }
> solve.nonlinear( irr.in, -100, 60, 70 );
0.189
If someone has written an irr function, this would be helpful,
too---though not difficult to write, either. thanks for any pointers.
Regards,
/iaw
2007 Dec 14
1
windows rtools missing gfortran.exe?
Hi,
I replaced my Rtools today as posted at
http://www.murdoch-sutherland.com/Rtools/Rtools.exe
Trying to build R-devel_2007-12-13.tar.gz without modifying MkRules
gives the gfortran command not found error below. I am wondering if
gfortran.exe is missing from (recent?) Rtools.exe or I am doing
something wrong.
Thanks to hints at Duncan's site, I worked around the error by adding
2007 Oct 26
5
help
hello,
please can anyone help me out. Am a new user of R
program. Am having problem
with this code below, not getting the expected
results.
1. Each m, the cumulative sum should be 1.000 but the
2nd and 3rd m returned 2.000 and 3.000
instead of 1.000.
2. to get the LCL(m) and UCL(m) for each m base on
these instructions
if out.cum > 0.025 then LCL(m)= y-1
if out.cum >0.975
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
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