Re: [R] Optimization function producing negative parameter values

2021-03-21 Thread J C Nash
This is likely because Hessian is being approximated. Numerical approximation to Hessian will overstep the bounds because the routines that are called don't respect the bounds (they likely don't have the bounds available). Writing numerical approximations that respect bounds and other constraints

Re: [R] Optimization function producing negative parameter values

2021-03-21 Thread Bill Dunlap
Does optim go out of bounds when you specify hessian=FALSE? hessian=TRUE causes some out-of-bounds evaluations of f. > optim(c(X=1,Y=1), > function(XY){print(unname(XY));(XY[["X"]]+1)^4+(XY[["Y"]]-2)^4}, method= > "L-BFGS-B", lower=c(0.001,0.001), upper=c(1.5,1.5), hessian=TRUE) [1] 1 1 [1] 1.00

Re: [R] Optimization function producing negative parameter values

2021-03-21 Thread J C Nash
Can you put together your example as a single runnable scipt? If so, I'll try some other tools to see what is going on. There have been rumours of some glitches in the L-BFGS-B R implementation, but so far I've not been able to acquire any that I can reproduce. John Nash (maintainer of optimx pac

Re: [R] Optimization with Parallel Processing Functions/Packages

2018-11-07 Thread Jeff Newmiller
This is highly problem dependent... and you appear to already know the answer. Note that some differential evolution solution approaches may benefit from parallelizing evaluation of generations since within that sub-problem the optimization dependencies don't apply. A theoretical discussion fo

Re: [R] Optimization issue - Solution converges for any initial value

2016-09-29 Thread ProfJCNash
I haven't tried running your code, but a quick read suggests you should 1) set up the input data so your code can be run with source() without any preprocessing. 2) compute the function for several sets of parameters to make sure it is correct. Maybe create a very simple test case you can more o

Re: [R] Optimization max likelihood problem

2016-04-06 Thread ProfJCNash
At the "solution" -- which nlm seems to find OK -- you have a very nasty scaling issue. exp(z) has value > 10^300. Better transform your problem somehow to avoid that. You are taking log of this except for adding 1, so effectively have just z. But you should look at it carefully and do a number of

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 > and LL) at some s

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 to examine your details fo

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 t

Re: [R] Optimization Grid Search Slow

2015-09-18 Thread Enrico Schumann
On Thu, 17 Sep 2015, "Patzelt, Edward" writes: > R Help - > > I am trying to use a grid search for a 2 free parameter reinforcement > learning model and the grid search is incredibly slow. I've used optimx but > can't seem to get reasonable answers. Is there a way to speed up this grid > search d

Re: [R] Optimization Grid Search Slow

2015-09-17 Thread ProfJCNash
optimx does nothing to speed up optim or the other component optimizers. In fact, it does a lot of checking and extra work to improve reliability and add KKT tests that actually slow things down. The purpose of optimx is to allow comparison of methods and discovery of improved approaches to a p

Re: [R] Optimization to fit data to custom density distribution

2015-03-23 Thread Johannes Radinger
On Sat, Mar 21, 2015 at 3:41 PM, Prof Brian Ripley wrote: > On 21/03/2015 14:27, Johannes Radinger wrote: > >> Thanks for the fast response. The fitdistr() function works well for the >> predefined density functions. However, what is the recommended approach >> to optimize/fit a density function

Re: [R] Optimization to fit data to custom density distribution

2015-03-21 Thread Prof Brian Ripley
On 21/03/2015 14:27, Johannes Radinger wrote: Thanks for the fast response. The fitdistr() function works well for the predefined density functions. However, what is the recommended approach to optimize/fit a density function described by two superimposed normal distributions? In my case it is N1

Re: [R] Optimization to fit data to custom density distribution

2015-03-21 Thread Johannes Radinger
Thanks for the fast response. The fitdistr() function works well for the predefined density functions. However, what is the recommended approach to optimize/fit a density function described by two superimposed normal distributions? In my case it is N1(mean=0,sd1)*p+N2(mean=0,sd2)*(1-p). With fitdis

Re: [R] Optimization to fit data to custom density distribution

2015-03-21 Thread Prof Brian Ripley
One way using the standard R distribution: library(MASS) ?fitdistr No optimization is needed to fit a normal distribution, though. On 21/03/2015 13:05, Johannes Radinger wrote: Hi, I am looking for a way to fit data (vector of values) to a density function using an optimization (ordinary leas

Re: [R] optimization question

2014-10-02 Thread Andras Farkas
There is an error jean, I apologize... I made changes to the vectors and did not correct the bottom line... this is the correct run:a <-c(0,1,1,0,1,0,0,0,0) b <-c(0,0,0,1,0,0,0,0,0) c <-c(1,0,1,0,1,1,0,0,0) d <-c(0,1,0,1,0,1,0,0,0) df <-rbind(a,b,c,d) df <-cbind(df,h=c(sum(a)*8,sum(b)*8,sum(c)*8,s

Re: [R] optimization question

2014-10-02 Thread Adams, Jean
Andras, Is there an error in your post or am I missing something? df[, 9] is made up of the last (9th) element of each of a, b, c, and d. The minimum value for sum(df[, 9]) is 0. Given your conditions, there are many, many ways to get this result. Here is just one example: a <-c(1,1,1,1,1,0,0,0,0

Re: [R] optimization

2013-11-16 Thread Rolf Turner
On 11/17/13 11:49, Dennis Murphy wrote: There are lots of errors in your code. In particular, the optimization routines do not like functions that ignore the parameters. I would like to nominate this delicious riposte as a fortune candidate. Anyone to second the motion? Indeed. I so second!

Re: [R] optimization

2013-11-16 Thread Dennis Murphy
> There are lots of errors in your code. In particular, the optimization > routines do not like functions that ignore the parameters. I would like to nominate this delicious riposte as a fortune candidate. Anyone to second the motion? Dennis On Sat, Nov 16, 2013 at 1:26 PM, Prof J C Nash (U30A)

Re: [R] optimization

2013-11-16 Thread Prof J C Nash (U30A)
There are lots of errors in your code. In particular, the optimization routines do not like functions that ignore the parameters. And you have not provided out or out1 to the optimizer -- they are returned as elements of func(), but not correctly. Please try some of the examples for optim or opti

Re: [R] optimization: multiple assignment problem

2013-11-14 Thread Hans W.Borchers
Jean-Francois Chevalier bisnode.com> writes: > You have already given the answer yourself. You have binary variables x(j, i), you need to set up the inequalities, and then apply one of the mixed-integer linear programming solvers in R, for instance 'lpSolve', 'Rglpk', 'Rsymphony'. Setting up th

Re: [R] optimization: multiple assignment problem

2013-11-14 Thread Simon Zehnder
It would be more clear if you tell, what you want to do instead of what you do not want to do. If you start with a usual cost matrix (whatever cost function you have) and you have to assign N to N this reduces to the well-known Munkre’s algorithm (see for example: http://gallery.rcpp.org/artic

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-30 Thread peter dalgaard
On 29 Oct 2013, at 21:35 , Rolf Turner wrote: > On 10/29/13 19:44, peter dalgaard wrote: > > > >> There really is no substitute for knowledge and understanding! Did it not >> occur to you that the Windspeed column needs to enter into your analysis? > > > > Fortune! Actually, I felt

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-30 Thread Carl Witthoft
Which suggests the OP should verify that the data in "...$Frequency" is the data he expects to be there. Rui Barradas wrote > Hello, > > I can't reproduce your error: > > windfreq <- > c(1351L, 2147L, 3317L, 4378L, 5527L, 6667L, 7865L, 8970L, 9987L, > 10907L, 11905L, 12642L, 131000L, 14983L, 1

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-29 Thread Rolf Turner
On 10/29/13 19:44, peter dalgaard wrote: There really is no substitute for knowledge and understanding! Did it not occur to you that the Windspeed column needs to enter into your analysis? Fortune! cheers, Rolf Turner __ R-hel

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-28 Thread peter dalgaard
On 28 Oct 2013, at 13:07 , kmmoon100 wrote: > Hello everyone, > > This is Kangmin. > > I am trying to produce shape and scale of my wind data. My data is based on > wind speed frequency with 1km/hr increment. data is described below. > > Windspeed (km/h)Frequency > 1 351 > 2 147 >

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-28 Thread Berend Hasselman
On 29-10-2013, at 00:35, kmmoon100 wrote: > Hi Berend, > > Thank you for your reply. > How can I use dput function for this type of data? > I looked up the description of the function but I still can't understand how > to use it for solving my error. > You don't use dput() to solve your error

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-28 Thread kmmoon100
Hi Berend, Thank you for your reply. How can I use dput function for this type of data? I looked up the description of the function but I still can't understand how to use it for solving my error. Regards, Kangmin. -- View this message in context: http://r.789695.n4.nabble.com/Optimization-f

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-28 Thread Berend Hasselman
On 28-10-2013, at 16:07, Rui Barradas wrote: > Hello, > > I can't reproduce your error: > > windfreq <- > c(1351L, 2147L, 3317L, 4378L, 5527L, 6667L, 7865L, 8970L, 9987L, > 10907L, 11905L, 12642L, 131000L, 14983L, 15847L, 16842L, 17757L, > 18698L, 19632L, 20626L, 21599L, 22529L, 23325L, 24391L

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-28 Thread Rui Barradas
Hello, I can't reproduce your error: windfreq <- c(1351L, 2147L, 3317L, 4378L, 5527L, 6667L, 7865L, 8970L, 9987L, 10907L, 11905L, 12642L, 131000L, 14983L, 15847L, 16842L, 17757L, 18698L, 19632L, 20626L, 21599L, 22529L, 23325L, 24391L, 25356L, 26267L, 27230L, 28223L, 29190L, 30142L, 31124L, 32104

Re: [R] Optimization of a function using optim

2013-06-17 Thread Suzen, Mehmet
Dear Graham, On 16 June 2013 02:08, Graham McDannel wrote: > I am attempting to optimize a function I have developed using optim. > > I am getting the below error message: > > Error in n < 1: 'n' is missing > I suspect a function requires an argument named n, and you didn't pass one. Either in

Re: [R] Optimization of a function using optim

2013-06-15 Thread Rolf Turner
The r-help list should institute a prize for "Most Obtuse Question of the Month". This one should be a shoe-in for the June 2013 prize. cheers, Rolf Turner On 16/06/13 12:08, Graham McDannel wrote: I am attempting to optimize a function I have developed using optim. I am gettin

Re: [R] Optimization of a function using optim

2013-06-15 Thread Jeff Newmiller
Not unless you read the Posting Guide, stop posting in HTML mail format, and provide a reproducible example. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#.

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

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 arc

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
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: http://r.789695.n4.nabble.com/Optimization-problem-tp4663821p4663898.ht

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 in R similar to MS Excel Solver

2013-03-12 Thread Berend Hasselman
On 12-03-2013, at 08:45, Pavel_K wrote: > Dear Mr Hasselman, > for a better understanding I have attached an example solved in excel by > using the tool Solver. > > I want to assign for each municipality one of the centres and apply it for > calculating the minimum cost as you can see in an exa

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] Optimization in R similar to MS Excel Solver

2013-03-12 Thread Pavel_K
Dear Mr Hasselman, for a better understanding I have attached an example solved in excel by using the tool Solver. I want to assign for each municipality one of the centres and apply it for calculating the minimum cost as you can see in an example. I used package lpsolve, but it does not work. I a

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

2013-03-11 Thread Berend Hasselman
On 11-03-2013, at 23:31, Pavel_K wrote: > 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 re

Re: [R] Optimization Problem in R

2013-02-09 Thread Berend Hasselman
On 09-02-2013, at 21:08, Axel Urbiz 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 parameters, > o

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

2012-10-27 Thread Berend Hasselman
On 26-10-2012, at 21:41, Richard James wrote: > > That solution works very well. > > The only issue is that 'rnorm' occasionally generates negative values which > aren't logical in this situation. > Try another random generator. Lognormal, uniform, ... > Is there a way to set a lower limit

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

2012-10-26 Thread Richard James
That solution works very well. The only issue is that 'rnorm' occasionally generates negative values which aren't logical in this situation. Is there a way to set a lower limit of zero? -- View this message in context: http://r.789695.n4.nabble.com/Optimization-in-R-similar-to-MS-Excel-Sol

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

2012-10-26 Thread Berend Hasselman
On 26-10-2012, at 12:50, Richard James wrote: > Dear Berend and Thomas, > > thank you for suggesting the lsei function. I found that the tlsce {BCE} > function also works very well: > > library("BCE") > tlsce(A=bmat,B=target) > > The limSolve package has an 'xsample' function for generating un

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

2012-10-26 Thread Berend Hasselman
On 26-10-2012, at 12:50, Richard James wrote: > Dear Berend and Thomas, > > thank you for suggesting the lsei function. I found that the tlsce {BCE} > function also works very well: > > library("BCE") > tlsce(A=bmat,B=target) > > The limSolve package has an 'xsample' function for generating un

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

2012-10-26 Thread Richard James
Dear Berend and Thomas, thank you for suggesting the lsei function. I found that the tlsce {BCE} function also works very well: library("BCE") tlsce(A=bmat,B=target) The limSolve package has an 'xsample' function for generating uncertainty values via Monte-Carlo simulation, however it only works

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

2012-10-21 Thread Richard James
Dear Berend, Many thanks for taking your time to assist with this optimization problem. I'll work on data this week and let you know how I get on. Again, many thanks Richard -- View this message in context: http://r.789695.n4.nabble.com/Optimization-in-R-similar-to-MS-Excel-Solver-tp4646759

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

2012-10-21 Thread Berend Hasselman
On 21-10-2012, at 13:37, Thomas Schu wrote: > Dear Richard, > > It is funny. I have to perform the approach of sediment fingerprinting for > my master thesis. Mr. Hasselman gave me the advice to take a closer look > into the limSolve package a few days ago. > http://cran.r-project.org/web/packa

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

2012-10-21 Thread Thomas Schu
Dear Richard, It is funny. I have to perform the approach of sediment fingerprinting for my master thesis. Mr. Hasselman gave me the advice to take a closer look into the limSolve package a few days ago. http://cran.r-project.org/web/packages/limSolve/index.html I guess, the lsei-function of thi

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

2012-10-20 Thread Berend Hasselman
I do not know what algorithms the Excel solver function uses. See inline for how to do what you want in R. Forgive me if I have misinterpreted your request. On 19-10-2012, at 16:25, Richard James wrote: > Dear Colleagues, > I am attempting to develop an optimization routine for a river suspende

Re: [R] Optimization help

2012-07-30 Thread Petr Savicky
On Mon, Jul 30, 2012 at 06:51:47AM -0700, Megh Dal wrote: > Hi, I have following optimization problem: > > Min: x1 + x2 +...+ x7 > subject to: > > x1 + x2 >= 80 > x2 + x3 >= 65 > x3 + x4 >= 40 > > all xi are ***positive integer***. > > Can somebody help me in this optimization problem? Hi. As

Re: [R] Optimization inconsistencies

2012-05-18 Thread Petr Savicky
On Thu, May 17, 2012 at 06:14:37PM -0400, 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 > > equality constraint: > sum(x) = 1

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 peter dalgaard
On May 18, 2012, at 09:10 , Hans W Borchers wrote: > 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 >>>

Re: [R] Optimization inconsistencies

2012-05-18 Thread Marc Girondot
Le 18/05/12 00:14, Nathan Stephens a écrit : 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 equality constraint: sum(x) = 1 But I get inconsistent results dependi

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] Optimization inconsistencies

2012-05-17 Thread peter dalgaard
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 > > equality constraint: > sum(x) = 1 > > But I

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

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 th

Re: [R] Optimization package

2011-09-15 Thread Paul Hiemstra
On 09/14/2011 10:37 PM, Diviya Smith wrote: > Hi there, > > I have a complex math equation which does not have a closed form solution. > It is - > > y <- (p*exp(-a*d)*(1-exp((d-p)*(a-x[1]/((p-d)*(1-exp(-p*(a-x[1] > > For this equation, I have all the values except for x[1]. So I need to so

Re: [R] Optimization package

2011-09-14 Thread Berend Hasselman
Diviya Smith wrote: > > Hi there, > > I have a complex math equation which does not have a closed form solution. > It is - > > y <- (p*exp(-a*d)*(1-exp((d-p)*(a-x[1]/((p-d)*(1-exp(-p*(a-x[1] > > For this equation, I have all the values except for x[1]. So I need to > solve > this probl

Re: [R] optimization problems

2011-08-13 Thread John C Nash
optimx with BFGS uses optim, so you actually incur some overhead unnecessarily. And BFGS really needs good gradients (as does Rvmmin and Rcgmin which are updated BFGS and CG, but all in R and with bounds or box constraints). >From the Hessian, your function is (one of the many!) that have pretty

Re: [R] optimization problems

2011-08-13 Thread Kathie
To be honest, The first derivative of my objective function is very complicated so I ignore this. Could it lead to this sort of problem? Kathie -- View this message in context: http://r.789695.n4.nabble.com/optimization-problems-tp3741005p3741010.html Sent from the R help mailing list archive

Re: [R] optimization in for loop

2011-06-29 Thread siriustar
Thankyou very much. I think "try" works for me. I am learning it . Sirius -- View this message in context: http://r.789695.n4.nabble.com/optimization-in-for-loop-tp3633638p3634100.html Sent from the R help mailing list archive at Nabble.com. __ R-hel

Re: [R] optimization in for loop

2011-06-29 Thread David Winsemius
On Jun 29, 2011, at 2:31 PM, siriustar wrote: Hi, dear R help I am trying to use optim inside a for loop: ##For example. a: intial guess. b: result. f: function to be minimized for (i in 1:10) { b[i] <- optim(a[i], f)} However, some intial values cause error in optim function (e.g. "

Re: [R] optimization with Sparse matrices

2011-06-17 Thread Ben Bolker
Dube, Jean-Pierre chicagobooth.edu> writes: > > To whom it may concern, > > I am trying to maximize a log-likelihood function using optim. > This is a simple problem with only 18 > parameters. To conserve memory, I am using sparse matrices > (SLAM) for some of the data matrices used in the >

Re: [R] optimization with Sparse matrices

2011-06-16 Thread Berend Hasselman
Dube, Jean-Pierre wrote: > > To whom it may concern, > > I am trying to maximize a log-likelihood function using optim. This is a > simple problem with only 18 parameters. To conserve memory, I am using > sparse matrices (SLAM) for some of the data matrices used in the > computation of the lik

Re: [R] Optimization - n dimension matrix

2011-05-02 Thread Andrew Robinson
Hello, optim() works for more than one dimension. You might also find this page helpful: http://cran.r-project.org/web/views/Optimization.html Cheers Andrew On Mon, May 02, 2011 at 12:41:19PM -0700, petrolmaniac wrote: > Dear all, > > I am facing the following problem in optimization: > > w

Re: [R] Optimization Question

2011-02-14 Thread Ravi Varadhan
du -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ravi Varadhan Sent: Monday, February 14, 2011 10:20 AM To: 'Gabrielsen, Alexandros'; r-help@r-project.org Subject: Re: [R] Optimization Question Your function is non-smooth

Re: [R] Optimization Question

2011-02-14 Thread Ravi Varadhan
Your function is non-smooth and nasty looking. You might want to set the function value to a large positive number if an illegal arithmetic operation is performed and `NaN' is returned. fn <- function(p) { ftemp <- 263*log(sqrt(2*pi)*sd(test$A))+ sum(log(abs(c(test$A[-1], 1))^p[3])) + (sum(((te

Re: [R] optimization w.r.t matrix

2010-10-05 Thread David Winsemius
On Oct 5, 2010, at 2:46 PM, QiJun Fung wrote: Does any one know how to optimize the following function w.r.t to beta? The difficulty here is the beta is a matrix not a vector. and f is also a function of beta and an element of the objective function. I just want to know for this complicated sit

Re: [R] optimization subject to constraints

2010-08-10 Thread Matthias Gondan
Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dwayne Blind Sent: Monday, August 09, 2010 12:56 PM To: Gildas Mazo Cc: r-help@r-project.org Subject: Re: [R] optimization subject to constraints Hi ! Why not constrOptim ? D

Re: [R] optimization subject to constraints

2010-08-10 Thread Gildas Mazo
: >> constrOptim can only handle linear inequality constraints. It cannot >> handle >> equality (linear or nonlinear) as well as nonlinear inequality >> constraints. >> >> Ravi. >> >> -Original Message----- >> From: r-help-boun...@r-project.org >

Re: [R] optimization subject to constraints

2010-08-09 Thread Spencer Graves
not handle equality (linear or nonlinear) as well as nonlinear inequality constraints. Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dwayne Blind Sent: Monday, August 09, 2010 12:56 PM To: Gildas Mazo Cc: r-help@r-projec

Re: [R] optimization subject to constraints

2010-08-09 Thread Ravi Varadhan
: Monday, August 09, 2010 12:56 PM To: Gildas Mazo Cc: r-help@r-project.org Subject: Re: [R] optimization subject to constraints Hi ! Why not constrOptim ? Dwayne 2010/8/9 Gildas Mazo > Dear R users, > > I'm looking for tools to perform optimization subject to constraints, > bo

Re: [R] optimization subject to constraints

2010-08-09 Thread Matthias Gondan
try command solnp in package Rsolnp Am 09.08.2010 18:56, schrieb Dwayne Blind: Hi ! Why not constrOptim ? Dwayne 2010/8/9 Gildas Mazo Dear R users, I'm looking for tools to perform optimization subject to constraints, both linear and non-linear. I don't mind which algorithm may be used, m

Re: [R] optimization subject to constraints

2010-08-09 Thread Ravi Varadhan
You may want to look at: http://cran.r-project.org/web/packages/alabama/index.html Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gildas Mazo Sent: Monday, August 09, 2010 12:49 PM To: r-help@r-project.org Subject: [R] optim

Re: [R] optimization subject to constraints

2010-08-09 Thread Dwayne Blind
Hi ! Why not constrOptim ? Dwayne 2010/8/9 Gildas Mazo > Dear R users, > > I'm looking for tools to perform optimization subject to constraints, > both linear and non-linear. I don't mind which algorithm may be used, my > primary aim is to get something general and easy-to-use to study simples

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 uni-hohenheim.de> writes: > > Dear Ravi, > > As I've already written to you, the problem indeed is to find a solution >

Re: [R] Optimization problem with nonlinear constraint

2010-07-28 Thread Ravi Varadhan
-- From: r-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 uni-hohenheim.de> writes: > > Dear

Re: [R] Optimization problem with nonlinear constraint

2010-07-28 Thread Hans W Borchers
Uli Kleinwechter 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 optimization is the ri

Re: [R] Optimization problem with nonlinear constraint

2010-07-28 Thread Uli Kleinwechter
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. John C. Nash has been so kind to help me on here. In case anyone faces a similar problem in

Re: [R] Optimization problem with nonlinear constraint

2010-07-26 Thread Ravi Varadhan
Hi Uli, I am not sure if this is the problem that you really want to solve. The answer is the solution to the equation y = x * T^(x-1), provided a solution exists. There is no optimization involved here. What is the real problem that you are trying to solve? If you want to solve a more meaning

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 outco

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

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

Re: [R] Optimization problem

2010-06-17 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-17 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 s

Re: [R] Optimization problem

2010-06-17 Thread Ravi Varadhan
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. Let me know if you have any

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, self-contain

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 l

Re: [R] Optimization

2010-05-24 Thread Berend Hasselman
Berend Hasselman wrote: > > > Bogaso wrote: >> >> Hi all, I need to minimize following function : >> >> dat <- matrix(rnorm(2), ncol=2) >> targetFn <- function(x) { >> dat <- as.matrix(dat) >> dat1 <- 1*dat[,1] - (x^2)*dat[,2] >> return(sd(dat1))

Re: [R] Optimization

2010-05-24 Thread Berend Hasselman
Bogaso wrote: > > Hi all, I need to minimize following function : > > dat <- matrix(rnorm(2), ncol=2) > targetFn <- function(x) { > dat <- as.matrix(dat) > dat1 <- 1*dat[,1] - (x^2)*dat[,2] > return(sd(dat1)) } > > i.e. I want ro find for which "x"

Re: [R] optimization challenge

2010-01-28 Thread Greg Snow
Well, Albyn Jones gave a great solution to my challenge that found the best reading schedule. My original thought was that doing an exhaustive search would take too much time, but Albyn showed that there are ways to do it efficiently. My approach (as mentioned before) was to use optim with meth

Re: [R] optimization problem

2010-01-17 Thread Hans W. Borchers
Ravi Varadhan 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 (i.

Re: [R] optimization problem

2010-01-17 Thread Erwin Kalvelagen
gt; Ravi Varadhan, Ph.D. > Assistant Professor, > Division of Geriatric Medicine and Gerontology > School of Medicine > Johns Hopkins University > > Ph. (410) 502-2619 > email: rvarad...@jhmi.edu > > > - Original Message - > From: Erwin Kalvelagen &

Re: [R] optimization problem

2010-01-17 Thread Ravi Varadhan
klau...@gmx.de Date: Sunday, January 17, 2010 8:06 am Subject: Re: [R] optimization problem To: Ravi Varadhan , 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

Re: [R] optimization problem

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

  1   2   >