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

[R] Optimization function producing negative parameter values

2021-03-21 Thread Shah Alam
Dear all, I am using optim() to estimate unknown parameters by minimizing the residual sums of squares. I created a function with the model. The model is working fine. The optim function is producing negative parameter values, even I have introduced upper and lower bounds (given in code). Therefor

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

[R] Optimization with Parallel Processing Functions/Packages

2018-11-07 Thread Doran, Harold
More of a general query, but looking to see if others have successfully used something like the foreach package (or other parallel style functions) with certain functions that minimize likelihood or objective functions (e.g., optim/nlminb). I have had great success with embarrassingly parallel

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

2016-09-30 Thread Paul Gilbert
ent is zero because the objective function is flat. This would normally be considered a "user error" but perhaps John's newer code can catch it? Paul Date: Thu, 29 Sep 2016 14:53:08 -0500 From: Narendra Modi To: "r-help@r-project.org" Subject: [R] Optimizatio

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

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

2016-09-29 Thread Narendra Modi
I have put together a R snippet wherein I am trying to get optimum values for which error is minimized. The error is the difference between two matrices. Every time I run the below code, I don't see any optimization happening as in the final answer is the same as the initial estimate regardless of

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

[R] Optimization max likelihood problem

2016-04-06 Thread Alaa Sindi
hello all, I am getting wrong estimates from this code. do you know what could be the problem. thanks x<- c(1.6, 1.7, 1.7, 1.7, 1.8, 1.8, 1.8, 1.8) y <- c( 6, 13, 18, 28, 52, 53, 61, 60) n <- c(59, 60, 62, 56, 63, 59, 62, 60) DF <- data.frame(x, y, n) # note: there is no need to have the ch

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

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

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

[R] Optimization Grid Search Slow

2015-09-17 Thread Patzelt, Edward
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 dramatically? dat <- structure(list(choice = c(0, 1, 1, 1,

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

[R] Optimization to fit data to custom density distribution

2015-03-21 Thread Johannes Radinger
Hi, I am looking for a way to fit data (vector of values) to a density function using an optimization (ordinary least squares or maximum likelihood fit). For example if I have a vector of 100 values generated with rnorm: rnorm(n=100,mean=500,sd=50) How can I fit these data to a Gaussian density

[R] Optimization function

2014-11-20 Thread Amit Thombre
Hi, I want to optimize the root mean square error objective function using the optim function. Thus the function will look like sqrt(sum((yi - f(xi))^2)/n). Now the f(xi) is the Arima function. I am not clear how do I get the f(xi) because the call to arima function in C gives the value of th

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

[R] optimization question

2014-10-01 Thread Andras Farkas
Dear All, please provide help with the following: we have 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,sum(d)*8)) df <-cbind(df,df[,8]*c(1,2,3,2)) I would like to minimize the

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
> Please try some of the examples for optim or optimx to learn how to > structure your problem. > > JN > > > On 13-11-16 06:00 AM, r-help-requ...@r-project.org wrote: >> Message: 19 >> Date: Fri, 15 Nov 2013 09:17:47 -0800 (PST) >> From: IZHAK shabsogh >> T

Re: [R] optimization

2013-11-16 Thread Prof J C Nash (U30A)
optimx to learn how to structure your problem. JN On 13-11-16 06:00 AM, r-help-requ...@r-project.org wrote: > Message: 19 > Date: Fri, 15 Nov 2013 09:17:47 -0800 (PST) > From: IZHAK shabsogh > To: "r-help@r-project.org" > Subject: [R] optimization > Message-ID: >

[R] optimization

2013-11-15 Thread IZHAK shabsogh
x1<-c(5.548,4.896,1.964,3.586,3.824,3.111,3.607,3.557,2.989,18.053,3.773,1.253,2.094,2.726,1.758,5.011,2.455,0.913,0.890,2.468,4.168,4.810,34.319,1.531,1.481,2.239,4.204,3.463,1.727) y<-c(2.590,3.770,1.270,1.445,3.290,0.930,1.600,1.250,3.450,1.096,1.745,1.060,0.890,2.755,1.515,4.770,2.220,0.590,0.5

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

[R] optimization: multiple assignment problem

2013-11-14 Thread Jean-Francois Chevalier
Hello, I'm trying to solve a multiple assignment problem. I found a package Adagio and its function mknapsack which maximize vstar = p(1)*(x(1,1) + ... + x(m,1)) + ... ... + p(n)*(x(1,n) + ... + x(m,n)) subject to w(1)*x(i,1) + ... + w(n)*x(i,n) <= k(i) for i=1,...,m x(1,j) + ... + x(m,j) <= 1

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

[R] "Optimization fail" error from fitdistr (Weibull distribution)

2013-10-28 Thread kmmoon100
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 3 317 4 378 5 527 6 667 7 865 8 970 9 987 10 907 11 905 12 64

[R] Optimization failed in fitdistr (Weibull distribution)

2013-10-28 Thread kmmoon100
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 3 317 4 378 5 527 6 667 7 865 8

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

[R] Optimization of a function using optim

2013-06-15 Thread Graham McDannel
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 Could some one provide some additional clarity regarding this message and what it entails, as well as, how to rectify this issue. Thanks [[alternati

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]

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

2013-03-12 Thread Berend Hasselman
you can see in an example. > I used package lpsolve, but it does not work. I am not sure how to treat > with this part of statement, I think I made mistake in it: > row.rhs <- c(15,10,5,30) and > col.rhs <- c(1,1,1,1,1,1) > > The example in R: > > library(lpSolve) &g

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
am not sure how to treat with this part of statement, I think I made mistake in it: row.rhs <- c(15,10,5,30) and col.rhs <- c(1,1,1,1,1,1) The example in R: library(lpSolve) costs <- as.matrix(read.table("C:/R/OPTIMIZATION/DATA.TXT", dec = ",", sep=";",

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

[R] Optimization in R similar to MS Excel Solver

2013-03-11 Thread Pavel_K
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 and 6 columns represent the centres. It co

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

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

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

[R] Optimization help

2012-07-30 Thread Megh Dal
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? Thanks for your help __ R-help@r-project.org

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

[R] Optimization inconsistencies

2012-05-17 Thread Nathan Stephens
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 depending on what starting values I. I've tried variou

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

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

2011-09-15 Thread Paul Hiemstra
_ > 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-contained, reproducible code. Google for "R optimization&q

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

[R] Optimization package

2011-09-14 Thread Diviya Smith
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 problem numerically. Can anyone suggest an optimi

[R] optimization problems

2011-08-13 Thread Ravi Varadhan
Kathie, It is very difficult to help without adequate information. What does your objective function look like? Are you maximizing (in which case you have to make sure that the sign of the objective function is correct) or minimizing? Can you try "optimx" with the control option all.methods=TR

Re: [R] optimization problems

2011-08-13 Thread John C Nash
00 (PDT) > From: Kathie To: r-help@r-project.org Subject: > [R] > optimization problems Message-ID: <1313223129383-3741005.p...@n4.nabble.com> > Content-Type: > text/plain; charset=us-ascii Dear R users I am trying to use OPTIMX(OPTIM) > for nonlinear > optimization. Th

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

[R] optimization problems

2011-08-13 Thread Kathie
Dear R users I am trying to use OPTIMX(OPTIM) for nonlinear optimization. There is no error in my code but the results are so weird (see below). When I ran via OPTIM, the results are that Initial values are that theta0 = 0.6 1.6 0.6 1.6 0.7. (In fact true vales are 0.5,1.0,0.8,1.2, 0.6.) --

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

[R] optimization in for loop

2011-06-29 Thread siriustar
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. " system is computationally singular..."). Then the for

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

[R] optimization with Sparse matrices

2011-06-16 Thread Dube, Jean-Pierre
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 likelihood. However, optim appears to co

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

[R] Optimization - n dimension matrix

2011-05-02 Thread petrolmaniac
Dear all, I am facing the following problem in optimization: w = (d, o1, ..., op, m1, ..., mq) is a 1 + p + q vector I want to determine: w = argmin (a - d(w))' A (a - d(w)) where a is a 1xK marix, A is the covariance matrix of vector a, d(w) is a 1xK vector which parameters are functions of

Re: [R] a question on R optimization functions

2011-03-25 Thread Ravi Varadhan
pkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Bolker Sent: Friday, March 25, 2011 3:23 PM To: r-h...@stat.math.ethz.ch Subject: Re: [R] a question on R optimiz

Re: [R] a question on R optimization functions

2011-03-25 Thread Ben Bolker
Paul Gilbert bank-banque-canada.ca> writes: > > It seems more likely that the return value from your function > is NA or NaN or Inf. This might then result in an > NA parameter value being calculated for the next step. > This is possible, for example, because the line > search extends outside

Re: [R] a question on R optimization functions

2011-03-25 Thread Paul Gilbert
3:59 AM > To: r-help@r-project.org > Subject: [R] a question on R optimization functions > > Dear All, > > I use nlminb or optim for maximizing likelihood functions. Sometimes, > the parameter values happen to be NA, then the program will hang there > and iterate foreve

  1   2   3   >