Displaying 20 results from an estimated 10000 matches similar to: "R: integration problem"
2011 Jun 06
2
Taking Integral and Optimization using Integrate, Optim and maxNR
Dear All, Hello!
I have some questoins in R programming as follows:
Question 1- How to take the integral of this function with respect to y, such that x would appear in the output after taking integral.
f(x,y)=(0.1766*exp(-exp(y+lnx))*-exp(y+lnx))/(1-exp(-exp(y+lnx))) y in (-6.907,-1.246)
It is doable in maple but not in R. At least I could not find the way.
p.s: result from maple is:
2009 Jan 02
1
R: numerical integration problems
hello all
happy new year and hope you r having a good holiday.
i would like to calculate the expectation of a particular random variable and would like to approximate it using a number of the functions contained in R. decided to do some experimentation on a trivial example.
example
========
suppose x(i)~N(0,s2) where s2 = the variance
the prior for s2 = p(s2)~IG(a,b)
so the posterior is
2018 Mar 23
1
Integrate erros on certain functions
In the help for ?integrate:
>When integrating over infinite intervals do so explicitly, rather than
just using a large number as the endpoint. This increases the chance of a
correct answer ? any function whose integral over an infinite interval is
finite must be near zero for most of that interval.
I understand that and there are examples such as:
## a slowly-convergent integral
integrand
2005 Nov 03
1
multidimensional integration not over a multidimensionalrectangle
Hi,
anyone knows about any functions in R can get multidimensional integration
not over a multidimensional rectangle (not adapt).
For example, I tried the following function f(x,n)=x^n/n!
phi.fun<-function(x,n)
{ if (n==1) {
x
}else{
integrate(phi.fun, lower=0, upper=x, n=n-1)$value
}
}
I could get f(4,2)=4^2/2!=8, but failed in f(4,3)=4^3/3! Thanks
Best,
Lynette
2013 Apr 09
1
Solving an integral in R gives the error “The integral is probably divergent”
I am trying to solve an integral in R. However, I am getting an error when
I am trying to solve for that integral.
The equation that I am trying to solve is as follows:
$$ C_m = \frac{{abs{x}}e^{2x}}{\pi^{1/2}}\int_0^t t^{-3/2}e^{-x^2/t-t}dt $$
[image: enter image description here]
The code that I am using is as follows:
a <- seq(from=-10, by=0.5,length=100)
## Create a function to compute
2007 Aug 23
1
nls() and numerical integration (e.g. integrate()) working together?
Dear List-Members,
since 3 weeks I have been heavily working on reproducing the results of an
economic paper. The method there uses the numerical solution of an integral
within nonlinear least squares. Within the integrand there is also some
parameter to estimate. Is that in the end possible to implement in R
[Originally it was done in GAUSS]? I'm nearly into giving up.
I constucted an
2011 Nov 10
2
performance of adaptIntegrate vs. integrate
Dear list,
[cross-posting from Stack Overflow where this question has remained
unanswered for two weeks]
I'd like to perform a numerical integration in one dimension,
I = int_a^b f(x) dx
where the integrand f: x in IR -> f(x) in IR^p is vector-valued.
integrate() only allows scalar integrands, thus I would need to call
it many (p=200 typically) times, which sounds suboptimal. The
2010 Jul 19
2
integral in R
Hello All,
I have to create a variable that is a function of another one (already
created), its cumulative distribution function and the integral of this
cumulative distribution, with limits: 0 and the value of the variable.
To be clear, I have the variable called “cip”. And its cdf called “cdfcip”
I need to create the variable:
bip = cip + ((1 – cdfcip)^4)*integral((1-cdf(u))^4*du, 0, value
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"
2007 Dec 06
1
Integral implicit function
Hi,
Could somebody help me with the following. I want to calculate the integral over an implicit function. I thought to integrate over a function depending on uniroot. In previous topics I found a thread about finding the root of an integral. And that works. But the other way around, does not work. Does R support this?
I included the following example. The function in the example is very easy
2005 Jun 20
1
r: integration question
hi all
at the outset i must APOLOGIZE for sending the following mail. it is not
R related but since there are many stats and maths buffs that use the
list i decided to send the following question.
integrate ((1+((y-bx)^2)/(av))*(1+(x^2)/(bv)))^(-0.5*(v+1))
over the interval 0 to inf
a>0, b>0 and v>4
y treated as a constant over the real line.
i could integrate the function using
2002 Jun 28
1
integrate function fails! (PR#1718)
Full_Name: José Enrique Chacón
Version: 1.5.0 and 1.3.1
OS: Windows Millenium
Submission from: (NULL) (158.49.28.155)
Dear reader:
I was trying to evaluate the L2 error produced when estimating the density
function N(0,1) from a sample of size 100 using a kernel density estimate. It
produced a strange value. You can reproduce the process by typing
samp<-rnorm(100)
2007 Dec 17
3
integration
Dear All,
I need to perform a numerical integration of one dimensional
fucntions. The extrems of integration are both finite and the functions
I'm working on are quite complicated. I have already tried both area()
and integrate(), but they do not perform well: area() is very slow and
integrate() does not converge. Are in R other functions for numerical
integration of one dimentional
2008 Mar 07
3
Numerical Integration in 1D
Dear UseRs,
I'm curious about the derivative of n!.
We know that Gamma(n+1)=n! So when on takes the derivative of
Gamma(n+1) we get Int(ln(x)*exp(-x)*x^n,x=0..Inf).
I've tried code like
> integrand<-function(x) {log(x)*exp(x)*x^n}
> integrate(integrand,lower=0,upper=Inf)
It seems that R doesn't like to integrate for any n, and I was
wondering if anyone knew a way around
2007 May 24
3
Problem with numerical integration and optimization with BFGS
Hi R users,
I have a couple of questions about some problems that I am facing with
regard to numerical integration and optimization of likelihood
functions. Let me provide a little background information: I am trying
to do maximum likelihood estimation of an econometric model that I have
developed recently. I estimate the parameters of the model using the
monthly US unemployment rate series
2008 Aug 27
5
Integrate a 1-variable function with 1 parameter (Jose L. Romero)
Hey fellas:
I would like to integrate the following function:
integrand <- function (x,t) {
exp(-2*t)*(2*t)^x/(10*factorial(x))
}
with respect to the t variable, from 0 to 10.
The variable x here works as a parameter: I would like to integrate the said function for each value of x in 0,1,..,44.
I have tried Vectorize to no avail.
Thanks in advance,
jose romero
2009 Sep 23
1
Numerical integration problem
Hi there
I'm trying to construct a model of mortality risk in 2D space that
requires numerical integration of a hazard function, for which I'm using
the integrate function. I'm occasionally encountering parameter
combinations that cause integrate to terminate with error "Error in
integrate... the integral is probably divergent", which I'm not sure how
to interpret. The
2010 Oct 29
2
what´s wrong with this code?
Hello, I want to maximize a likelihood function expressed as an
integral that can not be symbolically evaluated. I expose my problem
in a reduced form.
g<- function(x){
integrand<-function(y) {exp(-x^2)*y}
g<-integrate(integrand,0,1)
}
h<-function(x) log((g(x)))
g is an object of the class function, but g(2) is a integrate object,
I can print(g(2))
2011 Jun 22
1
numerical integration and 'non-finite function value' error
Dear R users,
I have a question about numerical integration in R.
I am facing the 'non-finite function value' error while integrating the
function
xf(x)
using 'integrate'. f(x) is a probability density function and assumed to
follow the three parameter (min = 0) beta distribution for which I have
estimated the parameters. The function is integrated
2018 Feb 06
2
question with integrate function
Hi all,
The function h below is a function of c and it should be a monotone
increasing function since the integrand is nonnegative and integral is
taken from c to infinity. However, as we can see from the plot, it is not
shown to be monotone. Something wrong with the usage of integrate function?
Thanks so much for your help.
Hanna
h <- function(c){
g <- function(x){pnorm(x-8.8,