[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

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 of

[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

[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 >

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

2019-12-15 Thread Hans W Borchers
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 the developm

[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

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

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. > > M

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 <-

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 have a small >

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

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,

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()

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 functionality

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

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 to

Re: [R] integrate with vector arguments

2015-02-26 Thread Hans W Borchers
marKo mtoncic at 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, but

Re: [R] Nonlinear integer programming (again)

2015-02-16 Thread Hans W Borchers
Zwick, Rebecca J RZwick at 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

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

Re: [R] Double Infinite Integration

2013-12-06 Thread Hans W Borchers
Aya Anas aanas at 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

Re: [R] Graphing complex functions

2013-10-22 Thread Hans W Borchers
John Van Praag john at 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 __

Re: [R] MCP solver

2013-10-13 Thread Hans W Borchers
Maxwell, John McFarland jmmaxwell at 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

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

2013-07-27 Thread Hans W Borchers
Tiago V. Pereira tiago.pereira at 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 y2y10. I am trying the following approach # first attempt library(cubature) fun - function(x) {

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

2013-06-05 Thread Hans W Borchers
David Winsemius dwinsemius at 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) # -6 + 11*x - 6*x^2 + x^3 p0 - polynomial

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

2013-06-04 Thread Hans W Borchers
Bert Gunter gunter.berton at 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

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

2013-04-02 Thread Hans W Borchers
Bert Gunter gunter.berton at 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

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

2013-03-12 Thread Hans W Borchers
Pavel_K kuk064 at 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] Using lm to estimate a parameter?

2013-02-19 Thread Hans W Borchers
Uwe Ligges ligges at 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

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

2013-02-19 Thread Hans W Borchers
Jeff Newmiller jdnewmil at 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

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 separate

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 are

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

2012-07-18 Thread Hans W Borchers
Cren oscar.soppelsa at 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

Re: [R] identifying local maxima

2012-07-12 Thread Hans W Borchers
Gary Dong pdxgary163 at 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.

Re: [R] numerical integration

2012-05-23 Thread Hans W Borchers
Michael Meyer mjhmeyer at 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) {

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

2012-05-22 Thread Hans W Borchers
Rehena Sultana hena_4567 at 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.

Re: [R] Runs up and runs down test

2012-05-19 Thread Hans W Borchers
JWDougherty jwd at 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. Davis

Re: [R] Optimization inconsistencies

2012-05-18 Thread Hans W Borchers
peter dalgaard pdalgd at 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 high

Re: [R] Optimization inconsistencies

2012-05-18 Thread Hans W Borchers
Marc Girondot marc_grt at 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

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

2012-05-06 Thread Hans W Borchers
Haio joakim.aback at 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=[];

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

2012-05-02 Thread Hans W Borchers
Ben Bolker bbolker at gmail.com writes: Ted.Harding at 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

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 -

Re: [R] R numerical integration

2012-03-26 Thread Hans W Borchers
casperyc casperyc at 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

Re: [R] R numerical integration

2012-03-24 Thread Hans W Borchers
casperyc casperyc at 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

Re: [R] R numerical integration

2012-03-24 Thread Hans W Borchers
Hans W Borchers hwborchers at googlemail.com writes: casperyc casperyc at 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

Re: [R] ACM Software Copyright and License Agreement

2012-02-17 Thread Hans W Borchers
peter dalgaard pdalgd at 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. netlib.org/toms/≥ (CALGO, or Trans. On Math. Software, TOMS), in Open Source programs, maybe also in some R packages

[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. netlib.org/toms/ (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

Re: [R] Schwefel Function Optimization

2012-02-11 Thread Hans W Borchers
Vartanian, Ara aravart at 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]

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

2012-01-28 Thread Hans W Borchers
R. Michael Weylandt michael.weylandt at 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

Re: [R] k-means++

2012-01-09 Thread Hans W Borchers
Ferebee Tunno ferebee.tunno at 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

Re: [R] Base function for flipping matrices

2011-12-31 Thread Hans W Borchers
Hadley Wickham hadley at 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, ]

Re: [R] Union/Intersect two continuous sets

2011-12-22 Thread Hans W Borchers
谢一鸣 cutexym at 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

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

2011-12-13 Thread Hans W Borchers
Carl Witthoft carl at 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] nls start values

2011-12-13 Thread Hans W Borchers
Niklaus Fankhauser niklaus.fankhauser at 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

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

2011-12-10 Thread Hans W Borchers
JeffND Zuofeng.Shang.5 at 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

Re: [R] Intersection of 2 matrices

2011-12-02 Thread Hans W Borchers
Michael Kao mkao006rmail at 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 -

Re: [R] Intersection of 2 matrices

2011-12-02 Thread Hans W Borchers
Michael Kao mkao006rmail at 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

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

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

2011-11-23 Thread Hans W Borchers
Monica Pisica pisicandru at 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)

Re: [R] performance of adaptIntegrate vs. integrate

2011-11-11 Thread Hans W Borchers
baptiste auguie baptiste.auguie at 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 -

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

2011-11-11 Thread Hans W Borchers
Ben Bolker bbolker at 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

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

2011-10-10 Thread Hans W Borchers
Liu Evans, Gareth Gareth.Liu-Evans at 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

Re: [R] Binary optimization problem in R

2011-09-21 Thread Hans W Borchers
Michael Haenlein haenlein at 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

Re: [R] fitting a sinus curve

2011-07-29 Thread Hans W Borchers
David Winsemius dwinsemius at comcast.net writes: On Jul 28, 2011, at 1:07 PM, Hans W Borchers wrote: maaariiianne marianne.zeyringer at 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

Re: [R] fitting a sinus curve

2011-07-28 Thread Hans W Borchers
maaariiianne marianne.zeyringer at 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

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

2011-06-01 Thread Hans W Borchers
Clement LAUZIN lauzin at 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 jeroenooms at 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 -

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

2011-04-03 Thread Hans W Borchers
eric ericstrom at 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

Re: [R] question about calculating derivatives for vectors

2011-03-29 Thread Hans W Borchers
Mingwei Min mm809 at 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 NAs. I want to know the changing rate throughout the whole time range. I am wondering if there is function in R

Re: [R] linear constrained optimization in R

2011-03-26 Thread Hans W Borchers
sammyny sjain at 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) =

Re: [R] minimum distance between line segments

2011-03-09 Thread Hans W Borchers
Darcy Webber darcy.webber at 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

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

2011-02-28 Thread Hans W Borchers
rex.dwyer at 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

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 mean(x)

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

Re: [R] Regarding Savitzky-Golay Smoothing Filter

2011-02-22 Thread Hans W Borchers
reynolds pravindev reynoldspravindev at 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

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

2011-01-31 Thread Hans W Borchers
Joe P King jp at 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

Re: [R] optim function multi variables -newbie

2011-01-28 Thread Hans W Borchers
michalseneca michalseneca at 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

Re: [R] Hilbert Huang Transformation

2011-01-27 Thread Hans W Borchers
Jumlong Vongprasert jumlong.ubru at 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

Re: [R] optim function multi variables -newbie

2011-01-27 Thread Hans W Borchers
michalseneca michalseneca at 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

Re: [R] Integration of two lines

2011-01-25 Thread Hans W Borchers
Xavier Robin Xavier.Robin at 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 wdunlap at 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 eval()

[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

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

2010-12-06 Thread Hans W Borchers
Andreas Jensen bentrevisor at 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

Re: [R] Optimize multiple variable sets

2010-12-06 Thread Hans W Borchers
peter dalgaard pdalgd at 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] How to formulate constraint like abs(x) = y i n constrOptim (or other)

2010-12-06 Thread Hans W Borchers
Benjamin B. benj.bad.ac at 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

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

Re: [R] question about constraint minimization

2010-11-23 Thread Hans W Borchers
dhacademic at gmail.com dhacademic at 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,

Re: [R] question about constraint minimization

2010-11-20 Thread Hans W Borchers
dhacademic at gmail.com dhacademic at 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)

Re: [R] how to find near neighbors?

2010-11-19 Thread Hans W Borchers
Czerminski, Ryszard Ryszard.Czerminski at astrazeneca.com writes: I am looking for an efficient way to find near neighbors... More specifically... I have two sets of points: A B and I want to find points in set B which are closer to set A than some cutoff (or n-closest) I will

Re: [R] Fwd: Numerical integration

2010-11-17 Thread Hans W Borchers
Eduardo de Oliveira Horta eduardo.oliveirahorta at gmail.com writes: -- Forwarded message -- From: Eduardo de Oliveira Horta eduardo.oliveirahorta at gmail.com Date: Wed, Nov 17, 2010 at 3:59 PM Subject: Re: [R] Numerical integration To: David Winsemius dwinsemius at

Re: [R] Rsolnp examples

2010-10-29 Thread Hans W Borchers
Jan Theodore Galkowski bayesianlogic at acm.org writes: I'm interested in the Rsolnp package. For their primary function solnp, one example is given, and there is a reference to unit tests. Anyone know where these can be found? Also, Rsolnp is used in a few other packages (e.g.,

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread Hans W Borchers
jonas garcia garcia.jonas80 at googlemail.com writes: Thanks for your reply, My main issue is that I don't have any equations to generate the data, just a bunch of points, each corresponding to a polygon. I was looking in package sp and there is a function to calculate areas (

Re: [R] calculate area between intersecting polygons

2010-10-26 Thread Hans W Borchers
Remko Duursma remkoduursma at gmail.com writes: Here is a different solution: library(gpclib) p1 - as(poly1, gpc.poly) p2 - as(poly2, gpc.poly) area.poly(p2) + area.poly(p1) - area.poly(union(p1,p2)) I.e., take areas of both polygons and subtract the union (check plot(union(p1,p2))

Re: [R] Hash fuctions library for R?

2010-10-14 Thread Hans W Borchers
Uwe Ziegenhagen ziegenhagen at gmail.com writes: Hi, I would like to calculate various hash sums for given string but haven't found a suitable package, yet. I found tools::md5sum which works only for files, however I would like to avoid putting my string in a file before calculating the

Re: [R] Finding Zeros of a Function

2010-10-08 Thread Hans W Borchers
Lorenzo Isella wrote: Hello, And sorry for the late reply. You see, my problem is that it is not known a priori whether I have one or two zeros of my function in the interval where I am considering it; on top of that, does BBsolve allow me to select an interval of variation of x?

Re: [R] Finding Zeros of a Function

2010-10-08 Thread Hans W Borchers
Hans W Borchers wrote: Let's see how many zeroes are there of the function sin(1/x) in the interval [0.1, 1.0]. Can you find out by plotting? In the 1-dimensional case the simplest approach is to split into subintervals small enough to contain at most one zero and search each

Re: [R] Hashing a set

2010-09-30 Thread Hans W Borchers
Lorenzo Isella lorenzo.isella at gmail.com writes: Dear All, I am given a time series such at, at every time t_i, I am given a set of data (every element of the set is just an integer number). What I need is an injective function able to map every set into a number (possibly an integer

Re: [R] constrained optimization -which package?

2010-09-29 Thread Hans W. Borchers
Leonardo Monasterio leonardo.monasterio at gmail.com writes: Dear R users, In the function bellow I want to find the maximum value of v, subject to the constrain that the sum of x is equal to 1. I want to maximize: v-t(x)%*%distance%*%x Subject to: sum(x)=1 I do not see why you

Re: [R] non-linear integer optimization?

2010-09-23 Thread Hans W Borchers
darckeen darckeen at hotmail.com writes: Are there any packages that do non-linear integer otimization? Looked at lpSolve but i'm pretty sure it only works with linear programming and not non-linear, tried L-BFGS-B optim after flooring all my params, works somewhat but seems really

  1   2   3   >