similar to: questions regarding "integrate" function in R

Displaying 20 results from an estimated 2000 matches similar to: "questions regarding "integrate" function in R"

2006 Nov 18
1
Questions regarding "integrate" function
Hi there. Thanks for your time in advance. I am using R 2.2.0 and OS: Windows XP. My final goal is to calculate 1/2*integral of (f1(x)^1/2-f2(x)^(1/2))^2dx (Latex codes: $\frac{1}{2}\int^{{\infty}}_{\infty} (\sqrt{f_1(x)}-\sqrt{f_2(x)})^2dx $.) where f1(x) and f2(x) are two marginal densities. My problem: I have the following R codes using "adapt" package. Although "adapt"
2006 Nov 17
0
Question regarding "integrate" function
Hi there. Thanks for your time in advance. My final goal is to calculate 1/2*integral of (f1(x)^1/2-f2(x)^(1/2))^2dx (Latex codes: $\frac{1}{2}\int^{{\infty}}_{\infty} (\sqrt{f_1(x)}-\sqrt{f_2(x)})^2dx $.) where f1(x) and f2(x) are two estimated marginal densities. My problem: I have the following R codes using "adapt" package. Although "adapt" function is mainly designed
2001 Jan 11
1
segmentation fault in integrate (PR#812)
I tried to integrate numerically a function wich is similar to the following: > dummy <- function(x) { exp(-1*x) * dnorm(x) } > dummy(-100) [1] 0 > dummy(-1000) [1] NaN > dummy(-10000) [1] NaN If I choose the lower boundary to be too small integrate causes a segmentation fault: > library(integrate) > integrate(dummy, -100, 0)$value [1] 1.387143 > integrate(dummy, -1000,
2011 Dec 10
2
efficiently finding the integrals of a sequence of functions
Hi folks, I am having a question about efficiently finding the integrals of a list of functions. To be specific, here is a simple example showing my question. Suppose we have a function f defined by f<-function(x,y,z) c(x,y^2,z^3) Thus, f is actually corresponding to three uni-dimensional functions f_1(x)=x, f_2(y)=y^2 and f_3(z)=z^3. What I am looking for are the integrals of these three
2010 Feb 09
2
Double Integral Minimization Problem
Hello all, I am trying to minimize a function which contains a double integral, using "nlminb" for the minimization and "adapt" for the integral. The integral is over two variables (thita and radiusb) and the 3 free parameters I want to derive from the minimization are counts0, index and radius_eff. I have used both tasks in the past successfully but this is the first time
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
2002 Jul 14
1
help with adapt function
Dear People, I'm trying 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,
2007 Nov 14
0
R Crashes on certain calls of Adapt
I'm having trouble with adapt. I'm trying to use it in a Bayesian setting, to integrate the posterior distribution, and to find posterior means. I tried using the following script, and things went ok: data = rnorm(100,0.2,1.1) data = c(data,rnorm(10,3,1)) data = data[abs(data)<2*sd(data)] prior = function(x){ dgamma(x[2],shape=2,scale=1)*dnorm(x[1],0,.5) } liklihood =
2003 Apr 21
2
piece wise functions
Hello, Apologies if this question has already arised, hope you can help me to the find the solution to this or point the place to look at. I have a multidimensional piece-wise regression linear problem, i.e. to find not only the regression coefficients for each "interval" but also the beginning and ends of the intervals. To simplify it to the one dimensional case and two intervals,
2001 Mar 08
1
inconsistent results when calling functions with other func (PR#869)
Hello Bug people, I have an unexpected behavior and am unsure whether the problem is in my thinking, my implementation or the program R. Basically I get two different answers depending on how I call a function which takes other functions as arguments as indicated below. To me it should make no difference if f is a function that returns the function g then z(f(x)) whould give the same as y<-
2009 May 06
0
bivariate normal and rho
Hi, Let f(rho) = E[F_1(x) F_2(y)], i.e f(rho) is the expectation of F(x) * F(y) with respect to the bivariate Gaussian density with mean 0 and covariance matrix [1 rho; rho 1]. Moreover, assume F_1(x) and F_2(y) to be increasing functions of x and y respectively. I was wondering if it was true that f(rho) is an increasing function of rho. If so, are there any references? Best, Agos
2007 Jul 07
2
No convergence using ADAPT
I am trying calculate a probability using numerical integration. The first program I ran spit out an answer in a very short time. The program is below: ## START PROGRAM trial <- function(input) { pmvnorm(lower = c(0,0), upper = c(2, 2), mean = input, sigma = matrix(c(.1, 0, 0, .1), nrow = 2, ncol = 2, byrow = FALSE)) } require(mvtnorm) require(adapt) bottomB <- -5*sqrt(.1) topB <-
2012 May 23
1
numerical integration
Greetings, Sorry, the last message was sent by mistake! Here it is again: I encounter a strange problem computing some numerical integrals on [0,oo). Define $$ M_j(x)=exp(-jax) $$ where $a=0.08$. We want to compute the $L^2([0,\infty))$-inner products $$ A_{ij}:=(M_i,M_j)=\int_0^\infty M_i(x)M_j(x)dx $$ Analytically we have $$ A_{ij}=1/(a(i+j)). $$ In the code below we compute the matrix
2007 Mar 28
1
warnings on adapt
Hi all I was wondering if someone could help me. I have to estimate some parameters, so I am using the function nlm. Inside this function I have to integrate, hence I am using the function adapt. I don't understand why it is giving the following warnings: At the beginning: Warning: a final empty element has been omitted the part of the args list of 'c' being evaluated was:
2012 May 23
0
numerical integrals
Greetings,   I encounter a strange problem computing some numerical integrals on [0,oo). Define $$ M_j(x)=exp(-jax) $$ where $a=0.08$. We want to compute the $L^2([0,\infty))$-inner products $$ A_{ij}:=(M_i,M_j)=\int_0^\infty M_i(x)M_j(x)dx $$ Analytically we have $$ A_{ij}=1/(a(i+j)). $$ In the code below we compute the matrix $A_{i,j}$, $1\leq i,j\leq 5$, numerically and check against the known
2010 Sep 21
3
bivariate vector numerical integration with infinite range
Dear list, I'm seeking some advice regarding a particular numerical integration I wish to perform. The integrand f takes two real arguments x and y and returns a vector of constant length N. The range of integration is [0, infty) for x and [a,b] (finite) for y. Since the integrand has values in R^N I did not find a built-in function to perform numerical quadrature, so I wrote my own after
2003 Nov 10
1
ts package function filter: mismatch between function action and help (PR#5017)
Dear people, I'm running RedHat 9.0 and R : Version 1.7.1 (2003-06-16) from the help file # Usage: # # filter(x, filter, method = c("convolution", "recursive"), # sides = 2, circular = FALSE, init) # init: for recursive filters only. Specifies the initial values of # the time series just prior to the start value, in reverse # time
2003 Apr 26
2
Multiple Integration
Dear all, May I do multiple integration using R? I was looking adapt but it is saying 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
2013 Nov 19
1
Generación de números aleatorios. Mixtura k-puntos
Saludo cordial para cada uno. Les pido ayuda para generar números aleatorios de una mixtura k-puntos. Sabemos que la función de distribución F es una mixtura k-puntos si es de la forma F(x) = p_1 F_1(x) + p_2 F_2(x) + … + p_k F_k(x), donde F_j es una función de distribución de probabilidad, p_j > 0 y suma(p_j) = 1, para j = 1, 2, …, k. En mi caso particular F es la suavización de la
2010 Sep 08
11
problem with outer
Hello, i wrote this function guete and now i want to plot it: but i get this error message. i hope someone can help me. Error in dim(robj) <- c(dX, dY) : dims [product 16] do not match the length of object [1] p_11=seq(0,0.3,0.1) p_12=seq(0.1,0.4,0.1) guete = function(p_11,p_12) { set.seed(1000) S_vek=matrix(0,nrow=N,ncol=1) for(i in 1:N) { X_0=rmultinom(q-1,size=1,prob=p_0)