Dummy or indicator variables are used to include categorical or qualitative variables in a regression model.
Questions tagged [dummy-variable]
868 questions
-2
votes
1 answer
factors to dummies in R
My data consists of data about smartphones.
To do a random forest, I need to convert my factor Brand into a lot of dummies.
I tried this code
m <- model.matrix( ~ Brand, data = data_price)
Intercept BrandApple BrandAcer BrandAlcatel ...
1 …

GerritCalle
- 91
- 1
- 2
- 8
-3
votes
1 answer
Search for string and state whether present or not in new column
I have a dataset with 63,000 rows in R. One of the columns contained a list of words in the format
("[\"Stunning seaside location\", \"24-hour emergency call system and secure video entry\", \"Mature landscaped gardens with large terraces and…
-3
votes
3 answers
using a loop for creating multiple dummy variables
I am trying to create a loop to create dummy variable columns. My column mydata$code contains codes like "AA1" or "AA2". I want to create an indivual column for each code, where the value of the row is 1 if the code is hit and 0 otherwise. I have…

user8261831
- 464
- 1
- 4
- 20
-3
votes
1 answer
Create numeric variable with condition
I would like to create a dummy variable for % Change PMI. If % Change PMI is positive is 1 and if negative a 0.
print(Overview3)
Adjusted Close % Change PMI % Change IP
Date
1970-02-27 …

Thomas Widmer
- 9
- 3
-3
votes
1 answer
Dummy head declaration
Dummy is used to record where the initial head is.
why do we have to set up dummy head as Node dummy = new Node(0) but not Node dummy = null. (I get NPE for doing so). Don't we just need to return the head position? Why does setting up dummy with a…

M-M
- 881
- 2
- 10
- 19
-3
votes
1 answer
turn date into dummies for days of month and month of year
I have a vector of dates like this:
ds <- lubridate::as_date(c("2015-11-23", "2015-11-24", "2015-11-25",
"2015-11-26", "2015-11-27", "2015-11-30", "2015-12-01", "2015-12-02",
"2015-12-03", "2015-12-04"))
This vector…

spore234
- 3,550
- 6
- 50
- 76
-3
votes
2 answers
Generate all posible dummies according values of var in r
I have a dataframe like this:
df <- data.frame(V1=c("a,b,c,d,e,f","a,b,c","e,f","b,d","a,e"))
I want to generate all possible dummies according to categories in var V1, something like this:
df$a <- c(1,1,0,0,1)
df$b <- c(1,1,0,1,0)
df$c <-…

Israel
- 260
- 3
- 15
-3
votes
1 answer
creating a dummy matrix from a concatenated column
I'm using R and I have a column that looks like this:
relative
aunt
mother,grandmother
sister,mother
My desired outcome should look like this:
mother sister aunt grandmother
0 0 1 0
1 0 0 1
0 0 0 0
1 …

Milad Botros
- 1
- 2
-3
votes
2 answers
Create Dummy Variables with Loop in Python
I'm trying to create a bunch of new Binary variables just for some columns that contain a certain word (and I want to name these new binary variables BINARY_ +column name), I'm trying to do it in this was way but it doesn't work:
# create empty…

Mastodon87
- 325
- 3
- 6
- 14
-3
votes
1 answer
Dummy Variable in R
Ciao Everyone,
I would like to create a dummy variable in R. So I have a list of Italian regions, and a variable called mafia. The mafia variable is coded 1 in the regions with high levels of mafia infiltration and 0 in the regions with lower…

156158
- 1
-4
votes
1 answer
how to gen variable = 1 if at least two dummy variables == 1 in Stata?
I am trying to generate a dummy variable that = 1 if at least two or more (out of seven) dummy variables also == 1. Could anybody tell me an efficient way of doing this?

Econometrics33
- 101
- 8