[R] optimize linear function

roger koenker rkoenker at uiuc.edu
Sun Jun 13 07:19:12 CEST 2004


On Jun 12, 2004, at 4:35 PM, Prof Brian Ripley wrote:

> This is just a linear programming problem.  So the packages which do
> linear programming are `particularly well suited to this sort of task'
> and theory tells you a lot about the solution.
>
Indeed.  With the package  quantreg, for example, you could do:

	rq(y ~ x1 + x2, tau = eps)

for any small eps.    Note that in the example sum(y) and the additive
factor .03 aren't really germane.  If the problem is large you might 
want to
add method = "fn" to the call to use interior point optimization rather 
than
simplex (exterior point) methods).

url:	www.econ.uiuc.edu/~roger        	Roger Koenker
email	rkoenker at uiuc.edu			Department of Economics
vox: 	217-333-4558				University of Illinois
fax:   	217-244-6678				Champaign, IL 61820

>
> On Sat, 12 Jun 2004, Michaell Taylor wrote:
>
>> I am attempting to optimize a regression model's parameters to meet a 
>> specific
>> target for the sum of positive errors over sum of the dependent 
>> variable
>> (minErr below).
>
>>
>> ===========  Sample Problem = first approach  ================
>> # linear model  (presumably yielding B1=.8 and B2=.2)
[....]
>> m<-lm(y ~ x1+ x2)
>> # test on summation of positive errors.
>> e <- resid(m)
>> minErr <- (sum(ifelse(e<0,0,e))/sum(y))-.03
>>




More information about the R-help mailing list