[R] country fixed effects model with binary dependent variable

Cristina Cametti cristina.cametti at gmail.com
Sat Jul 23 16:49:53 CEST 2016


Dear all,

I am having problems finding a reliable code for a country fixed effects model with binary dependent variable. I was able to run it for another part of my research, because in that case the dependent variable is continuous. 
This is my code for the continuous dependent variable “imwbcrm_rec”:

modelfe2 <- lm(imwbcrm_rec ~ tvpol + victim + agea + gndr + eduyrs + lrscale_GM + imgfrnd_dum +  qfimwht +factor(cntry)-1, data=mydata)

Please don’t mind to how I wrote the variables, they are from the first wave of the ESS survey. At this point, I have three questions: 
- do you think this code is correct? Since the data are all from the same year (2002), I did not used the ppm package since it is only for panel data. The results of the previous code make sense, so I am satisfied. However, I want to be sure that I am running the right code.
- second questions: someone knows the code for the same analysis, but having a BINARY dependent variable (aesfdrk_dummy)? I found very different information on the internet, and unfortunately, I do not know how to use STATA, so I need to find a reliable code in r. This is the code that I have now:

modelfe1 <-lm(aesfdrk_dummy ~mixed_neigh + ethnic_neigh + agea+ gndr + eduyrs + domicil + partner + tvpol + hincfel_dum + factor(cntry) -1, data=mydata)

-last question: I have to add some interaction between country level variables and individual level variables. So, do you think that this code is right?

mydata$ppltrst_GMXprison_pop <- mydata$ppltrst_GM*mydata$prison_pop 
mydata$ppltrst_GMXforeign_pop <- mydata$ppltrst_GM*mydata$foreign_pop
mydata$victimXprison_pop<- mydata$victim*mydata$prison_pop 
mydata$victimXforeign_pop<- mydata$victim*mydata$foreign_pop
mydata$mixed_neighXprison_pop<- mydata$mixed_neigh*mydata$prison_pop 
mydata$mixed_neighXforeign_pop <- mydata$mixed_neigh*mydata$foreign_pop
mydata$ethnic_neighXprison_pop <- mydata$ethnic_neigh*mydata$prison_pop 
mydata$ethnic_neighXforeign_pop <- mydata$ethnic_neigh*mydata$foreign_pop

modelfe1.2<-lm(aesfdrk_dummy ~mixed_neigh + ethnic_neigh + agea + gndr + eduyrs + domicil + partner + tvpol + hincfel_dum + victim + ppltrst + ppltrstXprison_pop + ppltrst_Xforeign_pop_ + victimXprison_pop_ + victimXforeign_pop + mixed_neighXprison_pop + mixed_neighXforeign_pop + ethnic_neighXprison_pop + ethnic_neighXforeign_pop + factor(cntry)-1, data=mydata)


Thank you very much for your attention.
Kind Regards,

Cristina 


More information about the R-help mailing list