Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-24 Thread Hans W
I hereby protest strongly against the misuse of this thread through unnecessary and pointless discussions. My request was satisfactorily answered with references to R libraries and legitimate warnings about the use of zero-based indexing schemes in R. If you want to continue the discussions, PLEASE

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Hans W
t 13:36, Ben Bolker wrote: > > https://cran.r-project.org/package=index0 > > On Sun, Apr 21, 2024, 3:56 AM Hans W wrote: >> >> As we all know, in R indices for vectors start with 1, i.e, x[0] is not a >> correct expression. Some algorithms, e.g. in graph theory or comb

[R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Hans W
library that provides this functionality? Or is there a simple trick to do this in R? The expression 'x[0]' must be possible, does this mean the syntax of R has to be twisted somehow? Thanks, Hans W. [[alternative HTML version deleted]] _

Re: [R] Dependency errors for package pracma

2023-11-09 Thread Hans W
What really interests me: With all those strict checking procedures, how is it possible that the new 'Matrix' version got accepted on CRAN? I think this happened twice to me before, and it takes a lot of time to check package dependencies that turn out to be not dependent -- more time than checki

[R] Dependency errors for package pracma

2023-11-08 Thread Hans W
I tried to update my package {pracma} on CRAN from 2.4.2 (2022-09-21) to version 2.4.4 (2023-11-08). This package reverse depends / imports / suggests on 350 packages on CRAN and 25 packages on Bioconductor. The only changes are small corrections on some help files, a new function for stereographi

Re: [R] Noisy objective functions

2023-08-13 Thread Hans W
;SANN". See the Optimization cheatsheet I wrote with John Nash: "NOTE: CG (John is the author!) and SANN are NOT recommended." https://github.com/hwborchers/CheatSheets/blob/main/Base%20R%20Optim%20Cheatsheet.pdf Hans W. On Sun, 13 Aug 2023 at 21:28, Hans W wrote: > > While w

[R] Noisy objective functions

2023-08-13 Thread Hans W
While working on 'random walk' applications, I got interested in optimizing noisy objective functions. As an (artificial) example, the following is the Rosenbrock function, where Gaussian noise of standard deviation `sd = 0.01` is added to the function value. fn <- function(x) (1

[R] R Redis

2021-11-28 Thread Hans W
> Have anybody used this module? > https://cran.r-project.org/web/packages/rredis/README.html > > Could share your experience please. thank you. I have successfully used this package (on Linux and macOS) and I think it is a great way of storing hashed data across different platforms and programmin

Re: [R] Testing optimization solvers with equality constraints

2021-05-22 Thread Hans W
Yes. "*on* the unit sphere" means on the surface, as you can guess from the equality constraint. And 'auglag()' does find the minimum, so no need for a special approach. I was/am interested in why all these other good solvers get stuck, i.e., do not move away from the starting point. And how to av

Re: [R] Testing optimization solvers with equality constraints

2021-05-21 Thread Hans W
Mark, you're right, and it's a bit embarrassing as I thought I had looked at it closely enough. This solves the problem for 'alabama::auglag()' in both cases, but NOT for * NlcOptim::solnl -- with x0 * nloptr::auglag -- both x0, x1 * Rsolnp::solnp -- with x0 * Rdonlp::donlp

[R] Testing optimization solvers with equality constraints

2021-05-21 Thread Hans W
Just by chance I came across the following example of minimizing a simple function (x,y,z) --> 2 (x^2 - y z) on the unit sphere, the only constraint present. I tried it with two starting points, x1 = (1,0,0) and x2 = (0,0,1). #-- Problem definition in R f = function(x) 2 * (x[1]^2 -

[R] Which external functions are called in a package? [Solved]

2020-01-08 Thread Hans W Borchers
By using the *pkgapi* package and with quite a bit of manual work I was able to (almost) automatically find all function calls to my package in 150 depending on, importing, or suggesting packages. It took two days to overcome all the obstacles during the process -- and was a very rewarding experien

Re: [R] Fwd: Which external functions are called in a package?

2020-01-03 Thread Hans W Borchers
e reverse dependencies on your packages' CRAN web page. > > On January 3, 2020 1:45:42 PM PST, Hans W Borchers > wrote: > >You are absolutely right. I forgot that there is a difference between > >the unpacked and the installed directory of a package. The > >documentation

[R] Fwd: Which external functions are called in a package?

2020-01-03 Thread Hans W Borchers
You are absolutely right. I forgot that there is a difference between the unpacked and the installed directory of a package. The documentation of the *pkgapi* package in development is quite scarce and does not mention the details. Thanks for the tip. --HW PS: Still I would like to learn about ot

[R] Which external functions are called in a package?

2020-01-03 Thread Hans W Borchers
How can I find out which functions of my package A are called within another package B that depends on, imports, or suggests package A ? And more specifically, which functions in B are calling functions in A ? I tried to utilize the *pkgapi* package, but get error messages like > map_package(

Re: [R] class of 'try' if error is raised

2019-12-15 Thread Hans W Borchers
en mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Sun, Dec 15, 2019 at 6:21 AM Hans W Borchers wrote: >> >> I have been informed by CRAN administrators that th

[R] class of 'try' if error is raised

2019-12-15 Thread Hans W Borchers
I have been informed by CRAN administrators that the development version of R issues warnings for my package(s). Some are easy to mend (such as Internet links not working anymore), but this one I don't know how to avoid: Error in if (class(e) == "try-error") { : the condition has length > 1 I

Re: [R] CRAN package NlcOptim query

2019-01-18 Thread Hans W Borchers
The maintainer of the *NlcOptim* package told me that he has fixed the problem and already submitted a new version to CRAN. Thanks, XianYan, for this prompt reaction. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.

Re: [R] CRAN package NlcOptim query

2019-01-15 Thread Hans W Borchers
Wed, Dec 12, 2018 at 12:45 PM Hans W Borchers wrote: > > This is still not complete: `x_than0` is missing. > `Constr_new` is written with a capital 'C'. > And aeq2 is a list of column vectors, not a matrix. > Setting the tolerance to 0 does not seem to be a good idea. &

Re: [R] CRAN package NlcOptim query

2018-12-12 Thread Hans W Borchers
This is still not complete: `x_than0` is missing. `Constr_new` is written with a capital 'C'. And aeq2 is a list of column vectors, not a matrix. Setting the tolerance to 0 does not seem to be a good idea. Making aeq2 a matrix and adding `x_than0 <- matrix(c(1, 1))`, then aeq2 <- as.matrix(ae

Re: [R] How can I know the Hausdorff dimensions of fractals in the 'fractalcurve' function of package 'pracma'?

2018-09-15 Thread Hans W Borchers
> Dear Dr. Hans W. Borchers, This is a public mailing list; do not address specific people here, everyone can read and (possibly) answer your questions. And please send e-mail in plain text format, not as HTML. > I'm using your 'pracma' package. It is very useful. May I ha

Re: [R] Optimisation with Normalisation Constraint

2018-06-22 Thread Hans W Borchers
One way will be to solve this as an ordinary optimization problem with an equality constraint. Function `alabama::auglag` can do this: library(alabama) fn <- function(p) sum((df$y - p[1]*exp(-p[2]*df$x))^2) heq <- function(p) sum(p[1]*exp(-p[2]*df$x)) - 5 # Start with initial valu

Re: [R] lsqlin in R package pracma

2015-09-04 Thread Hans W Borchers
On Tue, Sep 1, 2015 at 11:24 PM, Wang, Xue, Ph.D. wrote: > > slsqp in R seems quite slow. Does anyone have some suggestion as how to speed > up this? > It is no surprise that a general solver like slsqp() takes longer than specialized quadratic solvers such as solve.QP, ipop(), or lowRankQP(). Y

Re: [R] lsqlin in R package pracma

2015-08-28 Thread Hans W Borchers
I got interested in enabling the full funcionality that MATLAB's lsqlin() has, that is with equality and bound constraints. To replace an equality constraint with two inequality constraints will not work with solve.QP() because it requires positive definite matrices. I will use kernlab::ipop() inst

Re: [R] lsqlin in R package pracma

2015-08-26 Thread Hans W Borchers
I am a strong advocate of the *nloptr* package; and "sequential quadratic programming", i.e. slsqp(), should be a good choice for least-squares problems. Note that you still have to provide a starting point. BUT: this point does not need to lie in the interior of the feasible region. So you can st

Re: [R] lsqlin in R package pracma

2015-08-26 Thread Hans W Borchers
On Mon Aug 24 Wang, Xue, Ph.D. Wang.Xue at mayo.edu wrote > I am looking for a R version of Matlab function lsqlin. I came across > R pracma package which has a lsqlin function. Compared with Matlab lsqlin, > the R version does not allow inequality constraints. > I am wondering if this functionalit

Re: [R] Second order bessel function

2015-03-05 Thread Hans W Borchers
On Wed Mar 4 21:32:30 CET 2015 Chris Vanlangenberg writes: > > I want to compute the numerical values for modified second order bessel > function given x and other parameters, currently base R has a bessel > function for 1st order and I have tried to use the relationship between 1st > and 2nd order

Re: [R] integrate with vector arguments

2015-02-26 Thread Hans W Borchers
marKo ffri.hr> writes: > > I'm a bit stuck. > I have to integrate a series of polynomial functions with vector > arguments. > > v1<-c(1:5) > v2<-c(1:5) > > f1<-function (x) {v1*x+v2*x^2} > > The problem is that integrate(f1, 0, 1) does not work. The point is not that there are "vector arguments"

Re: [R] Nonlinear integer programming (again)

2015-02-16 Thread Hans W Borchers
Zwick, Rebecca J ETS.ORG> writes: > Oddly, Excel's Solver will produce a solution to such problems but > (1) I don't trust it and > (2) it cannot handle a large number of constraints. > [...] > My question is whether there is an R package that can handle this problem. There are not many free in

Re: [R] Looking for an R package for Set Cover Problem

2015-01-25 Thread Hans W Borchers
As the Wikipedia page you took your example problem from explains, the sets cover problem can be formulated as an integer linear programming problem. In R, such problems will be solved effectively applying one of the available MILP packages, for example LPsolve or Rsymphony. Kumar Mainali gmail.

Re: [R] Double Infinite Integration

2013-12-06 Thread Hans W Borchers
Aya Anas feps.edu.eg> writes: > Hello all, > > I need to perform the following integration where the integrand is the > product of three functions: > f(x)g(y)z(x,y) > > the limits of x are(0,inf) and the limits of y are(-inf,inf). > > Could this be done using R? There is a saying: Don't ask C

Re: [R] Graphing complex functions

2013-10-22 Thread Hans W Borchers
John Van Praag jvp247.com> writes: > > Does R have any facilities, or packages, for graphing complex functions? Package 'elliptic' has function view() for "Visualization of complex functions using colourmaps and contours" Hans Werner __ R-help@r

Re: [R] MCP solver

2013-10-12 Thread Hans W Borchers
Maxwell, John McFarland wsu.edu> writes: > Hello, > > I'm trying to find a solver that will work for the mixed complementarity > problem (MCP). I've searched the CRAN task view page on optimization and > mathematical programming as well as many google searches to no avail. > Does anyone know i

Re: [R] How to double integrate a function in R

2013-07-26 Thread Hans W Borchers
Tiago V. Pereira mbe.bio.br> writes: > I am trying to double integrate the following expression: > > # expression > (1/(2*pi))*exp(-y2/2)*sqrt((y1/(y2-y1))) > > for y2>y1>0. > > I am trying the following approach > > # first attempt > > library(cubature) > fun <- function(x) { (1/(2*

Re: [R] how to compute maximum of fitted polynomial?

2013-06-05 Thread Hans W Borchers
David Winsemius comcast.net> writes: > [...] > > On Jun 4, 2013, at 10:15 PM, Hans W Borchers wrote: > > > In the case of polynomials, "elementary math ... methods" can > > actually be > > executed with R: library(polynomial)

Re: [R] how to compute maximum of fitted polynomial?

2013-06-04 Thread Hans W Borchers
Bert Gunter gene.com> writes: > > 1. This looks like a homework question. We should not do homework here. > 2. optim() will only approximate the max. > 3. optim() is not the right numerical tool for this anyway. optimize() is. > 4. There is never a guarantee numerical methods will find the max. >

Re: [R] Is DUD available in nls()?

2013-04-02 Thread Hans W Borchers
Bert Gunter gene.com> writes: > > I certainly second all Jeff's comments. > > **HOWEVER** : > http://www.tandfonline.com/doi/pdf/10.1080/00401706.1978.10489610 > > IIRC, DUD's provenance is old, being originally a BMDP feature. > Thanks for the pointer. That seems to be an interesting derivat

Re: [R] Optimization in R similar to MS Excel Solver

2013-03-12 Thread Hans W Borchers
Pavel_K vsb.cz> writes: > > Dear all, > I am trying to find the solution for the optimization problem focused on > the finding minimum cost. > I used the solution proposed by excel solver, but there is a restriction > in the number of variables. > > My data consists of 300 rows represent cities

Re: [R] R nls results different from those of Excel ??

2013-02-19 Thread Hans W Borchers
Jeff Newmiller dcn.davis.ca.us> writes: > > Excel definitely does not use nonlinear least squares fitting for power > curve fitting. It uses linear LS fitting of the logs of x and y. There > should be no surprise in the OP's observation. May I be allowed to say that the general comments on MS Ex

Re: [R] Using lm to estimate a parameter?

2013-02-19 Thread Hans W Borchers
Uwe Ligges statistik.tu-dortmund.de> writes: > > On 19.02.2013 11:23, hellen wrote: > > Hi, > > I have a data with three variables (X,Y,Z) and I have an equation as > > Z=X/(1+L*X/Y) where L is a constant which need to be estimated from data. > > How should I write the formula in lm or is it poss

Re: [R] minimizing a numerical integration

2013-02-16 Thread Hans W Borchers
> Dear all, > > I am a new user to R and I am using pracma and nloptr libraries to minimize > a numerical integration subject to a single constraint . The integrand > itself is somehow a complicated function of x and y that is computed > through several steps. i formulated the integrand in a sepa

Re: [R] cubic spline

2012-12-02 Thread Hans W Borchers
> but definitely *no* need to use a function from an extra CRAN > package .. as someone else ``erronously'' suggested. Except that Matlab's interp1() 'cubic' method does not use cubic spline interpolation, but Moler's 'pchip' approach, a piecewise cubic Hermite interpolation. Thus the results ar

Re: [R] The best solver for non-smooth functions?

2012-07-18 Thread Hans W Borchers
Cren bancaakros.it> writes: > The most robust solver for non-smooth functions I know of in R is Nelder-Mead in the 'dfoptim' package (that also allows for box constraints). First throw out the equality constraint by using c(w1, w1, 1-w1-w2) as input. This will enlarge the domain a bit, but com

Re: [R] identifying local maxima

2012-07-12 Thread Hans W Borchers
Gary Dong gmail.com> writes: > > Dear R users, > > I have created a Loess surface in R, in which x is relative longitude by > miles, y is relative latitude by miles, and z is population density at the > neighborhood level. The purpose is to identify some population centers in > the region. I'm w

Re: [R] numerical integration

2012-05-23 Thread Hans W Borchers
Michael Meyer yahoo.com> writes: > Check your logic. The following lines show that integrate *does* return the correct values: a = 0.08 # alpha M <- function(j,s){ return(exp(-j*a*s)) } A <- matrix(NA, 5, 5) for (i in 1:5) { for (j in i:5) { f <-

Re: [R] Need to help to get value for bigger calculation

2012-05-22 Thread Hans W Borchers
Rehena Sultana yahoo.com> writes: > I want to calculate values like 15^200 or 17^300 in R. In normal case it can > calculate the small values of b (a^b). > I have fixed width = 1 and digits = 22 but still answers are Inf. > > How to deal the cases like these? Thanks in advance. library

Re: [R] Runs up and runs down test

2012-05-19 Thread Hans W Borchers
JWDougherty surewest.net> writes: > Can someone point me to an implementation of the "runs up and runs > down" test, or does such beast exist in R? From web searches the > "runs up and runs down" test is commonly used for testing pseudo-random > number generators and in simulations.  John C. Davi

Re: [R] Optimization inconsistencies

2012-05-18 Thread Hans W Borchers
Marc Girondot yahoo.fr> writes: > > Le 18/05/12 00:14, Nathan Stephens a écrit : > > I have a very simple maximization problem where I'm solving for the vector > > But I get inconsistent results depending on what starting values I. I've > > tried various packages but none seem to bee the very sol

Re: [R] Optimization inconsistencies

2012-05-18 Thread Hans W Borchers
peter dalgaard gmail.com> writes: > > On May 18, 2012, at 00:14 , Nathan Stephens wrote: > > > I have a very simple maximization problem where I'm solving for the vector > > x: > > > > objective function: > > w'x = value to maximize > > > > box constraints (for all elements of w): > > low < x

Re: [R] Translation of matlab vectors code into r

2012-05-06 Thread Hans W Borchers
Haio gmail.com> writes: > > Hi there > I am new user of r, i would need some help to translate som code for vectors > in matlab to r. I have managed to translate the first 7 rows, but not the > rest. Could anyone give me any suggestions for this problem?? > > Matlab code: > > tempo=[]; > temps

Re: [R] Define lower-upper bound for parameters in Optim using Nelder-Mead method

2012-05-02 Thread Hans W Borchers
Ben Bolker gmail.com> writes: > > wlandres.net> writes: > > In addition to these options, there is also a derivative-free > box-constrained optimizer (bobyqa) in the 'minqa' package (and in > an optim-like wrapper via the optimx package), and > a box-constrained Nelder-Mead optimizer in the

Re: [R] Error in gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function

2012-04-03 Thread Hans W Borchers
> I am trying to obtain the grafic of a pdf . but this error keeps showing . > Here is the code Or use the complex gamma function gammaz() in package 'pracma'. The following code works, that is produces a plot: library(pracma) MXN.fd <- function(x,alpha,beta,mu,delta) { A <- (2*co

Re: [R] R numerical integration

2012-03-26 Thread Hans W Borchers
casperyc hotmail.co.uk> writes: > I don't know what is wrong with your Maple calculations, but I think you should check them carefully, because: (1) As Petr explained, the value of the integral will be < 0.5 (2) The approach of Peter still works and returns : 0.4999777 (3) And the same result c

Re: [R] R numerical integration

2012-03-24 Thread Hans W Borchers
Hans W Borchers googlemail.com> writes: > > casperyc hotmail.co.uk> writes: > > > Is there any other packages to do numerical integration other than the > > default 'integrate'? > > Basically, I am integrating: > > > > integrate(fu

Re: [R] R numerical integration

2012-03-24 Thread Hans W Borchers
casperyc hotmail.co.uk> writes: > Is there any other packages to do numerical integration other than the > default 'integrate'? > Basically, I am integrating: > > integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value > > The integration is ok provided sigma is >0. > However, when m

Re: [R] ACM Software Copyright and License Agreement

2012-02-17 Thread Hans W Borchers
peter dalgaard gmail.com> writes: > On Feb 16, 2012, at 12:31 , Hans W Borchers wrote: > > > I have often seen the use of routines from the ACM Collected Algorithms, > > i.e. > Open Source programs, maybe also in some R packages --- and sometimes > > these programs

[R] ACM Software Copyright and License Agreement

2012-02-16 Thread Hans W Borchers
ACM Software Copyright and License Agreement I have often seen the use of routines from the ACM Collected Algorithms, i.e. (CALGO, or Trans. On Math. Software, TOMS), in Open Source programs, maybe also in some R packages --- and sometimes these programs are distributed under the GPL license, som

Re: [R] Schwefel Function Optimization

2012-02-11 Thread Hans W Borchers
Vartanian, Ara indiana.edu> writes: > All, > > I am looking for an optimization library that does well on something as > chaotic as the Schwefel function: > > schwefel <- function(x) sum(-x * sin(sqrt(abs(x > > With these guys, not much luck: > > > optim(c(1,1), schwefel)$value > [1] -7.

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-28 Thread Hans W Borchers
R. Michael Weylandt gmail.com> writes: > > I'd write your own diff() that eliminates the method dispatch and > argument checking that diff -> diff.default does. > > x[-1] - x[-len(x)] # is all you really need. > (# you could also try something like c(x[-1], NA) - x which may be > marginally fast

Re: [R] k-means++

2012-01-09 Thread Hans W Borchers
Ferebee Tunno mathstat.astate.edu> writes: > Hi everyone - > > I know that R is capable of clustering using the k-means algorithm, but can > R do k-means++ clustering as well? k-means++ is a routine to suggest center points before the classical k-means is called. The following lines of code wi

Re: [R] Base function for flipping matrices

2011-12-31 Thread Hans W Borchers
Hadley Wickham rice.edu> writes: > See functions flipud(), fliplr() in package 'matlab' (or 'pracma'). Those are the names of corresponding functions in MATLAB. Hans Werner > Hi all, > > Are there base functions that do the equivalent of this? > > fliptb <- function(x) x[nrow(x):1, ] > fli

Re: [R] Union/Intersect two continuous sets

2011-12-22 Thread Hans W Borchers
谢一鸣 gmail.com> writes: > Dear All, > > It is my first time using this mail list to post a question. And I > sincerely hope that this will not bother any subscribers. > So far as I know, there are functions like union( ), which can help to > combine two sets of discrete data. But what if the data

Re: [R] nls start values

2011-12-13 Thread Hans W Borchers
Niklaus Fankhauser cell.biol.ethz.ch> writes: > I'm using nls to fit periodic gene-expression data to sine waves. I need > to set the upper and lower boundaries, because I do not want any > negative phase and amplitude solutions. This means that I have to use > the "port" algorithm. The problem i

Re: [R] axis tick colors: only one value allowed?

2011-12-13 Thread Hans W Borchers
Carl Witthoft witthoft.com> writes: > > Hi, > So far as I can tell, the 'col.ticks' parameter for axis() only uses the > first value provided. E.g.: > > plot(0:1,0:1, col.ticks=c('blue','red','green')) #all ticks are blue > > Just wondering if there's a different option in the basic plot

Re: [R] efficiently finding the integrals of a sequence of functions

2011-12-10 Thread Hans W Borchers
JeffND nd.edu> writes: > > Hi folks, > > I am having a question about efficiently finding the integrals of a list of > functions. We had the same discussion last month under the heading "performance of adaptIntegrate vs. integrate", see https://stat.ethz.ch/pipermail/r-help/2011-November

Re: [R] Intersection of 2 matrices

2011-12-02 Thread Hans W Borchers
Michael Kao gmail.com> writes: > Well, taking a second look, I'd say it depends on the exact formulation. In the applications I have in mind, I would like to count each occurrence in B only once. Perhaps the OP never thought about duplicates in B Hans Werner > > Here is an example based on t

Re: [R] Intersection of 2 matrices

2011-12-02 Thread Hans W Borchers
Michael Kao gmail.com> writes: > Your solution is fast, but not completely correct, because you are also counting possible duplicates within the second matrix. The 'refitted' function could look as follows: compMat2 <- function(A, B) { # rows of B present in A B0 <- B[!duplicated(

Re: [R] x, y for point of intersection

2011-12-01 Thread Hans W Borchers
Monica has sent me some data and code for taking a quick look. As it turned out, there was a simple programming error on her side. The segm_distance() function in package 'pracma' is working correctly. And there is no minimization procedure in here, it simply solves some equations from plane geomet

Re: [R] x, y for point of intersection

2011-11-23 Thread Hans W Borchers
Monica Pisica hotmail.com> writes: > Hi everyone, > > I am trying to get a point of intersection between a > polyline and a straight line ….. and get the x and y coordinates of this > point. > For exemplification consider this: > set.seed(123) k1 <-rnorm(100, mean=1.77, sd=3.33) k1

Re: [R] optim seems to be finding a local minimum

2011-11-11 Thread Hans W Borchers
Ben Bolker gmail.com> writes: > > Simulated annealing and other stochastic global optimization > methods are also possible solutions, although they may or may not > work better than the many-starting-points solution -- it depends > on the problem, and pretty much everything has to be tuned.

Re: [R] performance of adaptIntegrate vs. integrate

2011-11-11 Thread Hans W Borchers
baptiste auguie googlemail.com> writes: > > 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 I

Re: [R] Linear programming problem, RGPLK - "no feasible solution".

2011-10-10 Thread Hans W Borchers
Liu Evans, Gareth liverpool.ac.uk> writes: > In my post at https://stat.ethz.ch/pipermail/r-help/2011-October/292019.html > I included an undefined term "ej". The problem code should be as follows. > It seems like a simple linear programming problem, but for some reason my > code is not finding

Re: [R] Binary optimization problem in R

2011-09-21 Thread Hans W Borchers
Michael Haenlein escpeurope.eu> writes: > Dear all, > > I would like to solve a problem similar to a multiple knapsack problem and > am looking for a function in R that can help me. > > Specifically, my situation is as follows: I have a list of n items which I > would like to allocate to m grou

Re: [R] fitting a sinus curve

2011-07-29 Thread Hans W Borchers
David Winsemius comcast.net> writes: > > > On Jul 28, 2011, at 1:07 PM, Hans W Borchers wrote: > > > maaariiianne ec.europa.eu> writes: > > > >> Dear R community! > >> I am new to R and would be very grateful for any kind of help. I am >

Re: [R] fitting a sinus curve

2011-07-28 Thread Hans W Borchers
maaariiianne ec.europa.eu> writes: > Dear R community! > I am new to R and would be very grateful for any kind of help. I am a PhD > student and need to fit a model to an electricity load profile of a > household (curve with two peaks). I was thinking of looking if a polynomial > of 4th order,

Re: [R] interpolation and extremum location of a surface‏

2011-06-01 Thread Hans W Borchers
Clement LAUZIN hotmail.com> writes: > Hello, > > Hello, > > I have a x,y,z file.Z is not corresponding to a simple analytical function > of x and y (see below). I am trying to find the minimum location of this > surface and the z value corresponding to this location by a spline > interpolation

Re: [R] matrix of higher order differences

2011-04-27 Thread Hans W Borchers
Jeroen Ooms gmail.com> writes: > > Is there an easy way to turn a vector of length n into an n by n matrix, in > which the diagonal equals the vector, the first off diagonal equals the > first order differences, the second... etc. I.e. to do this more > efficiently: > > diffmatrix <- function(x

Re: [R] How do I modify uniroot function to return .0001 if error ?

2011-04-03 Thread Hans W Borchers
eric aol.com> writes: > > I am calling the uniroot function from inside another function using these > lines (last two lines of the function) : > > d <- uniroot(k, c(.001, 250), tol=.05) > return(d$root) > > The problem is that on occasion there's a problem with the values I'm > passing to uni

Re: [R] question about calculating derivatives for vectors

2011-03-29 Thread Hans W Borchers
Mingwei Min cam.ac.uk> writes: > > Hi all, > > I am trying to calculating derivatives for vectors using R. I have a > numerical vector, which is in time series manner and contains "NA"s. I > want to know the changing rate throughout the whole time range. I am > wondering if there is function in

Re: [R] linear constrained optimization in R

2011-03-26 Thread Hans W Borchers
sammyny caa.columbia.edu> writes: > > I am trying to use > http://rss.acs.unt.edu/Rdoc/library/stats/html/constrOptim.html in R to do > optimization in R with some given linear constraints but not able to figure > out how to set up the problem. > > For example, I need to maximize $f(x,y) = log(x

Re: [R] minimum distance between line segments

2011-03-09 Thread Hans W Borchers
Darcy Webber gmail.com> writes: > Dear R helpers, > > I think that this may be a bit of a math question as the more I > consider it, the harder it seems. I am trying to come up with a way to > work out the minimum distance between line segments. For instance, > consider 20 random line segments:

Re: [R] Finding pairs with least magnitude difference from mean

2011-02-28 Thread Hans W Borchers
syngenta.com> writes: > James, > It seems the 2*mean(x) term is irrelevant if you are seeking to > minimize sd. Then you want to sort the distances from smallest to > largest. Then it seems clear that your five values will be adjacent in > the list, since if you have a set of five adjacent value

Re: [R] Using uniroot() with output from deriv() or D()

2011-02-26 Thread Hans W Borchers
> I need to find the root of the second derivative of many curves and do not > want to cut and paste the expression results from the deriv() or D() > functions every time. Below is an example. What I need to do is refer to > "fn2nd" in the uniroot() function, but when I try something like > uniro

Re: [R] Finding pairs with least magnitude difference from mean

2011-02-26 Thread Hans W Borchers
> I have what I think is some kind of linear programming question. > Basically, what I want to figure out is if I have a vector of numbers, > > > x <- rnorm(10) > > x > [1] -0.44305959 -0.26707077 0.07121266 0.44123714 -1.10323616 > -0.19712807 0.20679494 -0.98629992 0.97191659 -0.77561593 >

Re: [R] Regarding Savitzky-Golay Smoothing Filter

2011-02-22 Thread Hans W Borchers
reynolds pravindev gmail.com> writes: > Hi > When we use the sav_gol command in R , it shows an error which says: " > error in as.matrix". We've downloaded the necessary packages. Kindly > help us with this issue. If there is any other function to perform > Savitzky-Golay smoothing in R, please l

Re: [R] Rubin's rules of multiple imputation

2011-01-31 Thread Hans W Borchers
Joe P King joepking.com> writes: > Hello all, if I have multiple imputed data sets, is there a command or > function in R in any package you know of to combine those, I know one common > MI approach is rubins rules, is there a way to do this using his rules or > others? I know theres ways, like u

Re: [R] optim function multi variables -newbie

2011-01-28 Thread Hans W Borchers
michalseneca gmail.com> writes: > I tried to modify the code,thanks for noticing... > now i get that the function cannot be evaluated at initial parameters. > However I do not know what does that mean.. > Should I try to modify parameters. I am still not sure of syntax of > function. I cannot get

Re: [R] optim function multi variables -newbie

2011-01-27 Thread Hans W Borchers
michalseneca gmail.com> writes: > Hi, > Basically what I am trying is to rewrite matlab code into R ...This is code > for famous SABR model Calibration. > I did most of the code up to optimalization issue. > In the attachment you can find matlab and my unfinished R code..This is very > helpful co

Re: [R] Hilbert Huang Transformation

2011-01-27 Thread Hans W Borchers
Jumlong Vongprasert gmail.com> writes: > Dear All > I try to use Hilbert Huang Transformation in R. > How I can do. > Many Thanks. > The Hilbert-Huang transformation is a combination of "empirical mode decomposition" (EMD) and "Hilbert Spectral Analysis". For both see the package 'E

Re: [R] Integration of two lines

2011-01-25 Thread Hans W Borchers
Xavier Robin unige.ch> writes: > Hello, > > I need to integrate the absolute difference between two lines measured > on different points. > > # For example : > x <- seq(0, 1, 1/100) > f_x <- runif(101) + x > y <- seq(0, 1, 1/23) > f_y <- runif(24) + (1 - y) > > plot(x, f_x, type="l") > lines(y

Re: [R] Help on a Display function

2011-01-15 Thread Hans W Borchers
William Dunlap tibco.com> writes: > > But it fails on this: > > my_names <- c("Bill", "William") > > display(rev(my_names)) > rev(my_names) = Error in cat(list(...), file, sep, fill, labels, > append) : > argument 3 (type 'list') cannot be handled by 'cat' > This is because you call ev

[R] Help on a Display function

2011-01-14 Thread Hans W Borchers
> I wanted to simulate the Matlab DISPLAY function for some time now. After seeing a recent proposal by Gabor Grothendieck I came up with the following solution, display <- function(...) { my_names <- lapply(substitute(placeholderFunction(...))[-1], deparse) for (my in my_names) cat(my, "=",

Re: [R] Integrate and subdivisions limit

2011-01-12 Thread Hans W Borchers
> Dear all, > I have some issues with integrate in R thus I would like to request > your help. I am trying to calculate the integral of f(x)*g(x). > The f(x) is a step function while g(x) is a polynomial. > If f(x) (step function) changes its value only few times (5 or 6 'steps') > everything is ca

Re: [R] How to formulate constraint like abs(x) = y i n constrOptim (or other)

2010-12-06 Thread Hans W Borchers
Benjamin B. googlemail.com> writes: > Hello list reader, > > I am trying to form some constraints for an optimization I am working on. > I think I have understand the use of the constraints in matrix form. I use > them like: > > [...] > > Now I would like to formulate a constraint like > > Su

Re: [R] Optimize multiple variable sets

2010-12-06 Thread Hans W Borchers
peter dalgaard gmail.com> writes: > > On Dec 6, 2010, at 15:15 , Jonathan P Daily wrote: > > > Correct me if I'm wrong, but isn't the minimal x value in your example > > the same regardless of what positive coefficient you apply to x? If that > > is the case, you would expect the same min(x) for

Re: [R] Quadratic programming with semi-definite matrix

2010-12-06 Thread Hans W Borchers
Andreas Jensen gmail.com> writes: > Hello. > > I'm trying to solve a quadratic programming problem of the form min > ||Hx - y||^2 s.t. x >= 0 and x <= t using solve.QP in the quadprog > package but I'm having problems with Dmat not being positive definite, > which is kinda okay since I expect it

Re: [R] Integral of PDF

2010-12-03 Thread Hans W Borchers
That does not remedy the situation in any case, take the following function fun <- function(x) dnorm(x, -500, 50) + dnorm(x, 500, 50) that has a 'mode' of 0 again. Interestingly, if I transform it by 1/x, to integrate I again have to reduce the error tolerance to at least 1e-10:

Re: [R] Integral of PDF

2010-12-02 Thread Hans W Borchers
You can dive into the thread "puzzle with integrate over infinite range" from September this year. The short answer appears to be: Increase the error tolerance. integrate(function(x) dnorm(x, 500,50), -Inf, Inf, subdivisions=500, rel.tol=1e-11) # 1 with absolute error < 1.1e

Re: [R] question about constraint minimization

2010-11-23 Thread Hans W Borchers
dhacademic gmail.com gmail.com> writes: > Hi, > > I have struggled on this "bound optimization with equality constraint" by > using optim function for two days, but still fail to prepare a good input. > Can anyone help to prepare the input for my specific case? Many thanks. > > Best, > Hao Yo

Re: [R] question about constraint minimization

2010-11-20 Thread Hans W Borchers
dhacademic gmail.com gmail.com> writes: > > > Hi, > > I am a beginner of R. There is a question about constraint minimization. A > function, y=f(x1,x2,x3x12), needs to be minimized. There are 3 > requirements for the minimization: > > (1) x2+x3+...+x12=1.5 (x1 is excluded); > (2) x1=x3

  1   2   3   >