Re: [R] Integration with variable bounds

From: Ravi Varadhan <rvaradhan_at_jhmi.edu>
Date: Tue, 29 Mar 2011 21:12:35 -0400

You get 0 because you did not specify lower and upper bounds that define the hyper-rectangle; therefore, the default is used which is (0,1)^4.

Specify the proper lower and upper bounds.

Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan_at_jhmi.edu

> Thanks for the tip but all I get is 0 for the integral. Any other
> suggestions?
>
> int <- function(y){
> u2 = y[1]
> z2 = y[2]
> u1 =y[3]
> z1 = y[4]
>
> reg.nonzero <- (u2 > z1 & u2 < z2) & (z2 > z1 & z2 < 12) & (u1 > 4 &
> u1 <
> z1) & (z1 > 4 & z1 < 12)
>
>
> ff <- ifelse (reg.nonzero, u1*(z1-u1)*u2*(z2-u2)*exp(-0.027*(12-z2)),
> 0)
>
>
> return(ff)
>
>
> }
>
>
> cuhre(4,1,int)
>
> --
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
>
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 30 Mar 2011 - 01:15:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 Mar 2011 - 02:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive