Skip to content
Prev 244099 / 398506 Next

How to formulate constraint like abs(x) = y in constrOptim (or other)

Hi Benjamin,

If you just had abs(x_i) < c_i, it will reduce to linear inequalities, but
your constraint cannot be reduced to that.

You might try "alabama" or "Rsolnp" packages.

Ravi.

-------------------------------------------------------
Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology School of Medicine Johns
Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Hans W Borchers
Sent: Monday, December 06, 2010 1:08 PM
To: r-help at stat.math.ethz.ch
Subject: Re: [R] How to formulate constraint like abs(x) = y in constrOptim
(or other)

Benjamin B. <benj.bad.ac <at> googlemail.com> writes:
could
With 'constrOptim' you can formulate linear constraints only, and in most
cases abs() is not linear. You might try one of the nonlinear optimization
packages.

Another possibility is to reformulate the absolute value with two binary
values, if your optimization function itself is linear; you didn't tell us
the whole story.

Hans Werner

______________________________________________
R-help at 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.