Dummy variables and initial multiple linear regression model in R
I’m trying to create an initial model for my regression but I don’t want the coefficient for Item5 showing up, just the rest of them and Item5_1, Item5_2, etc since it’s already encoded. I also have to follow the K-1 rule and create a dummy variable for the number of categories in the categorical variables I pick. How can I adjust the code to not give Item5 and instead Item5_1, Item5_2, etc?
how to build a dummy with case_when?
i’m struggling on codes that worked well since this morning. I would like to create a dummy variable in this way:
for the group of observations identified by NCLP variable, it should take value 1 when variable Data_Fine_Effettiva is not missing, and when it is not missing I want to select the max value between all observations. Moreover, if Data_Fine_Effettiva is missing, my dummy has to be 1 when the max lagged value of Data_Inizio_Effettiva is not missing and smaller than a threshold (my_date).
In all the other case my dummy should be 0.