Re: [R] optimization problem

2015-10-19 Thread Hector Villalobos
Thanks to all who responded, I've found a very useful code here: http://courses.washington.edu/fish507/notes.html In particular the Lecture 3... Héctor 2015-10-17 7:05 GMT+00:00 Berend Hasselman : > > Your model is producing -Inf entries in the vector Be (in function modl >

Re: [R] optimization problem

2015-10-17 Thread Berend Hasselman
Your model is producing -Inf entries in the vector Be (in function modl and LL) at some stage during the optimization process. You should first do something about that before anything else. Berend > On 17 Oct 2015, at 03:01, Bert Gunter wrote: > > I made no attempt

[R] optimization problem

2015-10-16 Thread Hector Villalobos
Dear R users, I'im trying to find the parameters of a dynamic biomass model using maximum likelihood estimation. I used two approaches, one by hand, with optim() function and the other using mle2() function from package bbmle. My problem is that the results change a lot depending on the initial

Re: [R] optimization problem

2015-10-16 Thread Bert Gunter
I made no attempt to examine your details for problems, but in general, My problem > is that the results change a lot depending on the initial values... I can't > see what I am doing wrong... > > This is a symptom of an overparameterized model: The parameter estimates > are unstable even though

Re: [R] Optimization problem

2013-04-11 Thread Rui Barradas
Hello, You cannot change the numerical accuracy, it's a built-in constant. To see it use ?.Machine .Machine$double.eps # smallest value different from zero Actually, .Machine$double.eps is the the smallest positive floating-point number x such that 1 + x != 1 You can try the following

[R] Optimization problem

2013-04-10 Thread nntx
As a simple example, I want to find minimum value for x^2, but it can't be obtained by: f-function(x)x^2 optimize(f,lower=-1,upper=1) What are other methods to deal with this? I tried DEoptim, still doesn't work. Any suggustions will be extremely helpful! THanks! Shelly -- View this message

Re: [R] Optimization problem

2013-04-10 Thread peter dalgaard
On Apr 10, 2013, at 03:24 , nntx wrote: As a simple example, I want to find minimum value for x^2, but it can't be obtained by: f-function(x)x^2 optimize(f,lower=-1,upper=1) Works fine for me. What did you expect it to do? f-function(x)x^2 optimize(f,lower=-1,upper=1) $minimum [1]

Re: [R] Optimization problem

2013-04-10 Thread nntx
Thank you professor. I think the minimum value of x^2 between -1 and 1 should be x=0, y=0. but the result is not that. I am thinking is any wrong with my thought? Thanks for helping me out! -- View this message in context:

Re: [R] Optimization problem

2013-04-10 Thread Rui Barradas
Hello, Your thoght is mathematically right but numerically wrong. The result given by optimize is so close to the real minimum that numerical accuracy comes in and it becomes indistinguishable from the value you're expecting. You get the minimum up to a certain accuracy, not more. Hope this

Re: [R] Optimization problem

2013-04-10 Thread nntx
Rui, thanks for your reply. You meant that it is the issue of accuracy? So if I change the numerical accuracy, my results can be output? Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Optimization-problem-tp4663821p4663928.html Sent from the R help mailing list

[R] Optimization Problem in R

2013-02-09 Thread Axel Urbiz
Dear List, I'm new in R. I'm trying to solve a simple constrained optimization problem. Essentially, let's say I have a matrix as in the object 'mm' inside the function below. My objective function should have a matrix of parameters, one parameter for each element 'mm' (4 in this case). The

Re: [R] Optimization Problem in R

2013-02-09 Thread Berend Hasselman
On 09-02-2013, at 21:08, Axel Urbiz axel.ur...@gmail.com wrote: Dear List, I'm new in R. I'm trying to solve a simple constrained optimization problem. Essentially, let's say I have a matrix as in the object 'mm' inside the function below. My objective function should have a matrix of

Re: [R] Optimization problem

2012-05-17 Thread Pacin Al
Hi Greg, The problem is that I also have restrictions for each variable (they must be higher than -.07 and smaller than .2) and I'm dealing with a lot of them. I've already tried the second approach but, as far as it seems, the function doesn't satisfy my objective. That's what I'm doing:

[R] Optimization problem

2012-05-16 Thread Pacin Al
Hi, I'm dealing with an optimization problem. I'm using 'optim' to maximize the output of a function, given some restrictions on the input. I would like to know if there is a way to impose some restrictions on 'intermediate variables' of the function. An example.. fx = function (x) { s - 0 for

Re: [R] Optimization problem

2012-05-16 Thread Greg Snow
There are a couple of options. First if you want the mean to equal 7, then that means the sum must equal 21 and therefore you can let optim only play with 2 of the variables, then set the 3rd to be 21-s1-s2. If you want the mean to be greater than 7 then just put in a test, if the mean is less

Re: [R] Optimization problem with nonlinear constraint

2010-07-28 Thread Uli Kleinwechter
] Optimization problem with nonlinear constraint Dear all, I'm looking for a way to solve a simple optimization problem with a nonlinear constraint. An example would be max x s.t. y = x * T ^(x-1) where y and T are known values. optim() and constrOptim() do only allow for box or linear constraints

Re: [R] Optimization problem with nonlinear constraint

2010-07-28 Thread Hans W Borchers
Uli Kleinwechter u.kleinwechter at uni-hohenheim.de writes: Dear Ravi, As I've already written to you, the problem indeed is to find a solution to the transcendental equation y = x * T^(x-1), given y and T and the optimization problem below only a workaround. I don't think

Re: [R] Optimization problem with nonlinear constraint

2010-07-28 Thread Ravi Varadhan
-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Hans W Borchers Sent: Wednesday, July 28, 2010 11:11 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Optimization problem with nonlinear constraint Uli Kleinwechter u.kleinwechter at uni-hohenheim.de writes: Dear Ravi

Re: [R] Optimization problem with nonlinear constraint

2010-07-28 Thread Ravi Varadhan
Sent: Wednesday, July 28, 2010 11:11 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Optimization problem with nonlinear constraint Uli Kleinwechter u.kleinwechter at uni-hohenheim.de writes: Dear Ravi, As I've already written to you, the problem indeed is to find a solution

[R] Optimization problem with nonlinear constraint

2010-07-26 Thread Uli Kleinwechter
Dear all, I'm looking for a way to solve a simple optimization problem with a nonlinear constraint. An example would be max x s.t. y = x * T ^(x-1) where y and T are known values. optim() and constrOptim() do only allow for box or linear constraints, so I did not succedd here. I

Re: [R] Optimization problem with nonlinear constraint

2010-07-26 Thread Ravi Varadhan
into any problems using it. Best, Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Uli Kleinwechter Sent: Monday, July 26, 2010 10:16 AM To: r-help@r-project.org Subject: [R] Optimization problem with nonlinear constraint

Re: [R] Optimization problem

2010-06-18 Thread José E. Lozano
How about smoothing the percentages, and then take the second derrivative to find the inflection point? which.max(diff(diff((lowess(percentages)$y This solution is what I've been using so far. The only difference is that I am smoothing the 1st derivative, since its the one I want to be

Re: [R] Optimization problem

2010-06-18 Thread José E. Lozano
Hello: Here is a general approach using smoothing using the Gasser-Mueller kernel, which is implemented in the lokern package. The optimal bandwidth for derivative estimation is automatically chosen using a plug-in approximation. The code and the results are attached here. Maybe am I

Re: [R] Optimization problem

2010-06-18 Thread José E. Lozano
How about smoothing the percentages, and then take the second derrivative to find the inflection point? which.max(diff(diff((lowess(percentages)$y This solution is what I've been using so far. The only difference is that I am smoothing the 1st derivative, since its the one I want to

Re: [R] Optimization problem

2010-06-18 Thread William Simpson
I don't see why one would want to pretend that the function is continuous. It isn't. The x variable devices is discrete. Moreover, the whole solution space is small: the possible solutions are integers in the range of maybe 20-30. Bill On Fri, Jun 18, 2010 at 9:00 AM, José E. Lozano

Re: [R] Optimization problem

2010-06-18 Thread José E. Lozano
I don't see why one would want to pretend that the function is continuous. It isn't. The x variable devices is discrete. Moreover, the whole solution space is small: the possible solutions are integers in the range of maybe 20-30. Yes, you are right, what I'd like to think is that the outcome

[R] Optimization problem

2010-06-17 Thread José E. Lozano
Hello, I'm facing a problem of optimization, I've already solved but I'm trying to find other answers to this problem to improve the solution. Well, to make it short: I have to set/install a number of devices in a building, and I have to give service to a number of customers, or better say, to

Re: [R] Optimization problem

2010-06-17 Thread Bart Joosen
How about smoothing the percentages, and then take the second derrivative to find the inflection point? which.max(diff(diff((lowess(percentages)$y Bart -- View this message in context: http://r.789695.n4.nabble.com/Optimization-problem-tp2258654p2258828.html Sent from the R help mailing

Re: [R] Optimization problem

2010-06-17 Thread William Simpson
min(devices[percentages==max(percentages)]) Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal,

Re: [R] Optimization problem

2010-06-17 Thread Ravi Varadhan
questions. Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of José E. Lozano Sent: Thursday, June 17, 2010 7:48 AM To: r-help@r-project.org Subject: [R] Optimization problem Hello, I'm facing a problem of optimization, I've

[R] Optimization problem

2010-06-17 Thread William Simpson
Sorry, thought you wanted to find lowest value of x that produced maximum value of y. I see now that is not the case. I think you have to decide on what amount of improvement per device you judge to be 'minimal'. Then the algorithm uses the value of y that occurs at the point where this criterion

[R] optimization problem with linear constraints

2010-02-14 Thread Kathie
Dear R users, I need some advises on how to use R to optimize this function with the following constraints. f(x1,x2,x3,y1,y2,y3,) = gamma(x1+x2-1)/{gamma(x1)*gamma(x2)} * y1^(x2-1) * y2^(x1-1) + gamma(x1+x3-1)/{gamma(x1)*gamma(x3)} * y1^(x3-1) * y3^(x1-1) +

Re: [R] optimization problem

2010-01-17 Thread Hans W. Borchers
Ravi Varadhan rvaradhan at jhmi.edu writes: Interesting! Now, if I change the cost matrix, D, in the LSAP formulation slightly such that it is quadratic, it finds the best solution to your example: Dear Ravi, I thought your solution is ingenious, but after the discussion with Erwin

Re: [R] optimization problem

2010-01-17 Thread klausch
? Thank a lot again! Klaus Original-Nachricht Datum: Sat, 16 Jan 2010 23:42:08 -0500 Von: Ravi Varadhan rvarad...@jhmi.edu An: Erwin Kalvelagen erwin.kalvela...@gmail.com CC: r-h...@stat.math.ethz.ch Betreff: Re: [R] optimization problem Interesting! Now, if I change

Re: [R] optimization problem

2010-01-17 Thread Ravi Varadhan
of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Hans W. Borchers hwborch...@googlemail.com Date: Sunday, January 17, 2010 3:54 am Subject: Re: [R] optimization problem To: r-h...@stat.math.ethz.ch Ravi Varadhan rvaradhan

Re: [R] optimization problem

2010-01-17 Thread Ravi Varadhan
: Sunday, January 17, 2010 8:06 am Subject: Re: [R] optimization problem To: Ravi Varadhan rvarad...@jhmi.edu, erwin.kalvela...@gmail.com, hwborch...@googlemail.com Cc: r-h...@stat.math.ethz.ch Dear Erwin, Ravi and Hans Werner, thanks a lot for your replies. I don't think I have access

Re: [R] optimization problem

2010-01-17 Thread Erwin Kalvelagen
Message - From: Erwin Kalvelagen erwin.kalvela...@gmail.com Date: Saturday, January 16, 2010 5:26 pm Subject: Re: [R] optimization problem To: Ravi Varadhan rvarad...@jhmi.edu Cc: r-h...@stat.math.ethz.ch I believe this is a very good approximation but not a 100% correct formulation

Re: [R] optimization problem

2010-01-17 Thread Hans W. Borchers
Ravi Varadhan rvaradhan at jhmi.edu writes: Dear Hans, I agree with your comments. My intuition was that the quadratic form would be better behaved than the radical form (less nonlinear!?). So, I was hoping to see a change in behavior when the cost function was altered from a radical

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
: Saturday, January 16, 2010 2:35 am Subject: Re: [R] optimization problem To: r-h...@stat.math.ethz.ch Ravi Varadhan rvaradhan at jhmi.edu writes: dist - function(A, B) { # Frobenius norm of A - B n - nrow(A) sum(abs(B - A)) } See for a definition of the Frobenius

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Ravi Varadhan rvarad...@jhmi.edu Date: Saturday, January 16, 2010 10:00 am Subject: Re: [R] optimization problem To: Erwin Kalvelagen erwin.kalvela...@gmail.com Cc: r-h...@stat.math.ethz.ch Thanks, Erwin, for pointing out

Re: [R] optimization problem

2010-01-16 Thread Erwin Kalvelagen
and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Erwin Kalvelagen erwin.kalvela...@gmail.com Date: Saturday, January 16, 2010 2:35 am Subject: Re: [R] optimization problem To: r-h...@stat.math.ethz.ch Ravi

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Erwin Kalvelagen erwin.kalvela...@gmail.com Date: Saturday, January 16, 2010 1:36 pm Subject: Re: [R] optimization problem To: Ravi Varadhan rvarad...@jhmi.edu Cc: r-h

Re: [R] optimization problem

2010-01-16 Thread Erwin Kalvelagen
-2619 email: rvarad...@jhmi.edu - Original Message - From: Erwin Kalvelagen erwin.kalvela...@gmail.com Date: Saturday, January 16, 2010 1:36 pm Subject: Re: [R] optimization problem To: Ravi Varadhan rvarad...@jhmi.edu Cc: r-h...@stat.math.ethz.ch I also have doubts this can

Re: [R] optimization problem

2010-01-16 Thread Ravi Varadhan
...@gmail.com Date: Saturday, January 16, 2010 5:26 pm Subject: Re: [R] optimization problem To: Ravi Varadhan rvarad...@jhmi.edu Cc: r-h...@stat.math.ethz.ch I believe this is a very good approximation but not a 100% correct formulation of the original problem. E.g. for A - matrix(c

[R] optimization problem

2010-01-15 Thread klausch
Dear R-experts, this is not a direct R-problem but I hope you can help me anyway. I would like to minimize || PG-I || over P, where P is a p x p permutation matrix (obtained by permuting the rows and/or columns of the identity matrix), G is a given p x p matrix with full rank and I the

Re: [R] optimization problem

2010-01-15 Thread Erwin Kalvelagen
klausch at gmx.de writes: Dear R-experts, this is not a direct R-problem but I hope you can help me anyway. I would like to minimize || PG-I || over P, where P is a p x p permutation matrix (obtained by permuting the rows and/or columns of the identity matrix), G is a given p x p

Re: [R] optimization problem

2010-01-15 Thread Ravi Varadhan
of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: klau...@gmx.de Date: Friday, January 15, 2010 9:53 am Subject: [R] optimization problem To: r-help@r-project.org Dear R-experts

Re: [R] optimization problem

2010-01-15 Thread Erwin Kalvelagen
Ravi Varadhan rvaradhan at jhmi.edu writes: dist - function(A, B) { # Frobenius norm of A - B n - nrow(A) sum(abs(B - A)) } See http://mathworld.wolfram.com/FrobeniusNorm.html for a definition of the Frobenius norm. Erwin

[R] optimization problem with constraints..

2009-10-18 Thread Prof. John C Nash
Date: Sat, 17 Oct 2009 13:50:10 -0700 (PDT) From: kathie kathryn.lord2...@gmail.com Subject: [R] optimization problem with constraints... To: r-help@r-project.org Message-ID: 25941686.p...@talk.nabble.com Content-Type: text/plain; charset=us-ascii Dear R users, I need some advises on how

[R] optimization problem with constraints...

2009-10-17 Thread kathie
Dear R users, I need some advises on how to use R to optimize a nonlinear function with the following constraints. f(x1,x2,x3,x4,x5,x6) s.t 0 x1 1 0 x2 1 0 x1+x2 1 -inf x3 inf -inf x4 inf 0 x5 inf 0 x6 inf Is there any built-in function or something for these constraint??

Re: [R] optimization problem

2008-12-02 Thread Mike Prager
Hans W. Borchers [EMAIL PROTECTED] wrote: Why not use one of the global optimizers in R, for instance 'DEoptim', and then apply optim() to find the last six decimals? I am relatively sure that the Differential Evolution operator has a better chance to come near a global optimum than a loop

Re: [R] optimization problem (optim vs. nlminb)

2008-12-02 Thread Mike Prager
In case anyone is still reading this thread, I want to add this: In a current problem (a data-shy five-parameter nonlinear optimization), I found nlminb markedly more reliable than optim with method L-BFGS-B. In reviewing the fit I made, I found that optim only came close to its own minimum in

Re: [R] optimization problem

2008-12-01 Thread Mike Prager
tedzzx [EMAIL PROTECTED] wrote: If I want to find out the globle minia, how shoul I change my code? I sometimes use optim() within a loop, with random starting values for each iteration of the loop. You can save the objective function value each time and pick the best solution. Last time I

Re: [R] optimization problem

2008-12-01 Thread Hans W. Borchers
Why not use one of the global optimizers in R, for instance 'DEoptim', and then apply optim() to find the last six decimals? I am relatively sure that the Differential Evolution operator has a better chance to come near a global optimum than a loop over optim(), though 'DEoptim' may be a bit slow

Re: [R] optimization problem

2008-11-29 Thread Ben Bolker
tedzzx zengzhenxing at gmail.com writes: Hi, all I am facing an optimization problem. I am using the function optim(par,fun), but I find that every time I give different original guess parameter, I can get different result. For example I have a data frame named data: head(data)

[R] optimization problem

2008-11-28 Thread tedzzx
Hi, all I am facing an optimization problem. I am using the function optim(par,fun), but I find that every time I give different original guess parameter, I can get different result. For example I have a data frame named data: head(data) price s x t 1 1678.0 12817 11200

Re: [R] optimization problem

2008-11-28 Thread axionator
Hi, I guess your function has several local minima and depending on where you start, i.e. your initial variables, you get into another mimimum. HTH Armin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] optimization problem

2008-11-28 Thread John C Nash
] optimization problem To: r-help@r-project.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=UTF-8 I am facing an optimization problem. I am using the function optim(par,fun), but I find that every time I give different original guess parameter, I can get different result

Re: [R] optimization problem

2008-11-28 Thread tedzzx
If I want to find out the globle minia, how shoul I change my code? Thanks a lot Armin Meier wrote: Hi, I guess your function has several local minima and depending on where you start, i.e. your initial variables, you get into another mimimum. HTH Armin

[R] optimization problem

2008-11-24 Thread Jiang Peng
Dear list, hi ! I am a R beginner and I have a function to optimize . alpha = argmin{ f(x,alpha) } I want alpha to be in [0,1]. Is there any function that can work? I use nlm() but i can't fix the domain of alpha. thanks in advance ___ Jiang Peng, Ph.D.

Re: [R] optimization problem

2008-11-24 Thread Jagat.K.Sheth
, 2008 5:28 AM To: r-help@r-project.org Subject: [R] optimization problem Dear list, hi ! I am a R beginner and I have a function to optimize . alpha = argmin{ f(x,alpha) } I want alpha to be in [0,1]. Is there any function that can work? I use nlm() but i can't fix the domain

Re: [R] optimization problem

2008-11-24 Thread Ravi Varadhan
/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jiang Peng Sent: Monday, November 24, 2008 6:28 AM To: r-help@r-project.org Subject: [R] optimization problem

[R] Optimization problem with constraints

2008-06-02 Thread Matthias Graser
I'm trying to da an optimization for the followig function Zwischenwert - function (x) { lambda-x[1]; mu-x[2]; gammal-x[3]; mud-x[4]; gammad-x[5]; Mittelwert -0; for(t in 0:(T-1)) { for(i in 0:(n-1)) {

[R] Optimization problem, to minimize the length(rle(B)$lengths) for all the rows and columns

2008-05-12 Thread Ng Stanley
Hi, how can I order the rows and columns of a matrix A to generate B, in order to minimize the length(rle(B)$lengths) for all the rows and columns ? set.seed(5) a - matrix(rnorm(200), nrow=20) a[a=0] - 0 a[a0] - 1 a [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]01