I have 50 countries in a data frame and want to repeat the same regression model 50 times for each country. I have a column for country IDs:
Since I am analyzing imputed datasets, I am using "with" and "implist." For example,
model <- with(implist, lmer(happy~income+age+sex+education+city
+(1|school))
How can I repeat this model 50 times for each country and see the coefficients of income and age for each country? I can split data to each country if it is more convenient. Any ways will be fine for me. Thank you in advance.