Dummy or indicator variables are used to include categorical or qualitative variables in a regression model.
Questions tagged [dummy-variable]
868 questions
-1
votes
3 answers
Should I change my object variables to integers or create dummy variables?
I am trying to create a model to predict whether or not someone is at risk of a stroke. My data contains some "object" variables that could easily be coded to 0 and 1 (like sex). However, I have some object variables with 4+ categories (e.g. type…

Kevin
- 1
-1
votes
1 answer
convert a column of list to dummies by group not character
I've tried two things so far without luck to convert column values to dummies.
Data
So I'm trying to dummify personal interests.
uf = uf['personal_interests'].str.join('|').str.get_dummies()
print(uf)
or
mlb =…

Rob
- 21
- 5
-1
votes
1 answer
Creating dummy variables as counts using tidyverse/dplyr
Let's say I have some data as follows:
ID FRUIT
001 apple
002 grape
001 banana
002 apple
003 apple
001 apple
I would like to make columns out of this, like dummy variables. Except the dummies are counts of the variable in the FRUIT…

John Thomas
- 1,075
- 9
- 32
-1
votes
1 answer
Error concerning decimal specification when creating a dummy variable in SAS
I am very new to SAS and want to create a simple dummy variable (MALE) that equals 1 if SEX = 1, and equals 0 if SEX = 2. However, I get error messages: ERROR: The decimal specification of 2 must be less than the width specification of 1.
How do I…

Peter Jordanson
- 39
- 3
-1
votes
1 answer
Creating dummy variable based on value counts in a function
I'm trying to assign 0 to string that is more frequent and 1 to less frequent string in a function. My idea is that it should take any column with binary string and based on value count assign 0 and 1. How can i do that?
data =…
-1
votes
2 answers
combining multiple items to create one dummy variable
I have 7 items/variables in Stata that address the same survey question. These 7 items are each different weight control behaviors (diet, exercise, pills, etc.). I am trying to combine these variables to create a single weight control behavior…

Radhika Prasad
- 3
- 2
-1
votes
1 answer
Scatterplot with multi variables
Scatterplot reference
data set
Can someone help me create three scatter plots as in the first picture? Ideally using the plot() function.

Genetic
- 3
- 1
-1
votes
1 answer
Create dummy variable for all neighborhood region depending on another dummy variable (sf object)
I have a spatial dataframe (sf) of all European NUTS2 regions. Within this sf object certain regions have a dummy = 1, and others a dummy = 0.
How can I create a new dummy (lets say "dummy_neighbor") where all the neighboring (st_touches?) regions…

Tom
- 25
- 5
-1
votes
2 answers
Create column for mean of another column, filtered after a dummy variable
My table looks (simplified) like this:
| countrycode | year | dummy | Value
| "AUS" | 2008 | 1 | -3
| "AUS" | 2009 | 0 | -2
| "BEL" | 2008 | 0 | -5
| "BEL" | 2009 | 1 | -1
| "BEL" | 2010 | 1 | -2
| "BEL" | 2011 | 1 | -1
| "CAN" | 2008 | 0 |…

Passiv
- 1
- 1
-1
votes
3 answers
create dataframe with dummies
I am new to R and I have a problem at hand. I basically want to create a dataframe that contains a dummy variable for every year somebody has had a house. 0 for every year he did not sell, and 1 for the year he did sell. Next to this I need the year…

BeginnerinRstudio
- 13
- 6
-1
votes
2 answers
Why these Python codes fail in building a dummy variable?
I have the following dataframe:
df = pd.DataFrame.from_dict({'Date': {0: '2021-01-01 00:00:00',
1: '2021-01-02 00:00:00',
2: '2021-01-03 00:00:00',
3: '2021-01-04 00:00:00',
4: '2021-01-05 00:00:00',
5: '2021-01-06 00:00:00',
6:…

Rollo99
- 1,601
- 7
- 15
-1
votes
3 answers
How to create a new variable that shows different combinations of 4 dummy variables?
I have 4 dummy variables taking values 0 or 1 corresponding to the adoption or not of a certain technology. The data frame has over 14000 rows.
I want to loop over these 4 columns to give me the different combinations of == 1 into a new…

lorlu
- 3
- 3
-1
votes
1 answer
Dummy variable is not created
I am facing a problem while creating a dummy variable There is a problem with the 'town' column.
it's giving a key error but my syntax is correct.
please help me I didn't understand what is the problem even I am correct from my side.
import pandas…

SAURABH SINGH
- 1
- 3
-1
votes
1 answer
Anomaly Testing - Linear Regression with t or not with t? Problems to understand the setup
If you want to check an anomaly in stock data many studies use a linear regression. Let's say you want to check if there is a Monday effect, meaning that monday is significantly worse than other days.
I understood that we can use a regression like:…

Poldi
- 29
- 3
-1
votes
1 answer
Replace dummy values in multiple columns with corresponding string values from another pandas dataframe
I have two pandas dataframes with the second having dummy values I pulled from the first, like so:
df1
Col_0 Col_1 Col_2 Col_3 ...Col_27
0 A 535 C Mission
1 A 536 C Mission
2 A 541 C …

iron502
- 47
- 7