Re: [R] integrate function

2013-02-12 Thread Prof. Dr. Matthias Kohl
use pmin instead of min. hth Matthias On 12.02.2013 16:41, dan wang wrote: Hi All, Can any one help to explain why min and max function couldn't work in the integrate function directly. For example, if issue following into R: integrand - function(x) {min(1-x, x^2)} integrate(integrand, lower

Re: [R] integrate function

2013-02-12 Thread William Dunlap
wang Sent: Tuesday, February 12, 2013 7:41 AM To: r-help@r-project.org Subject: [R] integrate function Hi All, Can any one help to explain why min and max function couldn't work in the integrate function directly. For example, if issue following into R: integrand - function(x) {min

Re: [R] integrate function

2013-02-12 Thread dan wang
Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of dan wang Sent: Tuesday, February 12, 2013 7:41 AM To: r-help@r-project.org Subject: [R] integrate function Hi All, Can

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Navin Goyal
Apologies for the lengthy code. I tried a simple (and shorter) piece of code (pasted below) and it still gives me the same error for last few rows. Is this a bug or am I doing something totally wrong? Could anyone please provide some help/pointers ? PS. beta0 was fixed to 0.001 in the previous

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Navin Goyal
Apologies for the lengthy code. I tried a simple (and shorter) piece of code (pasted below) and it still gives me the same error for last few rows. Is this a bug or am I doing something totally wrong? Could anyone please provide some help/pointers ? PS. beta0 was fixed to 0.001 in the previous

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Berend Hasselman
On 06-04-2012, at 13:14, Navin Goyal wrote: Apologies for the lengthy code. I tried a simple (and shorter) piece of code (pasted below) and it still gives me the same error for last few rows. Is this a bug or am I doing something totally wrong? Could anyone please provide some

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Navin Goyal
Thank you so much for your help Berend. I did not see that my code had a typo and it was thus wrongly written ( I overlooked the i that was supposed to be actually 1) instead of for (q in *1*:length(comb1$ID)) I had it as for (q in *i*:length(comb1$ID)) It works correctly as

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-06 Thread Peter Ehlers
On 2012-04-06 07:19, Navin Goyal wrote: Thank you so much for your help Berend. I did not see that my code had a typo and it was thus wrongly written ( I overlooked the i that was supposed to be actually 1) instead of for (q in *1*:length(comb1$ID)) I had it as for (q in

[R] integrate function - error -integration not occurring with last few rows

2012-04-05 Thread Navin Goyal
Hi, I am using the integrate function in some simulations in R (tried ver 2.12 and 2.15). The problem I have is that the last few rows do not integrate correctly. I have pasted the code I used. The column named integral shows the output from the integrate function. The last few rows have no

Re: [R] integrate function - error -integration not occurring with last few rows

2012-04-05 Thread Berend Hasselman
On 06-04-2012, at 00:55, Navin Goyal wrote: Hi, I am using the integrate function in some simulations in R (tried ver 2.12 and 2.15). The problem I have is that the last few rows do not integrate correctly. I have pasted the code I used. The column named integral shows the output from the

[R] integrate function

2009-12-05 Thread li li
Hello, I have some trouble in terms of using integrate function in R. f1 is a function of p and x where x is supposed to be a vector. (See the code). Then I want to write function f2 which is a function of the vector x after I integrate out p. Can some one give me some help? Many thanks!

Re: [R] integrate function

2009-12-05 Thread David Winsemius
On Dec 5, 2009, at 4:59 PM, li li wrote: Hello, I have some trouble in terms of using integrate function in R. f1 is a function of p and x where x is supposed to be a vector. (See the code). Then I want to write function f2 which is a function of the vector x after I integrate out p.

Re: [R] integrate function

2009-12-05 Thread li li
Thank you very much for your reply! It is not an assignment. What I want to do is what we often do. If we have a bivariate function of x and p, I first fix x and integrate out p. Then the resultant function is only in terms of x. Here f1 is a bivariate function of x and p. f1 - function (p,x)

Re: [R] integrate function

2009-12-05 Thread Ravi Varadhan
@gmail.com Date: Saturday, December 5, 2009 7:13 pm Subject: Re: [R] integrate function To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Thank you very much for your reply! It is not an assignment. What I want to do is what we often do. If we have a bivariate function of x

Re: [R] integrate function

2009-12-05 Thread li li
Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: li li hannah@gmail.com Date: Saturday, December 5, 2009 7:13 pm Subject: Re: [R] integrate function To: David Winsemius dwinsem

Re: [R] integrate function

2009-12-05 Thread David Winsemius
. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: li li hannah@gmail.com Date: Saturday, December 5, 2009 7:13 pm Subject: Re: [R] integrate function To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Thank you very much for your reply

Re: [R] integrate function

2009-12-05 Thread Berend Hasselman
li li-13 wrote: Yes, f2 is the function I wanted to write. I tried to do use Vectorize function to f1, it did not work. f2 - function(x) + { + integrate(Vectorize(f1,vectorize.args =p), lower=0,upper=1, x) + } f2(c(2,3)) Error in Vectorize(f1, vectorize.args = p) :

[R] integrate() function error

2009-10-22 Thread fuzuo xie
This is my code , when i run it ,error happed . can you tell me what's the reason and modify it ?thank you very much !! the error is evaluation of function gave a result of wrong length e2-function(a) integrate(function(x) x,lower=0,upper=a)$value integrate(e2,lower=0, upper=0.5)$value

Re: [R] integrate() function error

2009-10-22 Thread andrew
Change e2 to the following and it works e2 - function(a) a^2/2 The reason it doesn't is that e2 must be able to handle vector inputs correctly. Your original function does not do this. from ?integrate f - an R function taking a numeric first argument and returning a numeric vector of the

Re: [R] Integrate function in R

2009-06-11 Thread Paul Hiemstra
?integrate, it is in the documentation Bhargab Chattopadhyay wrote: Hi! Can anyone please let me know what numerical integration procedure does the integrate function in package stats follow? Thank you in advance Shant [[alternative HTML version deleted]]

[R] Integrate function in R

2009-06-10 Thread Bhargab Chattopadhyay
Hi! Can anyone please let me know what numerical integration procedure does the integrate function in package stats follow? Thank you in advance Shant [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] Integrate function

2008-12-22 Thread David Winsemius
If these messages you're hearing are warnings, then the answer might be: ?warnings -- David Winsemius On Dec 22, 2008, at 6:07 PM, glenn roberts wrote: Quick One if any one can help please. On use of integration function ‘integrate’; how do I get the function to return just the value

Re: [R] Integrate function

2008-12-22 Thread David Winsemius
.. but it turned out he wanted; integrate(integrand)$value -- David Winsemius On Dec 22, 2008, at 6:26 PM, David Winsemius wrote: If these messages you're hearing are warnings, then the answer might be: ?warnings -- David Winsemius On Dec 22, 2008, at 6:07 PM, glenn roberts wrote: