Dummy or indicator variables are used to include categorical or qualitative variables in a regression model.
Questions tagged [dummy-variable]
868 questions
0
votes
1 answer
Create holiday dummy variable in weekly data based on the Date column where Date represents end of week
DF has end of week dates.
df <- data.frame(Date=seq(as.Date("2014-01-03"), as.Date("2020-12-25"), by="week"))
df$week <- seq(nrow(df))
df <- df[, c("week", "Date")]
head(df)
#> week Date
#> 1 1 2014-01-03
#> 2 2 2014-01-10
#> 3 3…

khelytics
- 11
- 4
0
votes
1 answer
Adding a vector of dummy variables in logistic regression
I am currently trying to conduct logistic regression where one of the variables is a vector of 32 dummy variables. Each dummy represents a type of crime. For example:
narcotics <- ifelse(train$PRIMARY.DESCRIPTION == "NARCOTICS", 1,0)
Then the…
user8276807
0
votes
2 answers
Dummy variable for year in R
So my data set consists 7 variables and one of them is date from 2004 to 2008, and I want to create a dummy variable for the year of 2008. Specifically, I want to know what happened before 2008 and after and have levels 0 and 1, but I don't know how…

Elen
- 3
- 4
0
votes
2 answers
R glm regression not including several dummy variables
I have a data set (acs_hh) in which one of the columns is race_eth.
For the following regression:
reg <- glm(acs_hh$own ~ acs_hh$hhincome + acs_hh$race_eth, family = "binomial")
summary(q7reg)
However, in my data there exist more than just the…

Henry Walsh
- 135
- 2
- 7
0
votes
2 answers
How to turn multiple dummy vars into 1 factor variable?
I have a huge data set from a survey with loads of statements that are dummy variables. Each dummy is a factor with levels "quoted" and "not quoted". Since different groups of statements belong to the same topic, I'd like to transform them into 1…

DanaDaskalova
- 21
- 6
0
votes
1 answer
Python: Regression slow compared with Stata (fixed-effect dummies)
I am trying to run a regression in Python, but it just takes ages and stops running. In Stata it works and only takes a few seconds.
This is due to a categorical column, including group fixed-effects.
Without the variable, the performance of Stata…

user27074
- 627
- 1
- 6
- 20
0
votes
1 answer
R Dummy-variable to be populated from multiple columns
I am a beginner in R and looking to implement dummy variables on a dataset.
I am having a data set with few columns like below -
Dataset1
T1 T2 T3
A C B
A C B
A C B
A D C
B D C
B E F
I want to add dummy variables to this…

user5891930
- 51
- 6
0
votes
1 answer
How to change from event data to time-series cross-sectional data with event dummies?
I have been given a dataset that lists dates for specific events by country in the manner below.
country date1 date2
1 03/01/2012 05/01/2012
2 05/04/2012 12/10/2012
3 07/12/2012 20/03/2012
4 04/02/2012 24/12/2012
What I…

Tom Okal
- 23
- 1
- 4
0
votes
2 answers
How to run panel regression with both individual and time fixed effects?
I'm trying to run a panel regression in Stata with both individual and time fixed effects. I have a lot of individuals and time periods in my sample so I don't want to print the results of all of them. But the documentation I've read online only…

Amazonian
- 391
- 2
- 8
- 22
0
votes
1 answer
Combine maximum possible number of not mutually exclusive dummy variables into a categorical variable
This is an R specific version of a more abstract question asked here https://math.stackexchange.com/questions/2691617/
Let's say we have a lot of dummy variables that we want to use as controls in our regression. If these variables were mutually…

nvx
- 3
- 2
0
votes
1 answer
How does SAS pick reference group when using CLASS statement?
How does SAS pick reference group when using CLASS statement?
I have a categorical variable and it can take on about 200 different values. Is it good practice to create dummies for only specific characteristics of this variable? I know that the…

bree
- 25
- 1
- 7
0
votes
1 answer
How to store the get_dummies transformation of pandas in Python?
There is the get_dummies transformation in the pandas package in python, which transforms categorical variables to binary (flag) variables with values 0 / 1. This transformation is based on the actual values, but I'd like to store the code of the…

lmocsi
- 550
- 2
- 17
0
votes
0 answers
Creating Dummy Variable based on string values in another variable
I am trying to create a dummy variable based on the string value of another variable the new dummy variable is including compound words. My question is how to get around this so it only includes the word in the quotes.
Syntax example "toke" =…

Kreitz Gigs
- 369
- 1
- 9
0
votes
1 answer
Create a column based on condition in groups of a dataframe
I have a data fram looks like:
I want to add a dummy column based on id group and acp which if acq == 1, then the later year in that group will have a dummy value with 1.
something like this :
im trying to doing this in r. i tried with double…

peteraa
- 11
- 1
0
votes
1 answer
Pandas - After I created dummy columns how do I given a new vector get the dummy representation?
Some of my columns contain textual categoric values like
"did_do_something" with the possible values of "true" or "false" or another column might be "browser_type" with possible values of "chrome", "safari" but I also have other columns containing…

Avba
- 14,822
- 20
- 92
- 192