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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 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 ...
user avatar
1 vote
1 answer
81 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$...
user avatar
  • 13
0 votes
0 answers
85 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 ...
user avatar
0 votes
0 answers
14 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 ...
user avatar
  • 11
1 vote
1 answer
38 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 ...
user avatar
  • 11
1 vote
1 answer
122 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 ...
user avatar
  • 11
1 vote
2 answers
69 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 ...
user avatar
  • 3,211
0 votes
0 answers
105 views

Missing outputs or coefficients from multiple linear regression?

I have a multiple linear regression I have completed below: ...
user avatar
  • 65
0 votes
1 answer
314 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 ...
user avatar
0 votes
0 answers
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 ...
user avatar
0 votes
0 answers
24 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: ...
user avatar
  • 1
1 vote
0 answers
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 ...
user avatar
0 votes
0 answers
31 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. ...
user avatar
4 votes
1 answer
424 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 ...
user avatar
1 vote
1 answer
85 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 ...
user avatar
  • 137
1 vote
1 answer
54 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 ...
user avatar
  • 153
0 votes
0 answers
17 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 ...
user avatar
0 votes
0 answers
91 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 ...
user avatar
4 votes
2 answers
702 views

Target encoding 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 ...
user avatar
  • 243
1 vote
1 answer
189 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 ...
user avatar
0 votes
1 answer
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, ...
user avatar
  • 1
0 votes
1 answer
38 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 ...
user avatar
  • 143
0 votes
1 answer
619 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)...
user avatar
  • 19
0 votes
0 answers
23 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 ...
user avatar
0 votes
0 answers
36 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 ...
user avatar
0 votes
0 answers
11 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), ...
user avatar
  • 1
1 vote
1 answer
26 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 ...
user avatar
0 votes
0 answers
25 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 ...
user avatar
  • 1
0 votes
0 answers
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 ...
user avatar
  • 1,126
1 vote
1 answer
63 views

Interpretation of two dummies interacted with one continuous variable

I am currently looking at the following equation using Stata and unsure of how to interpret the interaction terms when there are three variables interacted together (2 binary variables and one ...
user avatar
  • 11
3 votes
2 answers
411 views

Why are models based on coded (-1,1 etc) and non-coded variables (as they are) very different? What should I use for publications?

I am doing factorial experiments in R. I noticed when I use my variables as they are vs. coding them into -1,1, they are all very different. Here is my sample code. ...
user avatar
0 votes
0 answers
327 views

Dummy variables in a fixed effects model

I'm currently working on the correlation between sustainability and performance in the S&P500. I'm using a panel data model, with fixed effects for both, ime and firm. I wanted to insert a sector ...
user avatar
0 votes
0 answers
145 views

Missforest imputation algorithm and categorical variables

I am trying to implement MissForest imputation algorithm on a data set of mostly categorical variables. I've run into the problem however of not knowing whether to use one-hot-encoding or label ...
user avatar
  • 103
1 vote
1 answer
259 views

How to decide on encoding high cardinality variables for a small dataset?

I already referred the posts here, here, here, here, here etc. Don't mark as duplicate please. I have a dataset with 1008 rows with 16 input variables and 1 target variable. However, 14 of my input ...
user avatar
  • 1,932
1 vote
3 answers
89 views

Feature not applicable to some samples

I am working with a private medical dataset including categorical features coming from patients examinations. However, the problem is that some patients underwent MRI, others scanner, and some ...
user avatar
  • 31
0 votes
0 answers
45 views

Comparing non-reference groups with each other in regression-based methods

I am running several multi-level models. The multilevel aspect is not that important here though, this question would be the same even if it was simple regression. Basically, randomly assigned ...
user avatar
  • 1
0 votes
0 answers
120 views

Best practice for cyclical feature encoding for tree-based methods

Right now I'm facing a dataset of professional road cyclists which contains training data of the athletes at different dates over two years. For some tree-based methods I'm still looking for a 'best ...
user avatar
  • 218
0 votes
1 answer
77 views

Dummy variable's p value interpretation

I have a question related to the significance of the dummy variable. Some background context: I am writing my thesis and I have hypothesized the following. My first hypothesis hypothesizes that the ...
user avatar
  • 1
0 votes
0 answers
30 views

Panel regression rank variable instead of dummy set

Suppose I have the following (panel) regression equation: $$y_{i, t} = \alpha + \mathbf{x_{i,t}}'\mathbf{\beta} +\epsilon_{i,t},$$ where $y_{i,t}$ denotes the wealth of individual $i$ at time $t$, and ...
user avatar
  • 193
0 votes
1 answer
31 views

How do I interpret price elasticity when using state specific dummies and price, dummy interaction

I have price volume data for 3 states for which I want to calculate price elasticity for each state. The model has the following setup: $$ \ln(Y)=A_1+ A_2\ln(P) +A_3D_1 +A_4D_2+ A_5\ln(P)D_1 +A_6\ln(P)...
user avatar
  • 1
1 vote
1 answer
237 views

Interaction effects in regression models - should I include reference category?

I have a question about coding interaction effects using dummy coding which I’d be really grateful for your advice on please. Imagine I want to design an experiment to measure the impact of amount of ...
user avatar
2 votes
1 answer
70 views

Outcome variable coding for multinomial logistic regression with "I don't know" choice option

I have a categorical outcome variable "Type of intervention" with 3 levels: "Type A", "Type B", & "cannot decide". The "cannot decide" option is ...
user avatar
0 votes
1 answer
619 views

Interpreting GLM output with categorical data

I am having trouble identifying which reference level R is using for my response variable matnew. I know it sometimes chooses alphabetically, which in this case is "Fail", but I'm not sure ...
user avatar
  • 21
0 votes
0 answers
50 views

Can you combine multiple categories for the interaction terms to reduce the number of them?

I have been asked to a develop linear regression model for trip rates using a categorical variable with 5 levels, a continuous variable and an interaction between them. I've included the categorical ...
user avatar
  • 1
0 votes
0 answers
40 views

Advice for how to approach encoding non-numerical data

I have a dataset where the task is to classify whether someone looking for a new job will leave their current job, based on a number of factors. (dataset: https://www.kaggle.com/arashnic/hr-analytics-...
user avatar
0 votes
0 answers
71 views

Dummy variables in LASSO

When doing OLS, we usually drop a dummy level in each category (if we are including the intercept) to avoid the dummy variable trap, i.e. multicollinearity, which would make the OLS estimator ill ...
user avatar
0 votes
1 answer
221 views

Difference-in-Difference with two control groups and one treatment group over the same period of time using RStudio

So I'm trying to run a regression for one of my economics classes with one treatment group and two control groups over a period of time. I'm currently trying to create a dummy (binary) variable to ...
user avatar
0 votes
0 answers
35 views

Can I just use one effect-coded variable instead of two dummy variables when I perform a regression, if there are 3 groups?

To make things simple, let say I ran a basic psychometric experiment and I want to test whether the response time (i.e. a continuous variable) can predict the performance score (i.e. a continuous ...
user avatar
0 votes
0 answers
51 views

Framework for applying weights to binary variables in regression

Say I am training a ridge regression model on nothing but binary variables. The context being that each variable represents a player - a value of 1 meaning they were playing the game at the time, ...
user avatar
0 votes
0 answers
18 views

Coefficient testing for linear regression: multiple categorical variables

Assume that I am interested in performing a between group comparison for a given variable but I know that this $y$ variable is confounded by at least a couple of other variables. Say, $y = Device_1 + ...
user avatar
  • 165

1
2
3 4 5
15