I have a categorical independent variable (with options of "yes" or "no") that I want to add to my panel linear model. According to the answer here: After generating dummy variables?, the lm function automatically creates dummy variables for you for categorical variables.
Does this mean that creating dummy variables through i.e. dummy.data.frame is unnecessary, and I can just add in my variable in the plm function and it will automatically be treated like a dummy variable (even if the data is not numerical)? And is this the same for the plm function?
Also, I don't have much data to begin with. Would it hurt if I manually turned the data into numbers (i.e. "yes"=1, "no"=0) without creating a dummy variable?
str(df). If they arechar, you will need to transform them. If they arefactorvariables,lm()will handle it for you. - Romanfactor()inside the model, e.g.lm(y ~ x + factor(dummy), data). - jay.sf