# Questions tagged [categorical-encoding]

Representing categorical variables as sets of numerical variables. Necessary in many types of analysis for them to process categorical data. A common example is using a categorical predictor in regression/ANOVA via dummy coding, effect coding, Helmert coding, user-defined contrasts, etc.

726 questions
Filter by
Sorted by
Tagged with
1 vote
19 views

### MNIST with a TWIST, no labels given, only probabilities

Let's say we have basic MNIST dataset, and we have the same goal to predict the digit, BUT we're swapping all the labels by RED ...
• 121
1 vote
28 views

### Is it OK to include a continuous predictor variable and dummy predictors based on that continuous predictor?

I am using binary logistic regression with a number of continuous and dummy predictors. Is it OK to include a continuous predictor for age as well as dummy predictors based on age, such as "teen&...
• 111
117 views

### Exists an option to avoid reference categories in logistic regression?

I was wondering if there exists an option to avoid reference classes in logistic regression by transformation estimaters (especially the intercept)? Normally the intercept contains the information of ...
• 305
9 views

### Dice Coefficient vs *Negative* Dice Coefficient..?

While reading this paper I've noticed that they use what they call negative dice coefficient. I know that in general the dice coefficient is a metric commonly used in image segmentation tasks when we ...
• 427
8 views

### Categorical IV with probit second stage

In a panel setting, I have a binary endogenous variable $X_{ijt}$ where $i$ indexes the individual, $j$ indexes the region, and $t$ indexes the year. I have a set of mutually exclusive binary ...
24 views

### How do I model a predictor with multiple, mutually-exclusive possibilities? Specifically, type(s) of crime(s) charged at arrest

I am creating logistic regression models predicting outcomes of criminal arrest events, e.g., whether an arrestee hired a private attorney or not. My confusion concerns about 20 mutually exclusive ...
• 111
42 views

### Is there a fundamental mathematical reason that ordered factors are represented as orthogonal polynomials in linear regression?

At least for R, Chambers/Hastie write in their book "Statistical Models in S" in chapter 2.3.2 "Coding Factors by Contrasts": Ordered factors are coded so that individual ...
• 139
12 views

### Binning and WoE transformation. Reducing number of categories for high cardinality features

I'm doing a credit default risk project. I have some features like a job title that has >100000 unique titles. What is the best way to reduce cardinality in a meaningful way? The end goal is to get ...
1 vote
22 views

### Are all dummy variables stationary?

If a time series model contained only dummy variables as dependent and independent variables. Is it always stationary?
• 31
24 views

### How to interpret independent dummy variables in logistic regression?

I have both quantitative and dummy independent variables in my logistic regression. Dependent variable is binary. I have 2 questions. How to interpret a quantitative variable that is negative? How to ...
• 31
14 views

### Interpretation multiple linear regression with cumulative coding for ordinal variable

In order to do a multiple linear regression with categorical variable, I transformed them with the cumulative coding : My problem is in the interpretation of the results of the regression : from what ...
• 13
38 views

### how to interpret classes dependence that are not the reference class in a linear model

If we run the three following codes: ...
21 views

### How to add dummy variables for countries in time series data

I am running a binary logit regression. However, my independent variables consists of quantitative and dummy variables. Some of them are type of loan (5 types), loan purpose (5 types) and countries (...
• 31
33 views

### what could be wrong with a Principal Component analysis that uses regression on dummy variables? (I am not looking for workarounds) [duplicate]

I have already checked the suggested links and they do not answer my questions; my question is simple and does not need to be reinterpreted. So please do not close the question until it receives its ...
28 views

### What would we violate if we use principal component analysis on datasets containing only dummy variables?

I have 23 dummy variables that are generated through a multiple-answer question. Respondents could choose more than one option. I ran a PCA and could see meaningful components emerging. I then ...
20 views

### GMM clustering with binary and multicollinear data

I am using GMM clustering on bank data. The data have both categorical and numerical attributes. The categorical data were converted to numerical using binary encoding. I have a couple of questions: ...
1 vote
42 views

### Am I interpreting my lm() summary() results correctly in R?

(this question I originally posted in stack overflow) I want to know if I am interpreting the factor() function in R correctly. Suppose I have a variable with 10 ...
1 vote
49 views

### What type of prior to choose for one-hot encoded (dummy coded) variables in Bayesian logistic regression?

I'm going through Rethinking and Kruschke's Puppy book. After the examples I want to try myself with other data and have a problem. What if (unlike the examples in the book and online) categorical ...
• 157
9 views

### What should I do If I have 2 multi-categorical independent variables in a linear regression?

Ive been asked to perform a multiple linear regression of one dependant variable with several independent variables two of which are categorical. One has 3 options and the other has 5. I'm familiar ...
6 views

### how to select categorical variables for a multiclass logistic regression

i struggle to figure out how to turn something into a categorical variable. I have markov-chain-model with 10 states, so my transition matrix has 10 rows, 10 columns and 100 possible transitions To ...
1 vote
35 views

### Interaction between quadratic term and dummy variable

Suppose I have a linear regression: $Y=\beta_1+\beta_2X+\beta_3X^2+\beta_4D$ where $D$ is a dummy variable that takes value 0 and 1. If I want to examine if the effect of $X$ on $Y$ for $D=0$ and $D=1$...
• 13
31 views

### How to predict next occurrence in sequence where data has both numerical and categorical values?

Lets say we have the following prediction problem. Given data of the following form: Number HasProperty1 HasProperty2 1.5 0 1 1.5 0 1 2 1 0 2 1 0 Where ...
7 views

### How to select data and report a multinomial logistic regression for microbiome

recently I have been working with gut microbiome data, like abundance and its metabolic content (but for purposes of the question this may be indifferent). I'm inexpert in the field of multinomial ...
• 11
1 vote
27 views

### Too many categorical predictors in multinomial logistic regression

I am not familiar with multi-class prediction so I apologize in advance if this questions seem very basic. Here is my dataset: So within the dataset, I am trying to predict which fare product is ...
• 11
1 vote
65 views

### should I use n-1 dummies variables or all variables for a multinomial logistic regression?

Recently I have been working with gut microbiome data, like abundance and its metabolic content (but for purposes of the question this may be indifferent). I'm inexpert in the field of multinomial ...
• 11
1 vote
55 views

### Why does removing intercept not change predicition of linear model in the precence of factor predictors? [duplicate]

In a linear model that predicts birth rate (TFR) per country from per capita GDP, the country is encoded in "treatment coding", and there are several measurements (different years) per ...
• 3,006
32 views

### Missing outputs or coefficients from multiple linear regression?

I have a multiple linear regression I have completed below: ...
• 65
71 views

### Using dummy variables in a linear regression model in R - no need to manually encode when using factor or character string vector types?

A source of confusion that I often come across relates to when people want to use categorical data, where the number of categories is greater than 2, in a linear regression (simple or multiple) and ...
• 160
18 views

### Anova table for linear model, $3$ treatment groups with model $Y_i = 4+6 I_{1,i}-1 I_{2,i}$

Anova table for linear model, $3$ treatment groups with model $Y_i = 4+6 I_{1,i}-1 I_{2,i}$ where $4=B_0 = \bar Y_1$, $B_0+B_1=4+6=\bar Y_2, B_2=\bar Y_3$ and each group has a $5$ patients. The ...
18 views

### Addding a categorical variable to existing regression model generates strange coefficients

I have a regression model with numerical variables only. I created a new feature, categorical variable with options A, B, C. The means of the dependent variable are, by the categories from above are: ...
• 1
1 vote
18 views

### What is a word embedding approach that would work for these pre-labeled documents?

My Situation: I should start off with my end goal: I want to get a distance metric between each document and all of the other documents To get there, I first need to encode these topic labels so that ...
• 595
24 views

### Best way to combine categorical variables

I have two categorical variables measuring outdoor time during winter and summer. As I am interested in the overall outdoor time during the whole year, I am thinking about combining the variables. ...
362 views

### How can I mathematically represent the one-hot encoding?

If we have 5 classes and 3 inputs, let's say [C1, C2, C3, C4, C5] and [X1, X2, X3] then, If ...
1 vote
33 views

### Categorical variable with too many categories. Should I group them according to frequency or according to the target?

I am working with a dataset of flight records and I model the flight delay. I have variables for the origin and destination airport , but each of them has about 300 categories. I think about grouping ...
• 135
1 vote
48 views

### Custom-define contrast - mix between dummy and Helmert coding

I'm trying to use custom-defined contrasts. They are sort of a combination of traditional dummy coding and the last contrast produced by reversed Helmert coding. In short, I want to compare each of ...
• 153
14 views

### how to compare two variables with respect to the occurrence of an event

I have these two predictors and I want to know if individuals with predictor 1 are more likely to have the event (outcome = 1) than those with predictor 2. I want ...
• 505
49 views

### How to encode categorical data with a lot of unique values and streaming data for anomaly detection

I'm working on a Anomaly Detection problem with streaming data, where i use Robust Random Cut Forest (RRCF). I have 295.000+ rows to start with and there is more data coming in. The problem is when ...
286 views

### Target enconding in test data and target leakage

I understand target encoding, which is the average of the target value by category using out-of-fold mean within each fold. although you get slightly different means for the same value of a ...
• 231
1 vote
74 views

### Feature scaling of categorical and ordinal variables in Cox regression

I have a dataset with nominal (unorderable categories), ordinal (orderable categories), and continuous/numerical variables. I am performing Cox Proportional Hazard Regression using the scikit-survival ...
44 views

### One or multiple regression/s?

Say your equation in a paper has 6 coefficients, one being your main interest (dummy for Disability == Having at least one disability: coded 0/1). This estimation is done. BUT you want to dig deeper, ...
25 views

### Difference-in-Difference with temporary event

I am running a Diff-in-Diff analysis about the triggering of a policy that once triggered bans a certain action for 6 months. I have run the analysis considering only pre and post period, including in ...
• 133
255 views

### Is one-hot encoding required for categorical variables in R (logistic regression)?

I created a logistic regression model in R and fit the model using the MumIn package. I have several categorical variables that were coded as factors. For example, season (summer, fall, winter, spring)...
• 19
20 views

### One-way categorical vs. dummy-variable model: Same data, different coefficients and F-values

I am interested in seeing whether treatments interact in a fully factorial design with three treatments. Slinker 1998 recommends running a three-way ANOVA on a model that considers each treatment ...
27 views

### Does the 15:1 rule in multiple linear regression apply at the beginning, or to your final reduced model?

I've read that there are recommendations about how many outcome observations you need per predictor variable in multiple linear regression (often 15:1 or 10:1). I have a dataset with lots of different ...
9 views

### Dummy coding with overlapping categories

Spotify has a structured dataset which contains song tracks with its associated audio features such as energy, speechiness (numeric data), whether there is explicit language in the lyrics (boolean), ...
1 vote
21 views

### Categorical variable perfectly maps to continuous variable

I have a feature vector X in a regression problem, where one of the features X1 is categorical (genre) with 47 categories. There is also another feature X2 which is continuous (# subscribers) but ...
21 views

### Coding independent variable for regression based on relationship with dependent variable and reducing dimensionality

I have a table where rows are dates and columns are values of a dependent and many independent variables. I want to create regression with a number of nominal and ordinal independent variables to ...
• 1
11 views

### Coding via vectors of $K$ dummy variables or bits: How exactly does this work? [duplicate]

Chapter 2.2 Variable Types and Terminology of the textbook The Elements of Statistical Learning, second edition, by Hastie, Tibshirani, and Friedman, says the following: Qualitative variables are ...
• 1,096
1 vote