Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
1answer
19 views

Multiple regression with a odd-numbered Likert items

In the questionnaire, individuals were asked to pick from an odd number of options (5 or 7) how much they agree with the statement (from completely agree to completely disagree). Now, if there where ...
0
votes
0answers
12 views

WoE of test dataset

How to encode the categorical data to Weight of Evidence in the test dataset? I am interested to know about how to handle the categories which are not present in the training set.Or should we combine ...
1
vote
1answer
15 views

Transforming categorical variables

Can someone explain me in which cases is a good idea to convert a categorical variable to numerical in order to used it in our model (either regression or classification). I have seen cases where even ...
0
votes
1answer
33 views

Linear Regression in R: factor or z-standardise dichotomous variables

How should one handle dichotomous variables in a linear regression? Is it better to z-standardise or is it better to use factors? For example I have data of an Experiment with a 2x2 Design in which ...
0
votes
1answer
37 views

General Linear Model applied to binary data

So here I am studying regression analysis. As an assignment, I have been asked to obtain some binary data, simulate its behavior from some sample of it and apply the resulting general linear model to ...
2
votes
1answer
23 views

Does dummy code a variable affect the intercept in a linear regression model

My colleague and I were both using R to fit a linear regression with the same dataset and same variables. The outcome variable is test grade while the independent variables are gender, age, and times ...
3
votes
1answer
69 views

“Joint” dummy variables for two different variables

I am supposed to show the hazard ratio (HR) stratified by gender (1= female vs. 2= male) and age groups (quartiles, 1-4)*. The combination "female" and "first quartile of age" is supposed to be the ...
0
votes
0answers
11 views

Should one hot encoding be done on Likert scale ratings?

This seems like an easy question but I haven't been able to find a definitive source for this or questions that address this topic directly. When applying a classification algorithm, should you apply ...
0
votes
1answer
13 views

h2o glm tweedie for categorical variables

To build a tweedie glm for categorical variables, the document suggested that I can use data['variable_name'].asfactor(). However, in the model output, there is no reference level, i.e., if I have ...
0
votes
0answers
11 views

Interpreting findings of moderation using PROCESS Macro

I have recently conducted a moderation analysis using the PROCESS Macro plug-in for SPSS. I have tested the moderation effect of W (categorical using dummy variables) on the relationship between X (...
0
votes
3answers
51 views

Does Categorical Variable need normalization/standardization?

since we do normalize as 10kg >>> 10 grams or 1000 >> 10. so incase of one hot encoding eg male=0 and female =1, are we giving more weight to female as 1>0 for training our models?
1
vote
0answers
18 views

Dummy variable reference category

As part of my thesis, I am exploring the effect of firm owner type on research and development, which is a ratio. I have a dummy variable of company owner type with 10 categories e.g. Bank, ...
1
vote
0answers
26 views

Is there a theoretical basis for using partial least squares with categorical responses

I am using what is called PLS-DA in JMP to find a model for predicting a categorical (Positive/Negative) response. The documentation says that the responses are simply coded as 0/1, thereby ...
0
votes
0answers
20 views

How to deal with a potentially multiple categorical variable

I'm building a model that has, as inputs, some categorical variables. I had already dealt with this sort of data before, and applied different techniques as creation of dummy variables and factor ...
1
vote
1answer
23 views

In the summary of output of the regression analysis in R, is there a way to display categorical variable with just one coefficient [closed]

I am doing a linear regression analysis in R with logarithmic dependent variable. One of the control variables is categorical and describes an industry. There are 6 industries and thereby R ...
0
votes
0answers
38 views

How do you run a regression when categorical variables may be involved, using R?

I have a data set with several categorical and quantitative variables. Say A, B, and C are categorical with several levels, X and Y are quantitative. I know that X ~ A will basically just be a ...
0
votes
2answers
22 views

Can a dummy variable be used to correct ARCH?

Is it possible to use a dummy variable to allow for a structural break, in order to correct Autoregressive Conditional Heteroscedasticity?
0
votes
0answers
27 views

Linear Regression and High Dimensional Categorical Data

I've read that mean encoding is useful for classification tasks with high dimensional categorical data. My question: What kinds of encodings are effective for high dimensional categorical data in ...
0
votes
0answers
23 views

Dropping One-hot-encoded columns in Pandas/Sklearn

When one-hot-encoding categorial features in python with pandas or sklearn, when should I drop one of the resulting columns? I recall something about having all columns present being a problem for ...
0
votes
0answers
17 views

Finding the fitted probability for an aliased constraint in a binomial model?

For a binomial model, with probit link function: model = glm(response~A+B+C, family = binomial("probit"), na.action = na.omit) where A and B are continuous, C is ...
0
votes
1answer
31 views

Can you use two dummy variables?

Is it possible to use two dummy variables for breakpoints in a linear regression? In EViews I've created the following: ls log(consumption) c log(gdp) log(gdp(-1)) log(consumption(-1)) @year>1989 @...
0
votes
0answers
45 views

Target Encoding: missing value imputation before or after encoding

I want to perform a target encoding for my categorical features although I am not sure when to perform the data imputation if any of them has missing values. Let's say I have a few continuous features,...
2
votes
0answers
9 views

estimation inter rater reliability for strings of characters (i.e. URLs)

I have multiple raters extracting URLs from the internet based on search terms. The core issue is that a URL amounts to a string wherein two raters might come to the same URL but one string is a ...
0
votes
0answers
10 views

Influence of neighbouring characters on a given position

I have 10,000 fixed length strings of DNA sequences. An example would be ATTGGGT M GCGGCTG. Now the character marked M is a position of interest to me (say something that causes diseases). ...
0
votes
1answer
37 views

Multinomial logistic regression reference category function

Bit of background info on the data and methods that I've used. I have a forest road data that consists of one dependent variable which has 4 classes (0-3). The Dependent variable reflects possibility ...
2
votes
1answer
21 views

interpreting coefficients of interaction terms between categorical variables [closed]

Assuming I have a linear regression model of the form: Y = a + (b1*fact1) + (b2*fact2) + b3*(fact1*fact2) + b4*other_var where, fact1, fact2 are categorical variables of 2 factors each, YES and NO ...
0
votes
1answer
11 views

Heterogenous effects in DID models

I am working on a standard DID research design where all the assumptions are met - focused on a policy reform affecting a number of sectors in a country. I would like to improve the design by ...
0
votes
0answers
28 views

Model failed to converge in lme4::glmer() when the a factor is centered or releveled

I'm running a mixed-effects model using glmer() function. The modeling works well with R's default dummy coding. But if I center or relevel a factor of 2 levels, the model failed to converge. I am ...
0
votes
0answers
8 views

Regression analysis incorporating the investment grade status of event country and non-event country

I am conducting a regression analysis estimating the impact of event-country credit ratings on the CDS spreads of non-event countries. As of now the current formula looks like this: 'pct_chg_-1_1 ~ ...
0
votes
1answer
47 views

Manually setting reference levels in glm of categorical variables

I have a data set with variables that have 3 or more levels for example pen size: small, medium, large. I know that if you don't set a reference level, r will just pick one and then compare the other ...
2
votes
1answer
131 views

Is one-hot encoding and standardization of data equivalent to Gower's distance?

For clustering and other techniques for mixed data (numerical and categorical), Gower's distance is usually more preferred than Euclidean distance because the former computes distance differently for ...
0
votes
1answer
37 views

Dummy variables in equation? [closed]

I have a model equation with 10 year and 10 industry dummies. In equation, it will look like this: year$_1$ year$_2$ ... year$_10$ ind$_1$ ind$_2$ .... ind$_{10}$ which is too long to write out. Is ...
4
votes
1answer
120 views

When is deviation coding useful?

After many years of learning about contrasts in linear models I am curious about the relative usefulness of deviation coding, as it is defined by this website. I would appreciate someone filling me in ...
0
votes
1answer
20 views
0
votes
0answers
10 views

Problem with reference category after survSplit in Cox regression

I have two covariates in a survival data, Acet with four factor and Age as a continuous variable. I want category AAA to be the reference in the covariate Acet. Normal Cox regression is fine: ...
0
votes
0answers
15 views

Obtaining the fitted values of main effects and interactions when GLM coding is used

In short, I need to decompose the fitted values obtained from ANOVA into components corresponding to each term in ANOVA statement. This problem appears trivial, but it becomes tricky when GLM coding ...
1
vote
0answers
42 views

Dummy variables with dummyVars() - return to original columns [closed]

For building a machine learning model I used dummyVars() function to create the dummy variables for building a model. ...
0
votes
1answer
43 views

What would be the appropriate statistical test for my study?

What would be the appropriate test for a study that has: 2 categorical independent variables with 2 levels each, 1 moderator variable (and would it matter if my moderator is categorical or continuous?...
1
vote
1answer
20 views

Given two features, one a string and other a categorical, what are the encoding rules?

I have two features in my dataset I'm using to help predict a binary outcome. Based on my features, I'm trying to figure out which I need to drop a dummy to avoid the dummy trap. One feature is a ...
1
vote
0answers
63 views

Dummy variables in Johansen cointegration analysis

I am doing cointegration analysis (all my macroeconomic series are I(1)). In addition, I want to include in all my cointegration analysis a dummy variable indicating the years where there were ...
1
vote
0answers
7 views

Can and should you avoid implicit pretesting for differences in group means?

Suppose I have a population with four (or more) disjoint sub-populations which differ from one another by traitishness, the union of which is the whole population. I have an outcome measure on the ...
0
votes
1answer
19 views

Weird prediction with binary classification on unseen textual data

I try to solve a problem which looks really simple. However I meet an obstacle and get stuck. I have a corpus of texts. I have to assign 0 to 1 to them (appropriate or not). There are a lot of ...
1
vote
3answers
114 views

Multiple regression with dummy variables and interaction term

We have done a multiple regression analysis to see how gender and experience affect salary. We used a dummy variable for gender and then we also added the interaction variable (female work experience)....
0
votes
1answer
17 views

Differences between Wald Statistics and P-values obtained with Dummy Coding vs. Direct Coding in Cox Models

Using the larynx dataset (source: Survival Analysis Techniques for Censored and Truncated Data) to illustrate, supposing you want to estimates the hazard rates of event for stages 2 and stages 3 ...
0
votes
0answers
26 views

How to code a categorical variable for logistic regression with overlap in the categories/subgroups?

Suppose I have a categorical variable consisting of four levels: a, b, c, and d. When these levels are mutual exclusive, I would use dummy coding - so three dummies with for example level a as ...
0
votes
1answer
53 views

One-hot-encoding gives untractable amount of classes

I'm performing regression on the price of bycicles based on their brand, model and submodel. These features are hierarchical: one model belongs only to one brand but one brand can have many models. ...
0
votes
1answer
31 views

Question about making prediction with only two variables

I have a data set with only two variables, student id and book id. I have train and test sets and I will make prediction about what book student will get next time. Should I attach dummy variables to ...
1
vote
1answer
68 views

(Low cardinality) categorical features handling in gradient boosting libraries

In some popular gradient boosting libraries (lgb, catboost), they all seems like can handle categorical inputs by just specifying the column names of the categorical features, and pass it into a ...
0
votes
0answers
26 views

Assess impact on results of participants recruited via additional outreach efforts

I am currently working on a project that evaluates certain study recruitment strategies in regards of increasing participation among different subgroups. One of those strategies is reminder letters. ...
1
vote
4answers
262 views

Regression with Lots of Categorical Variables

I'm facing a regression task with many categorical and few numeric features. I encoded them into dummies and removed the first dummy column for each feature. I am not getting very good R2 at all. I ...