search for: functn

Displaying 20 results from an estimated 21 matches for "functn".

Did you mean: funct
2002 Jul 14
1
help with adapt function
...ng to use the function adapt, from the adapt library package, which does multidimensional numerical integration. I think I must be using the wrong syntax or something, because even a simple example does not work. Consider foo <- function(x){x[1]*x[2]} and adapt(2, lo = c(-1,-1), up = c(1,1), functn = foo) This simply hangs. A more complicated example crashes R, but never mind that for the moment. Perhaps some kind person could explain what I am doing wrong here? The help page says "functn an R function which should take a single vector argument and possibly some parameters and...
2008 Oct 19
1
multivariate integral with ADAPT when the parameter is close to boundary
...There is one problem I encountered when I used ADAPT to compute some 2-D integral w.r.t beta density. For example, when I try to run the following comments: fun2<-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))} int.fun2<-adapt(ndim=2,lo = c(0,0), up = c(1,1),functn = fun2,eps = 1e-4) It seems it will take very long time to run. Acturally, I stopped the program after it was running for like 20 minutes. I thought this might be due to the inclusion of the lower and upper in to the integral computation, so I tried to change the lower and upper limits: fun2<...
2007 Jul 07
2
No convergence using ADAPT
...ut, sigma = matrix(c(.1, 0, 0, .1), nrow = 2, ncol = 2, byrow = FALSE)) } require(mvtnorm) require(adapt) bottomB <- -5*sqrt(.1) topB <- 2 + 5*sqrt(.1) areaB <- (topB - bottomB)^2 unscaled.Po.in.a <- adapt(2, lo = c(bottomB, bottomB), up = c(topB, topB), minpts = 1000, eps = 1e-4, functn = trial) (1/areaB)*unscaled.Po.in.a$value ## FINISH PROGRAM I tried to run the program again changing a.) sigma in the trial function, b.) upper in the trial function, and c.) the bounds of integration; that is, bottomB and topB. The new program is below: ## START PROGRAM trial <- functi...
2001 Jan 11
1
segmentation fault in integrate (PR#812)
...ndary to be too small integrate causes a segmentation fault: > library(integrate) > integrate(dummy, -100, 0)$value [1] 1.387143 > integrate(dummy, -1000, 0)$value [1] NaN Warning message: Ifail=1, maxpts was too small. Check the returned relerr! in: adapt(1, lower, upper, minpts, maxpts, functn, eps, ...) > integrate(dummy, -10000, 0)$value Segmentation fault I'm running R.1.2.0 on Debian Linux. Regards Achim > version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status...
2003 Apr 26
2
Multiple Integration
...ng it integrates a scalar function over a multidimensional rectangle. I have integrand of several variable and upper, lower limit too variable. I wanted to see the result using adapt (though it is not for this purpose, I suppose) Func<-function(x){(x[1]*x[2])} adapt(2, lo=c(0,1), up=c(1,x[1]), functn=Func) it is not giving any error(it should, if it is not the correct way of putting up) but also not giving correct result. Is there any package to handle multiple integration in R?? Thanking you, with best regards, N. Dey
2008 Mar 07
1
triple integral: adapt package question
...where some of the boundaries are functions of the other variables? require(adapt) fn<-function(z,y,x) {exp(x^3+y^4+x^2*y+x*z^2+y/z)} x<-runif(200);y<-runif(200);z<-runif(200); c1<-.5;c2<-5;M<-100; #M to represent infinity i1<-adapt(3,lo=c(.0001,0,0),up=c(M,c1*z,c2/y),functn=fn)$value print(i1); Thanks, -- Davood Tofighi [[alternative HTML version deleted]]
2004 Jul 27
1
Integration with "adapt"
Hi all, I need to calculate a multidimensional integration on R. I am using the command "adapt" (from library adapt), although sometimes I get the following error message: Ifail=2, lenwrk was too small. -- fix adapt() ! Check the returned relerr! in: adapt(3, linf, lsup, functn = Integrando1) I guess it happens because the domain of integration is too small, although I tried a change of variables to avoid this problem and it didn?t help. The command adapt calls a fortran routine, but I don?t know fortran enough to fix the problem. Can someone help me? Thanks a lot Rodrig...
2007 Oct 29
1
meaning of lenwrk value in adapt function
R-listers, In using the adapt function, I am getting the following warning: Ifail=2, lenwrk was too small. -- fix adapt() ! Check the returned relerr! in: adapt(ndim = 2, lower = lower.limit, upper = upper.limit, functn = pr.set, Would someone explain what the 'lenwrk' value indicates in order to help diagnose this issue. Also, what are the possible codes for Ifail, so I can set some traps in my code to handle them correctly. I apologize for not including a reproducible example in this query, but the...
2006 Nov 11
2
Bayesian question (problem using adapt)
...x2, theta, param))} / 10000 kernel1 <- function(theta, param) { exp(loglik(theta, param)) + log(10000)} kernel2 <- function(theta, param) {( exp(loglik(theta, param)) + log(10000)) * gm(theta, param) } kernel2(theta0, param0) adapt(4, lower = c(0, 0, 0, 0), upper = c(1, 1, 1, 1), functn = kernel2(theta0, param0)) So I am trying to integrate the posterior density with four different parameters. But I cannot do anything to get the adapt function to work.
2010 Feb 09
2
Double Integral Minimization Problem
...-(2*index-0.324)*(radiusb/radius_eff)^(1/index))*(1+(((majaxis_pix^2)+(radiusb^2)-2*majaxis_pix*radiusb*cos(-thita)+(ellip^2-2*ellip)*((radiusb*sin(thita))^2))/(alpha^2)))^(-vita) return(counts2) } sersic=function(p) { counts0=p[1] index=p[2] radius_eff=p[3] value1=adapt(2,c(0,0),c(2*pi,200),functn=intensity,minpts=1000,maxpts=NULL,eps=0.01,counts0=counts0,index=index,radius_eff=radius_eff) test=value1$value f=sum(((counts-test)/countserr)^2) return(f) } out<-nlminb(c(16000.0, 3.0,10.0), sersic) ##############End of the code Any suggestions are welcome, Thank you, Marina -- Vi...
2006 Nov 18
1
Questions regarding "integrate" function
...m((x1.eval-x1)/h1))/(n*h1) f.x2 <- sum(dnorm((x2.eval-x2)/h2))/(n*h2) # Return the integrand # return((sqrt(f.x1)-sqrt(f.x2))**2) } estimate<-0.5*adapt(1, lo=lo.default, up=up.default, minpts=minpts.default, maxpts=maxpts.default, functn=integrand, eps=eps.default, x1, x2,h1,h2)$value But when I used it for one-dimension, it failed. Some of my colleagues suggested getting rid of "x2.eval" in the "integrand" because it is only one integral. But after I changed it, it still didn't work. R gave the error msg:...
2005 Mar 10
3
two-dimensional integration?
I find the one-dimensional "integrate" very helpful, but often enough I stumble into problems that require two (or more)-dimensional integrals. I suppose there are no R functions that can do this for me, "directly"? The ideal thing would be to be able to define say f <- function(x) { x1 <- x[1] x2 <- x[2] sin(x1*x2)*exp(x1-x2) } and then write say integrate(f,
2005 Sep 05
3
numerical intergation
how does one numerically intergate the following: A=function(x,y) { xy } over the range: 2<x<0 4<y<10 say. ie how would one set up the integrate function? i forgot!
2006 May 05
2
double integral
Dear r-users, Is there any command in R allowing to evaluate a double integral? for instance let say I want to evaluate the following integral: integrate[lo=(0,1),up=(2,3)] f(x,y)=x^2+y^2 where lo is the vector of lower bounds and up that of upper bounds. I thaught the function "adapt" would work but it did not. Many thanks, Dominique K.
2006 Nov 17
0
Question regarding "integrate" function
...val-x1)/h1))/(n*h1) f.x2 <- sum(dnorm((x2.eval-x2)/h2))/(n*h2) # Return the integrand # return((sqrt(f.x1)-sqrt(f.x2))**2) } estimate<-0.5*adapt(1, lo=lo.default, up=up.default, minpts=minpts.default, maxpts=maxpts.default, functn=integrand, eps=eps.default, x1, x2,h1,h2)$value But when I used it for one-dimension, it failed. Some of my colleagues suggested getting rid of "x2.eval" in the "integrand" because it is only one integral. But after I changed it, it still didn't work. R gave the error ms...
2006 Nov 17
0
questions regarding "integrate" function in R
...val-x1)/h1))/(n*h1) f.x2 <- sum(dnorm((x2.eval-x2)/h2))/(n*h2) # Return the integrand # return((sqrt(f.x1)-sqrt(f.x2))**2) } estimate<-0.5*adapt(1, lo=lo.default, up=up.default, minpts=minpts.default, maxpts=maxpts.default, functn=integrand, eps=eps.default, x1, x2,h1,h2)$value But when I used it for one-dimension, it failed. Some of my colleagues suggested getting rid of "x2.eval" in the "integrand" because it is only one integral. But after I changed it, it still didn't work. R gave the error msg:...
2007 Feb 13
1
Multidimensional Integration over arbitrary sets
Hi, I need to integrate a 2D function over range where the limits depend on the other e.g integrate f(x,y)=x*y over {x,0,1} and {y,x,1}. i.e \int_0^1 \int_x^1 xy dydx I checked adapt but it doesn't seem to help here. Are they any packages for this sort of thing? I tried RSitesearch but couldn't find the answer to this. Many thanks for you help. Regards Saptarshi Saptarshi Guha
2007 Nov 05
0
multidimensional integration with adapt
Hello, I apologize for eventual double-posting. I am trying to integrate a 2-dimensional function that already calls the function adapt. More precisely, I am calling adapt(2,lower=c(-100,-100),upper=c(100,100),functn=function(s){1-exp(-50*Unc enteredGauss(c(-10,10,-10,10),60,s)}) where UncenteredGauss is given by the following code in R: UncenteredGauss=function(limsamp,sigma2,s) { int=adapt(2,lower=c(limsamp[1],limsamp[3]),upper=c(limsamp[2],limsamp[4]),fu nctn=function(u){h(sigma2,s,u)}) value=int...
2009 Mar 23
0
Problems with adapt
...[i] +thmu*(e3[i])) Pni<- (y$Ch1[i]*exp(U1) + y$Ch2[i]*exp(U2)+ y$Ch3[i]*exp(U3))/(exp(U1)+exp(U2)+exp(U3)) fe<- exp((-e1[i]*e1[i]-e2[i]*e2[i]-e3[i]*e3[i])/(2*r)) fv<- exp((-v[1]*v[1]-v[2]*v[2])/(2*s)) prelik<- Pni*fe*fv return(prelik) } int[i]<- adapt(2,lo = c(-4,-4), up = c(4,4), functn= lstarpre, eps=0.01)$value print(int[i]) lik[i]<- log(max(1E-20,int)) print(lik[i]) } #End Loop logl<-sum(lik) return(-logl) } p<-optim(c(0,0,0,0,0,0,0,0,0,0,0),mnl.lik,y=DATA,method="BFGS",hessian=T, control = list(maxit=6000, temp=2000, trace=4))
2000 Jan 19
1
Segmentation fault using integrate()
Hi all, Running R 0.90.1 on a RH 6.1 system. Installation of the integrate_2.1-2 package went smoothly. My code contains a loop in which integrate() is called several times in each pass. I get a segmentation fault after what seems to be a random number of calls to integrate(). Debug output shows: Program received signal SIGSEGV, Segmentation fault. promiseArgs (el=0x40276414,