Displaying 20 results from an estimated 7000 matches similar to: "problem using uniroot with integrate"
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,
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
2011 Nov 14
2
how to include integrate in a function that can be solved with uniroot?
Hallo,
I am trying to define expectation as an integral
and use uniroot to find the distribution parameter
for a given expectation.
However I fail to understand how to define properly
the functions involved and pass the parameters correctly.
Can anyone help me out?
Thanks,
Gerrit Draisma.
This what I tried:
=======
> # exponential density
> g <- function(x,lambda){ lambda
2000 Sep 20
1
integration in R?
I have the following problem.
inf
p= Int [dnorm(x-d) * pnorm(x) ^ (m-1)] dx
-inf
Given p and m, I want to find d. For example,
p m d
.9 2 1.81
Is there a way to solve this problem in R? Ideally I would have a
function with arguments p and m, and output d.
Thanks very much for any help.
Bill
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing
2008 Nov 08
3
Fitting a modified logistic with glm?
Hi all,
Where f(x) is a logistic function, I have data that follow:
g(x) = f(x)*.5 + .5
How would you suggest I modify the standard glm(..., family='binomial')
function to fit this? Here's an example of a clearly ill-advised attempt to
simply use the standard glm(..., family='binomial') approach:
########
# First generate some data
########
#define the scale and location of
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
Thanks a lot!
Asaf
--
View this message in context:
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 = statistics test from t -distribution
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
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(
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
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
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
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
2011 Feb 04
3
uniroot
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 follows:
Randomly generate values of A~(0,1), y0 = -(lnA)^-1
Where: A=Pr{X<xi|Y=yi-1} and a is the
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], :
f() values at
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.
2006 Oct 27
1
making uniroot a bit more robust?
Hi,
I wonder if it would make sense to make uniroot detect zeros at the
endpoints, eg
if f(lower)==0, return lower as the root, else
if f(upper)==0, return upper as the root, else
stop if f(upper)*f(lower) > 0 (currently it stops if >=), else
proceed to the algorithm proper.
Currently I am using a wrapper function to implement this, and I found
it useful. But I didn't want to send a
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
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
2009 Dec 08
4
lower.tail option in pnorm
Hi,
I would have thought that these two constructions would
produce the same result but they do not.
Resp <- rbinom(10, 1, 0.5)
Stim <- rep(0:1, 5)
mm <- model.matrix(~ Stim)
Xb <- mm %*% c(0, 1)
ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb)))
pnorm(as.vector(Xb), lower.tail = Resp, log.p = TRUE)
> ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb)))
[1] -0.6931472 -1.8410216