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
How do I create a dummy variable in R based on a dataset's median?
My data has a median of 60. I'd like to create a dummy variable where 1 = >60 and 0 = <60.

E Bat
- 11
- 1
0
votes
0 answers
Linear model in R with multiple dummies but no constant: Choice of included dummy variable levels
Consider a large panel consisting of bilateral trade data and policy dummy (levels 0 and 1, reference level 0).
head(data)
home partner year gdphome gdppartner exports policy
Austria Albania 1988 133018182771 2126000000 8833653 …

Fusscreme
- 152
- 9
0
votes
2 answers
Creating dummy variables from cells with multiple character values
I'm trying to create multiple dummy variables, based on one column called 'Tags' within my df (2 rows, 2 columns, Tags and Score. The problem is that in each cell of the column Tags there can be any number of chr values (up to about 30 values). I…

Benjamin Telkamp
- 1,451
- 2
- 17
- 31
0
votes
0 answers
Run a within estimation with time dummies in R
I have a survey made of 13k observations: the dataset in an unbalanced panel based on a survey conducted every two years.
The df is based on individual observations from 2010 to 2014.
I wanted to run a two ways fixed effect regression and I used…

Laura R.
- 99
- 1
- 10
0
votes
1 answer
How to add additional years to an individual/company after last observed year?
I have an unbalanced panel data set in Stata. With observations from 1993 to 2013. I have a variable named bankrupcty year which indicates the year each company went bankrupt. The problem is that my Stata file is missing up to 2 years before each…
0
votes
0 answers
Manage categorical variables with NA in R
I am using a national survey to run my regression. The df is based on deographic and economic variables and sometime there are missing values that R address as "NA".
I have categorical variables but sometime I find problems: for example I have a…

Laura R.
- 99
- 1
- 10
0
votes
1 answer
Trouble Converting a data frame into a design matrix in r
I started with R a few days ago and really could use some help :D
I currently have a data.frame with 200 observations and 12 variables (they represent clicks, so they are named c1-c12).
Background:
A user clicks (up to 12 times) on fields. These…

sidebob
- 13
- 3
0
votes
1 answer
Change default binary label in a dummy variable
I use model.matrix() method in R to generate dummy variables as:
dd <- data.frame(a = gl(2,2))
model.matrix(~ a - 1,dd)
Instead of 0 and 1 output labels, what parameter we need to set in model.matrix() so that output labels are -1 and 1?

Haroon Lone
- 2,837
- 5
- 29
- 65
0
votes
1 answer
How to find observations whose dummy variable changes from 1 to 0 (and not viceversa) in a df in r
I have a survey composed of n individuals; each individual is present more than one time in the survey (panel). I have a variable pens, which is a dummy that takes value 1 if the individual invests in a complementary pension form. For example:
df <-…

Laura R.
- 99
- 1
- 10
0
votes
1 answer
SAS: Coding a dummy variable for a value of a variable by group within group
I have a dataset of CASE_ID (x y and z), a set of multiple dates (including duplicate dates) for each CASE_ID, and a variable VAR. I would like to create a dummy variable DUMMYVAR by group within a group whereby if VAR="C" for CASE_ID x on…

Deborah Weissner
- 37
- 1
- 2
- 8
0
votes
1 answer
Tying new variable value to all responses by individual in long data
I'm using a longitudinal survey in long format, and I'm trying to create a dummy variable for if an individual has NOT got a college degree by the age of 25. My data looks something like this:
ID CYRB VAR VALUE
1 1983 DEG98 1
1 …

Milhouse
- 177
- 3
- 11
0
votes
1 answer
Excel Dummy Variable for R
I hope this question isn't off topic.
I know how to code a dummy variable in R, however, I was wondering if I could create it in excel. Lets say I have 3 colors (red, blue, yellow) list under a color variable. R would import this as a factor with…

Danib90
- 181
- 7
0
votes
2 answers
Creating Dummy Variable in R
I'm pretty new to R and I'm trying to create some new variables. Basically my dataset has individuals with a variable for mother ID (i.e. if two individuals have the same mother the value of this variable will be the same).
Keeping it simple to…

Milhouse
- 177
- 3
- 11
0
votes
0 answers
polycor package - hetcor error in optim
I'm trying to run a factor analysis on a set of 80 dichotomous variables (1440 cases) using the hector function from the polycor package and the instructions I found here:…

D. K.
- 73
- 7
0
votes
1 answer
splitstackshape pkg - concat.split.expanded returning NA by coercion errors
I'm following the instructions here Dummy variables from a string variable to try to convert a column of strings (words separated by spaces) into dummy variables (0-1 to indicate a word being notused/used in the string in that row) using…

D. K.
- 73
- 7