# Tags around categorical data coding / representation

Return back to the issue, June 30, 2017

I want to bring your attention once again to this tag question about categorical data encoding. It has not been resolved satisfactory so far, to me.

1) I claim that we do need one special tag for (various types) of categorical data encoding/representation in analyses (types are: dummy or one-hot coding, deviation or effect coding, Helmert, repeated, etc. etc.). One omnibus tag for them. Just imagine it: we have endemic tag [many-categories] but we don't have a tag for ubiquitous theme of how to represent categorical variables in this or that analysis or situation. We have currently only tag [categorical-data] which covers it but is much more broad and general.

So, I recommend to create the tag. Wording candidates: [contrast-variables] or [categ-data-encoding] or [categ-coding-scheme] or suggest your variant.

2) Dummy (aka one-hot) binary variables are the most well-known type of the categorical encoding / contrast variables. As currently, the tag [dummy-variables] is a slave synonym to [categorical-data]. Please recover it back as the tag on its own. Next thing: we yet keep currently separate tag [indicator-variables] however. This is strange because it is conceptually the same thing as dummy variables (just less known term).

So, either map [indicator-variables] to the restored [dummy-variables] as its junior synonym; or, if you prefer [indicator-variables], keep it, but then map [dummy-variables] to it (not to [categorical-data]).

Original post Mar 6, 2017:

Moderators, please remove [dummy-variables] tag from being a synonym to [categorical-data]. These are definitely not synonyms. Categorical data can be represented as dummy variables, sure. That doesn't make the two concepts same at all.

[dummy-variables] should be kept a separate tag, and [indicator-variables] be made its junior synonym. In a recent question/comment I've expressed my tendency to see indicators as a synonym of dummy. "Dummy", in turn, is just the binary type of "contrast variables", not any contrast variables.

Therefore tag [contrast-variables] should be created. It is elementary variables to which categorical data (factors) are recoded, explicitly or implicitly, in ANOVA-like procedures. Contrast variables correspond, but not synonymic, to [contrasts] (comparing combinations of coefficients, we do have this tag already). Contrast variables include types "dummy", "deviation / effect", "Helmert", and so on.

If people agree and moderators recover [dummy-variables] I could then proceed and fix the tagging of questions according to the above thesaurus.

So far I can see these three alternatives:

• define [dummy-variables] (or [dummy-set]) as binary indicator variables obtained out of a categorical variable. & create [contrast-variables] (or [contrast-set]) as more general - not necessarily binary - such variables (I vote for this variant)

• define [indicator-variables] (or [indicator-set]) to be what "dummy variables" was defined just above. & define [dummy-variables] (or [dummy-set]) to be what "contrast variables" was defined just above.

Both variants require [dummy-variables] to be restored as a proper tag.

• Third solution: don't restore/define anyhow old [dummy-variables] tag, however create tag [contrast-variables] which, if you like, we may give another name, say [categ-coding-scheme].
• I agree that [dummy-variables] should not be a synonym of [categorical-data]. I agree that [indicator-variables] should be a synonym of [dummy-variables]. But I don't think that having [contrast-variables] and contrasts as two separate tags is a good idea. It's not clear to me how these two tags should be separated in usage. Mar 6, 2017 at 11:16
• Also, I agree with Scortchi here (stats.stackexchange.com/a/125612/28666) that "dummy variable" can have values other than 0 and 1, and so Helmert contrast coding variables can be described as "dummy variables" too. Mar 6, 2017 at 11:22
• @amoeba, I think they are didactically distinct, theoretically tied. Contrast is a set of coefficients creating/defining the now being compared groups out of categorical factor(s). Contrast variables are data values, codes. Since we have tag dummy-variables for data but define it narrowly (as indicator type contrast variables), we have to compensate and create the wider tag contrast-variables. Term "contrast variables" is not my invention, it encounters in literature. Mar 6, 2017 at 11:23
• I agree with Scortchi here This is exactly where @Scortchi and I don't agree. I see "dummy variables" as only the binary (1 0), specific type. This is principal issue of terminology. Either the audience decide to follow "Scortchi's" or "my" proposal of definition of "dummy". If Scortchi's - then we don't need [contrast-variables], but then must play back and recover [indicator-variables] (=one-hot) to be a separate tag. You see, this type is so widely used that it deserves a tag. Mar 6, 2017 at 11:29
• P.S. My own background is possibly different somewhat to Scortchi's. I did encounter "dummy variables" in his wide sense (= "my" contrast variables), but much more seldom than "dummy variables" as =indicator (binary) type. Mar 6, 2017 at 11:35
• The distinction between contrasts and contrast variables seems a very subtle one which may only interest a small number of users so I would not want to support that part of the proposal. +1 for the rest Mar 6, 2017 at 12:28
• One should note that dummy-variables -> categorical-data synonym exists since 2011 and has led to 350+ tag renames (one can see it here stats.stackexchange.com/tags/synonyms). Also, there are 500+ questions with "dummy variable" in their body. This makes me wonder whether removing this synonym mapping is the best course of action (even though I said so above)... We are not going to re-tag 300-500 old questions. Mar 6, 2017 at 14:43
• amoeba, It was very imprudent decision of @whuber to absorb [dummy-variables] by [categorical-data]. (Even analytically, it was wrong: dummy predictors enter the fitting algorithm as numeric values, they aren't "categorical" anymore.) I would say this should be undone at any "price" - if there price at all. Mar 6, 2017 at 18:34
• @whuber, will you, can you undo the past synonymization of [dummy-variables] to [categorical-data]? Mar 7, 2017 at 11:07
• @ttnphns As far as I know, this is impossible in principle. One can delete the synonym mapping, but one can't undo the tag changes that have previously happened via this synonym mapping... Mar 8, 2017 at 14:25
• @amoeba, Anyways, I've seen somewhere in meta here on on SO that a moderator can abolish the tie (mapping). At least this is ought to be done, for the future, for me. (If after it we need to do some "back" retagging manually - we could do it. In particualrly, I could find time(s) re-tag those ~ 500 questions, perhaps). Mar 8, 2017 at 17:52

Update (26 Oct 2017): Master tag has been created, and has the following three synonyms: [dummy-variables], [indicator-variables], and [one-hot].

I claim that we do need one special tag for (various types) of categorical data encoding/representation in analyses (types are: dummy or one-hot coding, deviation or effect coding, Helmert, repeated, etc. etc.). One omnibus tag for them.

This suggestion sounds sensible to me. It got several upvotes (your question + some of the comments) and nobody has objected in the discussion above.

I think it would be good to choose a name that includes "categorical" in it. But [categ-data-encoding] and [categ-coding-scheme] sound too clumsy. Perhaps [categorical-coding]?

Apart from that, I am not a big fan of narrow tags, and I don't like subset tags. So I would be against maintaining further tags that are subsets of this main categorical-coding tag. Therefore:

• should be uncoupled from (I agree with you here), but then made a synonym of our new categorical-coding tag. I don't think we should have it as a separate tag.

• (37, no excerpt) should be made synonym of the new categorical-coding tag too. [Note: many questions currently having this tag are about indicator function and are not at all related to encoding categorical variables for statistical analysis. Those have to be dealt with.]

Update: was created for questions about indicator function. Along the way, [indicator-variables] has been emptied, so if we want to make it a synonym of categorical-encoding, it has to be re-created first.

• We could create [contrast-variables] as another synonym of the same categorical-coding tag if we think it makes sense.

• The same goes for [one-hot]: we could create it as another possible synonym of the same tag, it might be useful.

This way we don't need to decide (see discussion in the comments above) on the terminological details such as whether "dummy variables" can have values other than 0 and 1. We'll have one omnibus tag for all these topics. It will be a subset of , but perhaps you are right that the topic is important enough to warrant that.

Just to mention it here: if we go with the above proposal, some manual retagging will be necessary to put this new "coding" tag on the most important threads about encoding categorical variables. As always, we don't need to put it everywhere; it's enough to put it on the most important threads. As far as I understand, @ttnphns volunteered to take care of it.

• Thank you a lot for the thorough response. 1) I'd vote then for [categorical-encoding], not [categorical-coding]. "Coding" is ambiguous, could be thought of as coding (labeling) categories by integers 1,2,.. or letters A,B,.., while we are speaking of the recoding a categorical variable into a set of elementary variables encoding the categories. 2) Though I personally think we better mark out [dummy-variables] as a separate tag too, I could change it for your opinion, especially if others support it. 3) Agree with all the rest points. Jul 1, 2017 at 23:33
• Let us wait a little while for somebody to enter the discussion. Then if we state we agree, I'd suggest you to perform the tags creation/(de)synonymizing (if you don't mind) while I then sort out questions to them. Jul 2, 2017 at 0:12
• Happy to look at the indicator variables ones if this goes ahead. Jul 2, 2017 at 11:10
• +1 this seems like a reasonable path forward for this difficult topic. Re the new name, @ttnphns's concern makes sense. I wonder if [encoding-categories] would be a viable option. Jul 2, 2017 at 13:00
• @gung, yours is fine too. Still, after some hesitation, I'd stand for [categorical-encoding]. Reasons are subtle. 1) We better keep word "categorical" to keep immediate reference to "categorical-data", while "categories" might sound too general. 2) "Categories" might prompt (a layman) to think we are recoding each category independently, while in fact its not so, we recode a set of categories (a variable) into a set of encoded "contrast" variables where codes (values) are specially interdependent - depending of the type we choose (dummy, deviance, Helmert etc.) Jul 2, 2017 at 13:36
• @ttnphns I am fine with categorical-encoding instead of categorical-coding, but note that terms like "effects coding", "dummy coding" etc. use the word "coding"... Jul 3, 2017 at 13:31
• amoeba, they might as well use "encoding". Saying "encode" we simply stress the directional and completeness (or totality) nature of the action, thansitional process, not simply a symbolic substitution dictionary.com/browse/encode. "Coding" is all right, but "encoding" might sound better, for me. Maybe @gung shares his opinion? Jul 3, 2017 at 14:23
• @ttnphns, any of these are about as good from my point of view. The ideal would be [coding-categorical-data], but I think that's too long. If people prefer [categorical-encoding], that's all right with me. Jul 3, 2017 at 15:10
• @gung, just to mention it again - I personally don't like very much [coding-categorical-data] because - as I've said - people think coding = labeling by codes and will take the tag for that; while we are speaking of and mean a special...ehh.. "transformation". Jul 3, 2017 at 15:22
• @ttnphns Nobody objects to [categorical-encoding], so we could use that. If you want to go ahead, I would suggest the following course of action: first of all, you create this tag and put it on 10-20 (or maybe 30-40, as you see fit) old threads that are "most important" in this topic (are well upvoted etc.). Once this is done and the tag is established, we will ask the mods to uncouple [dummy-variables] from categorical-data and to map it to categorical-encoding. In the meantime, mdewey can sort the [indicator-variables] tag. But creating+populating [categorical-encoding] is the first step. Jul 10, 2017 at 12:14
• @mdewey I think you can go ahead with [indicator-variables]. I'd say remove/replace this tag from abstract mathematical questions about indicator function, but leave it on questions about categorical-encoding (i.e. encoding categorical variables for statistical analysis). Once finished, we'll aim to make it a synonym. Jul 12, 2017 at 11:45
• [indicator-variables[ is now in progress Jul 12, 2017 at 12:22
• Amoeba, I created tag [categorical-encoding] and did the tagging of questions with it. Jul 12, 2017 at 12:55
• @ttnphns We don't "have to be reconciled", but if you want to make your case for releasing [dummy-variables] as a stand-alone tag then post your own answer in this thread suggesting this course of action so that people could upvote/downvote it. Currently my answer is suggesting otherwise, and it already has 5 upvotes and 0 downvotes, so it looks like it has some support. If you choose NOT to post your own answer, then I would say yes, "we will have to be reconciled" with what I proposed :-) Jul 26, 2017 at 14:13
• Amoeba I have tagged a few more questions found by searching for "indicator function". I only looked at ones with $>2$ votes and I only tagged them if they seemed to me to be about indicator functions rather than just using them as a notation. We now have 15 tagged. Jul 28, 2017 at 13:07

Do we need a special tag [dummy-variables]?

Since and thank to @amoeba's answer (which was well accepted, and I upvoted it too) we've acquired tag [categorical-encoding] - a separate tag marking topics on the ways to recode/represent categorical data in numerical data analysis.

One of the most well-known, ubiquitous way of "categorical encoding" is dummy variables (aka indicator variables, aka one-hot variables) - a set of binary variables - each one corresponding to one category - where 1 stands for "this category" and 0 stands for "not this category".

In their point 1 @amoeba thought we don't need a separate tag for dummy variables (I don't think we should have it as a separate tag) as soon as we have [categorical-encoding]. But I always believed we ought to have [dummy-variables] along with [categorical-encoding]. I don't think it is deadly critical, only that we'd rather have it than not, as it looks to me. It will be useful.

Reasons to have [dummy-variables]:

• Dummy-variables are most often used and well-known type of categorical coding. A person may even not be aware of different ways of categorical coding but he is likely to be familiar with "dummy" or "one-hot" terms.
• It is used far beyond the domain of representing of a predictor (factor) in ANOVA-like analyses; i.e. far beyond the theme of "contrasts". Almost every kind of data analysis which can manage categorical data will - internally or explicitly - encode it as the binary dummies. Thus, [dummy-variables] makes interest in threads discussing many algorithms, not just threads on categorical analysis.
• In "contrast" tasks (categorical predictor) we often consider k-1 set of dummy variables, not full k-variable set (k is the number of categories). It is an important (for parameter interpretation) issue which one is to drop in ANOVA context. But for analyses where we may use all k variables (clustering etc.) that question ("k or k-1 and which to drop?") doesn't belong to. Some users who think of [categorical-encoding] as contaminated with the question will be relieved to find tag [dummy-variables] which isn't necessarily contaminated and may use it calmly, say, in the context of cluster analysis.
• Sometimes the input is already a set of dummy variables and the task or the text contains just no word "categorical" anywhere. Therefore the issue that the set of numeric variables potentially represent one nominal variable is not apparent or important at all.

Note: if people decide that we create the tag, but they will oppress "dummy variables" (which term is OK for me), we could name that tag [indicator-variables] or [one-hot] instead.

• I am not going to downvote because I think it's others who should choose between our suggestions, but I'd like to re-iterate that I am against this suggestion, and the main reason is that I am (as a general principle) against strongly overlapping or subset tags. Two distinct tags [categorical-encoding] and [dummy-variables], imho, would overlap WAY too strong to warrant their separate existence. For that reason I am happy to consider the meaning of [categorical-encoding] general enough to be able to include all possible uses that you give in your bullet list. Jul 26, 2017 at 17:09
• (Practically speaking, I'd say we now have to wait at least 1 week before we can decide on the further course of action. I encourage everybody who reads this to either upvote or downvote this answer and ideally to leave a comment as well.) Jul 26, 2017 at 17:12
• I would encourage readers to comment on, more than up/down vote. It is strange how you can "measure" overlap WAY too strong. It was your intuition which is all right. Mine was different. I expressed some reasons to support it. Also, I think that in some special cases we could well keep separate tags which are much overlap. I'd say the current is such a case. Note that definitionally dummies are just the subset of "cat. encoding", but psychologically they are enough different for many users, think I. Jul 26, 2017 at 17:30
• @amoeba, [anova] completely belongs to [linear model] while the latter completely belongs to [generalized linear]. Still, we have all these popular tags as separate. It is reasonable. Logically, didactically. Jul 26, 2017 at 17:40
• I consider subset tags evil; sometimes it is a necessary evil. In this case it does not look necessary to me. But that's just my opinion. Let's see what others will say. Jul 26, 2017 at 18:09
• @amoeba, evil or not evil, things are (can be) classified hierarchically. If always we are to keep only the parent tag we in the end are left with just tag [everything]. :-) Practical reasons to leave exist some "good" junior subsets is what human thinking is about. Jul 26, 2017 at 18:15
• (+1) My feeling, for what it is worth, is that many beginners may understand the term dummy variable but would not immediately think of categorical encoding so I do see a role for it. It does seem to me to form a proper subset of categorical encoding so I would be happy with that. I do not feel super strongly about this so I shall not be crying into my beer if it does not go through. Jul 27, 2017 at 10:03
• I agree w/ @amoeba. For the most part, [dummy-variables] would be overlapping w/ [categorical-encoding]. To the extent that you might want [dummy-variables] on seemingly unrelated threads about algorithms, there is little chance of it ever really being used correctly, IMO. The point that some people will be familiar w/ the term 'dummy coding', or the term 'one hot', that is reasonable, but to me, it argues that we should also make those two tags & immediately make them synonyms of [categorical-encoding]. Jul 27, 2017 at 12:28
• usεr11852 wrote in chat: "I agree with you so I upvoted your answer but I did not downvote ttphns. (I usually refrain from downvoting Meta answers unless outright harmful.) I think that gung's comment about [one-hot] etc. is spot on. There will be some people that do not see the association immediately but generally it is not a big issue in my opinion and will quickly resolve itself." On the other hand, Glen_b commented under my answer: "I also upvoted ttnphns' answer since I find myself in agreement with it [...]". So it's 3:3 at the moment... :-/ Jul 28, 2017 at 8:22
• I think mapping all the different encodings to [categorical encoding] makes sense. I think a lot of people will search for dummy coding, but it's good teaching to show them that dummy coding is only one form of encoding (if they don't already know) and it allows for writing a single, informative description, rather than multiple ones. I upvoted @amoeba 's answer; I did not downvote this one, as it is helpful, I just disagree. Jul 28, 2017 at 13:03
• @PeterFlom You hit the nail on the head there. There's also the issue that [dummy-variables] is a not obviously overloaded term that can misleadingly connote a single topic, whereas [categorical-encoding] reads as a broader topical domain (at least to me), and as you point out the issues in that domain are interrelated. I feel we should not create [dummy-variables], unless we perhaps create it as a "synonymn" that points at [categorical-encoding] Jul 28, 2017 at 21:38
• @ttnphns I don't really see how dummy variables can be used in contexts that don't involve categorical data. Jul 29, 2017 at 11:46
• @ttnphns But if dummy variables linked to encoding, then they would find that wouldn't they? Dummy variables, on a statistics site, seems to me to have to have something to do with encoding. And, if we did include dummy variables, almost all of its use here on CV would be about that. Jul 29, 2017 at 12:32
• I don't get the last reason either. How can someone understand what dummy variables are without also understanding that they encode categorical variables? Jul 30, 2017 at 14:54
• @amoeba, Your position clearly got more supporters. I think you are free now to do what you have proposed: ask to recover [dummy-variables] and tie it with [categorical-encoding] Aug 8, 2017 at 6:55