Displaying 20 results from an estimated 300 matches similar to: "Integration in R"
2013 Jan 08
2
Integration in R
Hi R-users.
I'm having difficulty with an integration in R via
the package "cubature". I'm putting it with a simple example here. I wish
to integrate a function like:
f(x1,x2)=2/3*(x1+x2) in the interval 0<x1<x2<7. To be sure I tried it
by hand and got 114.33, but the following R code is giving me 102.6667.
2012 Mar 25
1
cubature
Hi,
I am using adaptIntegrate from Cubature to do numerical integration on a
double integral with a 1 x 2 vector x.
Say the function is something simple to start like f(x)=x1*x2 and I wish to
integrate x1 over (0,365-x2) and x2 over (0,365)
f <- function(x) {(x[2])*(x[1])} # "x" is vector
int1<-adaptIntegrate(f, lowerLimit = c(0, 0), upperLimit = c(365-x[2], 365))
I recieve
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
2012 Oct 23
1
Minimizing Computational Time
Dear R-users,
May I seek some suggestions from you. I have a long programme written in R
with several 'for' loops inside. I just want to get them out by any elegant
way (if there is!) to reduce the computational time of the main programme.
For instance, is there any smart way for the following programme that will
lessen time?
2013 Mar 11
2
vertical lines in R plot
Dear All,
May I seek your suggestion on a simple issue. I want to draw vertical lines
at some positions in the following R plot. To be more specific, I wish to
draw vertical lines at d=c(5.0,5.5,6) and they should go till
p=c(0.12,0.60,0.20) . I haven't found any way out, though made several
attempts. Please run the following commands first if you are interested in!
2013 Mar 21
1
"adaptIntegrate" function
Hi all,
it seems that there is problem with function "adaptIntegrate",
when the integration limits is infinity.
Please see the code below. The second integration does not
seem to work.
Can anyone familiar with this give some help?
Thank you with much.
Hanna
library(mnormt)
library(cubature)
ff <- function(x, rho){
mu <- rep(0,3)
Sigma
2013 Mar 05
2
Error message
Dear all,
I got an error message when running the following code.
Can anyone give any suggestions on fixing this type of error?
Thank you very much in advance.
Hanna
> integrand <- function(x, rho, a, b, z){
+ x1 <- x[1]
+ x2 <- x[2]
+ Sigma <- matrix(c(1, rho, rho, 1), 2,2)
+ mu <- rep(0,2)
+ f <-
2011 Jan 27
0
adaptIntegral takes too much time
Hello Dear List members,
as you can see (and guess) from the code below
adaptIntegrate(f,lowerLimit=c(-1,-1),upperLimit=c(.9999,.9999))
$integral
[1] 9.997e-09
$error
[1] 1.665168e-16
$functionEvaluations
[1] 17
$returnCode
[1] 0
> adaptIntegrate(f,lowerLimit=c(-1,-1),upperLimit=c(1,1))
the last command runs for 45 mins now.
-this one takes only less than sec:
2012 May 23
0
Error from using adaptIntegrate within a function that is then integrated
I want to measure the error in the estimation of a 2 dimensional density
function that is calculated using an integral but run into problems trying
to integrate with adaptIntegrate because the integrand also calls the
function adaptIntegrate. In particular I want
\int \hat{f}(x,y) - f(x,y) dx dy
where \hat{f}(x,y) = \int K(a,b, x, y) da db and in this simulation study I
know what the true value
2003 Dec 18
1
NUMERIC DERIVATE
UseRs,
I used the optim function
valor.optim <- optim(c(1,1,1),logexp1,method
="BFGS",control=list(fnscale=-1),hessian=T);
and I want to calculate the derivates,
psi1<-valor.optim$par[1]
psi2<-valor.optim$par[2]
psi3<-valor.optim$par[3]
a0=exp(psi1);
a1=exp(psi2)/(20+exp(psi2)+exp(psi3));
a2=exp(psi3)/(20+exp(psi2)+exp(psi3))
2011 May 03
2
adaptIntegrate - how to pass additional parameters to the integrand
Hello,
I am trying to use adaptIntegrate function but I need to pass on a few
additional parameters to the integrand. However, this function seems not to
have the flexibility of passing on such additional parameters.
Am I missing something or this is a known limitation. Is there a good
alternative to such restrictions, if there at all are?
Many thanks for your time.
HC
--
View this message in
2019 Apr 05
6
SMTPUTF8 support
Andr?, are you quite sure you have it working?
In this thread someone from Open-Xchange stated that no, Dovecot doesn?t
have SMTPUTF8 support implemented, and the same response was given by
another Dovecot developer last September (it ?is being considered? was
the answer then, see
https://dovecot.org/pipermail/dovecot/2018-September/112887.html).
I am using LMTP to deliver mail to Dovecot from
2007 Sep 13
1
Collapsing data frame; aggregate() or better function?
Hello r-help,
I am trying to collapse or aggregate 'some' of a data frame. A very
simplified version of my data frame looks like:
> tester
trip set num sex lfs1 lfs2
1 313 15 5 M 2 3
2 313 15 3 F 1 2
3 313 17 1 M 0 1
4 313 17 2 F 1 1
5 313 17 1 U 1 0
And I want to omit sex from the picture and just get an addition of num,
2005 Jun 06
1
A performance anomaly
I wrote a simple log likelihood (for the ordinary least squares (OLS)
model), in two ways. The first works out the likelihood. The second
merely calls the first, but after transforming the variance parameter,
so as to allow an unconstrained maximisation. So the second suffers a
slight cost for one exp() and then it pays the cost of calling the first.
I did performance measurement. One would
2013 Apr 03
5
scanning data in R
Dear R-user,
May I seek your suggestion. I have a data file 'stop' to be scanned in R.
But I want to ignore one specific number '21' there. Putting differently, I
want to get all numbers in the file except 21. Is there any command to
achieve it?
--------------------------------------------------------------
b<-scan("F:\\stop.txt")
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
2013 Jul 22
1
Error with sem function df = -6
Hello all,
I have an issue where I am generating data and trying to confirm the
estimates using a sem. I keep getting an error about the degree of freedom
being negative "Error in sem.default(ram, S = S, N = N, raw = raw, data =
data, pattern.number = pattern.number, : The model has negative degrees of
freedom = -6"
Can someone explain this error or tell me what is wrong with my
2011 Nov 28
0
function manipulation for integration
Hi All,
I'm trying to use one of the (2D) numerical integration functions, which is
not where the problem is. The function definition is as follows:
adaptIntegrate(f, lowerLimit, upperLimit, ...)
The problem is that I want to integrate a 3D function which has been
parametrised such that it is a 2D function:
eg. I want to integrate f(x_start+gradient_x*t1, y_start+gradient_y*t2) for
t1 in
2013 Jan 11
1
problems with package 'segmented'
Dear R-users,
I am trying to understand how the 'segmented'-package works to determine
breakpoints and slopes of regression lines in broken-line regression models.
However, I am not able to repeat the example on the "plant"-dataset,
which was reported in the accompanying paper of the package. (V.M.R
Muggeo, "Segmented: an R package to fit regression models with
2012 Nov 16
1
Interpretation of davies.test() in segmented package
My data:
I have raw data points that form a logit style curve as if they were a time
series. Which is to say they form 3 distinct lines with 3 distinct slopes
in backwards z pattern. A certain class of my data looks essentially flat
to the eye with marginal oscillation. What is important to me is the x
value at which the state change is occurring, in other words, the break
point
Use of