Questions tagged [categorical-data]

Categorical (also called nominal) data can take on a limited number of possible values called categories. Categorical values "label", they do not "measure". Please use [ordinal-data] tag for discrete but ordered data types.

Filter by
Sorted by
Tagged with
150
votes
6answers
147k views

Can principal component analysis be applied to datasets containing a mix of continuous and categorical variables?

I have a dataset that has both continuous and categorical data. I am analyzing by using PCA and am wondering if it is fine to include the categorical variables as a part of the analysis. My ...
124
votes
6answers
238k views

Correlations with unordered categorical variables

I have a dataframe with many observations and many variables. Some of them are categorical (unordered) and the others are numerical. I'm looking for associations between these variables. I've been ...
78
votes
1answer
158k views

Correlation between a nominal (IV) and a continuous (DV) variable

I have a nominal variable (different topics of conversation, coded as topic0=0 etc) and a number of scale variables (DV) such as the length of a conversation. How can I derive correlations between ...
59
votes
6answers
14k views

Principled way of collapsing categorical variables with many levels?

What techniques are available for collapsing (or pooling) many categories to a few, for the purpose of using them as an input (predictor) in a statistical model? Consider a variable like college ...
57
votes
8answers
41k views

Does it ever make sense to treat categorical data as continuous?

In answering this question on discrete and continuous data I glibly asserted that it rarely makes sense to treat categorical data as continuous. On the face of it that seems self-evident, but ...
52
votes
1answer
38k views

One-hot vs dummy encoding in Scikit-learn

There are two different ways to encoding categorical variables. Say, one categorical variable has n values. One-hot encoding converts it into n variables, while dummy encoding converts it into n-1 ...
47
votes
7answers
49k views

Graph for relationship between two ordinal variables

What is an appropriate graph to illustrate the relationship between two ordinal variables? A few options I can think of: Scatter plot with added random jitter to stop points hiding each other. ...
47
votes
4answers
14k views

What is a contrast matrix?

What exactly is contrast matrix (a term, pertaining to an analysis with categorical predictors) and how exactly is contrast matrix specified? I.e. what are columns, what are rows, what are the ...
42
votes
5answers
166k views

Correlations between continuous and categorical (nominal) variables

I would like to find the correlation between a continuous (dependent variable) and a categorical (nominal: gender, independent variable) variable. Continuous data is not normally distributed. Before, ...
41
votes
5answers
70k views

Warning in R - Chi-squared approximation may be incorrect

I have data showing fire fighter entrance exam results. I am testing the hypothesis that exam results and ethnicity are not mutually independent. To test this, I ran a Pearson chi-square test in R. ...
37
votes
6answers
65k views

Improve classification with many categorical variables

I'm working on a dataset with 200,000+ samples and approximately 50 features per sample: 10 continuous variables and the other ~40 are categorical variables (countries, languages, scientific fields ...
37
votes
2answers
31k views

Multinomial logistic regression vs one-vs-rest binary logistic regression

Lets say we have a dependent variable $Y$ with few categories and set of independent variables. What are the advantages of multinomial logistic regression over set of binary logistic regressions (i....
30
votes
1answer
40k views

Doing principal component analysis or factor analysis on binary data

I have a dataset with a large number of Yes/No responses. Can I use principal components (PCA) or any other data reduction analyses (such as factor analysis) for this type of data? Please advise how I ...
26
votes
4answers
55k views

Predicting with both continuous and categorical features

Some predictive modeling techniques are more designed for handling continuous predictors, while others are better for handling categorical or discrete variables. Of course there exist techniques to ...
25
votes
3answers
43k views

Interpreting interaction terms in logit regression with categorical variables

I have data from a survey experiment in which respondents were randomly assigned to one of four groups: ...
24
votes
1answer
46k views

Regression with only categorical variables

Is it possible to conduct a regression if all dependent and independent variables are categorical variables?
24
votes
3answers
7k views

Is hour of day a categorical variable?

Is "hour of the day" where the value can be 0, 1, 2, ..., 23 a categorical variable? I would be tempted to say no, since 5, for example, is 'closer' to 4 or 6 than it is to 3 or 7. On the other hand,...
24
votes
1answer
5k views

How to visualize an enormous sparse contingency table?

I have two variables: Drug Name (DN) and corresponding Adverse Events (AE), which stand in a many-to-many relation. There are 33,556 drug names and 9,516 adverse events. The sample size is about 5.8 ...
22
votes
3answers
22k views

Negative binomial distribution vs binomial distribution

What is the difference between the negative binomial distribution and the binomial distribution? I tried reading online, and I found that the negative binomial distribution is used when data points ...
22
votes
3answers
28k views

Why do we need to dummy code categorical variables

I am not sure why we need to dummy code categorical variables. For instance, if I have a categorical variable with four possible values 0,1,2,3 I can replace it by two dimensions. If the variable had ...
21
votes
8answers
24k views

How can you visualize the relationship between 3 categorical variables?

I have a dataset with three categorical variables and I want to visualize the relationship between all three in one graph. Any ideas? Currently I am using the following three graphs: Each graph is ...
21
votes
1answer
9k views

Dropping one of the columns when using one-hot encoding

My understanding is that in machine learning it can be a problem if your dataset has highly correlated features, as they effectively encode the same information. Recently someone pointed out that ...
20
votes
1answer
51k views

Regression for categorical independent variables and a continuous dependent one

I just realized I have always worked regression problem where the independent variables were always numerical. Can I use linear regression in the case where all independent variables are categorical?
19
votes
2answers
45k views

Significance of categorical predictor in logistic regression

I am having trouble interpreting the z values for categorical variables in logistic regression. In the example below I have a categorical variable with 3 classes and according to the z value, CLASS2 ...
19
votes
5answers
32k views

What is the best way to visualize relationship between discrete and continuous variables?

What is the best way to show a relationship between: continuous and discrete variable, two discrete variables ? So far I have used scatter plots to look at the relationship between continuous ...
19
votes
5answers
31k views

How do I study the “correlation” between a continuous variable and a categorical variable?

What's a meaningful "correlation" measure to study the relation between the such two types of variables? In R, how to do it?
19
votes
5answers
23k views

How to recode categorical variable into numerical variable when using SVM or Neural Network

To use SVM or Neural Network it needs to transform (encode) categorical variables into numeric variables, the normal method in this case is to use 0-1 binary values with the k-th categorical value ...
19
votes
4answers
6k views

With categorical data, can there be clusters without the variables being related?

When trying to explain cluster analyses, it is common for people to misunderstand the process as being related to whether the variables are correlated. One way to get people past that confusion is a ...
18
votes
4answers
2k views

Non-transitivity of correlation: correlations between gender and brain size and between brain size and IQ, but no correlation between gender and IQ

I found a following explanation on a blog and I would like to get more information about the non-transitivity of correlation: We have the following indisputable facts: On average, there is ...
18
votes
1answer
38k views

How to test the statistical significance for categorical variable in linear regression?

If in a linear regression I have categorical variable... how do I know the stastical signifance of the categorical variable? Let's say the factor $X_1$ has 10 levels... there will be 10 different ...
18
votes
2answers
20k views

Interpretation of betas when there are multiple categorical variables

I understand the concept that $\hat\beta_0$ is the mean for when the categorical variable is equal to 0 (or is the reference group), giving the end interpretation that the regression coefficient is ...
18
votes
1answer
27k views

How to deal with an SVM with categorical attributes

I have a space of 35 dimensions (attributes). My analytic problem is a simple classification one. Out of 35 dimensions, more than 25 are categorical and each attribute takes more than 50+ types of ...
18
votes
5answers
62k views

What summary statistics to use with categorical or qualitative variables?

Just to clarify, when I mean summary statistics, I refer to the Mean, Median Quartile ranges, Variance, Standard Deviation. When summarising a univariate which is categorical or qualitative, ...
18
votes
3answers
711 views

Is building a multiclass classifier better than several binary ones?

I need to classify URLs into categories. Say I have 15 categories that I'm planning to zero down every URL to. Is a 15-way classifier better? Where I have 15 labels and generate features for each ...
18
votes
2answers
6k views

Anomaly Detection with Dummy Features (and other Discrete/Categorical Features)

tl;dr What is the recommended way to deal with discrete data when performing anomaly detection? What is the recommended way to deal with ...
17
votes
2answers
19k views

Qualitative variable coding in regression leads to “singularities”

I have an independent variable called "quality"; this variable has 3 modalities of response (bad quality; medium quality; high quality). I want to introduce this independent variable into my multiple ...
17
votes
2answers
4k views

Alternative to sieve / mosaic plots for contingency tables

I once stumbled across a type of plot for categorical data (i.e., contingency tables) on the internet, which I really liked, but I've never found it again, and I don't even know what it's called. It ...
17
votes
2answers
8k views

Feature importance with dummy variables

I am trying to understand how I can get the feature importance of a categorical variable that has been broken down into dummy variables. I am using scikit-learn which doesn't handle categorical ...
17
votes
1answer
4k views

How to treat categorical predictors in LASSO

I am running a LASSO that has some categorical variable predictors and some continuous ones. I have a question about the categorical variables. The first step I understand is to break each of them ...
16
votes
2answers
7k views

Is it possible to create “parallel sets” plot using R?

Thanks to Tormod question (posted here) I came across the Parallel Sets plot. Here is an example for how it looks: (It is a visualization of the Titanic dataset. Showing, for example, how most of ...
15
votes
2answers
20k views

Mixing continuous and binary data with linear SVM?

So I've been playing around with SVMs and I wonder if this is a good thing to do: I have a set of continuous features (0 to 1) and a set of categorical features that I converted to dummy variables. ...
15
votes
2answers
6k views

“Dummy variable” versus “indicator variable” for nominal/categorical data

"Dummy variable" and "indicator variable" are labels frequently used terms to describe membership in a category with 0/1 coding; usually 0: Not a member of category, 1: Member of category. On 11/26/...
14
votes
3answers
6k views

Why is correlation not very useful when one of the variables is categorical?

This is a little bit of a gut check, please do help me see if I'm misunderstanding this concept, and in what way. I have a functional understanding of correlation but I'm feeling a little grasping-at-...
14
votes
2answers
1k views

Is going from continuous data to categorical always wrong?

When I read about how to setup your data, one thing I have often come across is that transforming some continuous data into categorical data is not a good idea, since you may very well make the wrong ...
14
votes
2answers
17k views

How to do regression with effect coding instead of dummy coding in R?

I am currently working on a regression model where I have only categorical/factor variables as independent variables. My dependent variable is a logit transformed ratio. It is fairly easy just to run ...
14
votes
2answers
4k views

Methods for merging / reducing categories in ordinal or nominal data?

I'm struggling to find a method for reducing the number of categories in nominal or ordinal data. For example, let's say that I want to build a regression model on a dataset that has a number of ...
14
votes
1answer
10k views

Is it OK to mix categorical and continuous data for SVM (Support Vector Machines)?

I have a dataset like ...
14
votes
1answer
957 views

What are the different types of codings available for categorical variables (in R) and when would you use them?

If you fit a linear model or a mixed model there are different types of codings available to transform a categorical or nominal varibale into a number of variables for which paramaters are estimated, ...
13
votes
2answers
24k views

How to transform ordinal data from questionnaire into proper interval data?

Are there any straightforward methods of transforming ordinal level data into interval level (just as there are for doing it the other way round)? And performable in Excel or SPSS? Having the data, ...
13
votes
4answers
7k views

How to summarize categorical data?

I've been struggling with the following problem with hopefully is an easy one for statisticians (I'm a programmer with some exposure to statistics). I need to summarize the responses to a survey (for ...