[R] Excel can do what R can't?????

Roger D. Peng rpeng at stat.ucla.edu
Thu Jul 17 07:42:32 CEST 2003


I'm having a little difficulty understanding this thread.  If Excel can 
do the job correctly and suits your needs, why not just use Excel? 

As far as I know, 'optim' cannot optimize a function subject to 
arbitrary equality constraints.  The 'constrOptim' function allows for 
linear inequality constraints but in general, you will either have to 
reformulate the problem or add your own penalty into the objective 
function.  Also, just a small note, but using lexical scoping in your 
problem would eliminate the need to have all those variables defined in 
the global environment (but otherwise it won't change anything). 

-roger

Michael Rennie wrote:

>Hi, Reid and Spencer- 
>
>I think I've figured something out pretty critical to the problem.  
>
>Loking at my 'solver' options, I have a condition added that 'Hgtmod = Hgt'.  
>Without this conditional statement, I have to run solver 3-4 times before I get 
>a final solution. MEANING- solver and R, when left to their own devices, suck 
>equally at finding a solution with similar starting points.  BUT, given a 
>conditional statement that demands Hgt = Hgtmod, it gives it somewhere to look 
>withing the given parameter space. 
>
>So, the millon dollar quesiton: Is there any way of setting up a contitional 
>statement like this in 'optim', to specify a solution such that Hgtmod = Hgt?  
>Or, write it into function f?  The control statements 'fnscale' and 'parscale' 
>

I don't think 'fnscale' or 'parscale' will help you here at all.  If you 
want a constraint you need to specify it in the objective function 
directly (something like an additive penalty). 

>look like candidates, but will only help me if I build Hgtmod into the 
>optimization statement- can I do that?  How do you specify multiple 
>parameters?  Or should I specify two functions to optimize- one, fucntion f, 
>and a second, something like
>
>g<- (Hgt = Hgtmod)^2  
>
>Can I do that? If this is all I need to do, I am off to the races, and owe you 
>both a beer!  I'm going to try some stuff. All is not lost! If you have any 
>ideas, I'd love to hear them.
>
>THanks again for everything.....
>
>
>  
>
>  
>




More information about the R-help mailing list