Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: minimum of "all other variables"


From   "Svend Juul" <[email protected]>
To   <[email protected]>
Subject   Re: st: minimum of "all other variables"
Date   Tue, 17 Oct 2006 09:16:42 +0200

Steve wrote:

... Thanks to Nick, I have a program (-myboolean-) that turns fuzzy sets
into multiset fuzzy intersections. So, for example, with fuzzy sets A
and B, running -myboolean A B- yields four new variables: ab Ab aB AB
(where lower = absence [1-set], upper = presence [set], and -- for
example -- AB = min(A,B)). Enough background I hope.

What I'd like to do now is to create new variables that contain the
maximum value of all OTHER configurations for each configuration
produced by -myboolean-. Manually, this is easy to do: otherAB =
max(Ab,aB,ab). But with 32 or 64 configuration variables, this is very
time consuming. Is there a way to automate this so that:
foreach var of varlist ab - AB {
gen other`var' = max(***all other vars in varlist but `var'***)
}

One final note: in the crisp set case (where set membership is always
0/1) other`var' would always = 1-`var'. But this is not true in the
fuzzy case. Hence the difficulty.
-------------------------------------------------

If I understand you right, this exemplifies a solution. Somebody else
may find a smarter way:

clear
set obs 20
gen ab=uniform()
gen Ab=uniform()
gen aB=uniform()
gen AB=uniform()
list
ds ab-AB
return list
local VV = r(varlist)
display `VV'

foreach V of varlist `VV' {
  gen `V'_max = 0
  foreach U of varlist `VV' {
    if "`U'" != "`V'" {
      replace `V'_max = `U' if `U'>`V'_max
    }
  }
}
list

Hope this helps
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: [email protected]
__________________________________________ 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index