Hello everyone,
I am trying to find a way, how variables can be grouped in a Coefplot with multiple models and similar variable names.
To begin with, I am working on a dataset that contains variables measuring attitudes towards income redistribution (e.g. ideal_redis) and drivers like the perception towards social mobility (soc_mob) that may explain those attitudes. The dataset contains information across six different countries and currently comprises 7954 observations and 824 variables in total. Here is an example:
What I observed first is the heterogeneity regarding the effect of e.g. the perception of social mobility on attitudes towards income redistribution across different groups (high-income vs. low-income or right-wing vs. left wing). To estimate these interaction effects I used the following regression command:
In a next step I further wanted to show, to what extend these interaction effects differ across countries. In other words, I want to find out whether e.g. people with high income differ systematically across countries in how attitudes towards income redistribution may be explained. Therefore I estimated interaction effects for each country separately with the following model:
Now I want to illustrate the interaction effects of e.g. right wing and left wing with e.g. social mobility using coefplot and group the effects by countries. For this I used the following command:
Now, I would usually use a specification like:
However, my problem here is that the variables from the different models (for each country) all have the same name and therefore I don't know how to group interaction terms for e.g. Germany specifically. The graph as it currently looks like is attached as well.
I hope my problem became clear and one can help me out here. Thanks in advance!
I am trying to find a way, how variables can be grouped in a Coefplot with multiple models and similar variable names.
To begin with, I am working on a dataset that contains variables measuring attitudes towards income redistribution (e.g. ideal_redis) and drivers like the perception towards social mobility (soc_mob) that may explain those attitudes. The dataset contains information across six different countries and currently comprises 7954 observations and 824 variables in total. Here is an example:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str8 id float(ideal_redis dif_tax_top1_bot50 fin_sec soc_mob immigr2 trustsv_gov socialc_daily right_wing left_wing fem_resp eq_hh_inc5 edu_cat_1 edu_cat_3) byte(dummctry1 dummctry2 dummctry3) "oypkwm6r" 10.71068 55 2.2285094 2.3342535 2.914331 2.3664074 0 0 1 0 1 1 0 1 0 0 "lu2fugw6" 2.2315383 8 3.565615 3.112338 3.642914 1.1832037 0 1 0 0 0 0 1 1 0 0 "tuswl5ab" 5.315876 25 4.457019 2.3342535 1.821457 1.9720062 0 1 0 1 0 0 1 1 0 0 "tr8ydsq9" 3.354943 16 2.674211 1.556169 2.1857483 3.15521 0 0 0 0 0 0 0 1 0 0 "z89oaoun" -5.478949 -36 1.7828075 .7780845 2.914331 2.760809 0 0 0 0 0 1 0 1 0 0 "dh56whmp" .9688556 0 2.2285094 2.3342535 1.0928742 1.9720062 0 0 0 1 0 1 0 1 0 0 "8y7cosz4" 7.504148 38 2.674211 2.3342535 2.5500395 2.760809 0 0 0 1 0 0 0 1 0 0 "cfcbkxfp" 5.78357 40 4.457019 3.8904226 3.642914 3.9440124 0 1 0 1 0 1 0 1 0 0 "qf7xnjej" 10.07989 66 . . . 1.9720062 0 0 0 1 1 0 1 1 0 0 "q3bsipwq" 5.287528 42 2.2285094 1.9452113 3.642914 1.9720062 0 0 0 1 0 0 0 1 0 0 "o0p42toh" 9.167415 49 3.565615 3.112338 2.5500395 2.760809 0 1 0 0 0 0 1 1 0 0 "6wachra6" 1.6787767 3 2.674211 3.8904226 1.4571655 .39440125 0 1 0 1 1 0 0 1 0 0 "m1i9sqjn" 3.523725 15 0 1.9452113 1.821457 1.9720062 0 1 0 0 0 1 0 1 0 0 "o57zks9h" 9.175116 36 2.2285094 2.723296 2.1857483 2.760809 0 0 0 0 0 0 0 1 0 0 "erqoabkm" 7.480872 38 3.565615 3.112338 2.914331 3.15521 0 0 0 1 1 0 0 1 0 0 end label values fin_sec finsec label def finsec 0 "0 - Worse", modify label values soc_mob soc_mob label values immigr2 immigr2 label values trustsv_gov trust2 label values fem_resp fem label def fem 0 "Male", modify label def fem 1 "Female", modify
Code:
reg ideal_redis $socioeconomic_basic $exp_riskav c.fin_sec#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.soc_mob c.soc_mob#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.immigr2 c.immigr2#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.trustsv_gov c.trustsv_gov#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// 1.socialc_daily#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.religion#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.reciprocity#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.tw_exp_share c.tw_exp_share#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// $social_preferences $relig_community $social_contact 1.right_wing 1.left_wing 1.polit_orient_na $dummctry, robust
In a next step I further wanted to show, to what extend these interaction effects differ across countries. In other words, I want to find out whether e.g. people with high income differ systematically across countries in how attitudes towards income redistribution may be explained. Therefore I estimated interaction effects for each country separately with the following model:
Code:
foreach var in ideal_redis dif_tax_top1_bot50 { foreach country in DEU GBR ITA JPN SVN { reg `var' $socioeconomic_basic $exp_riskav c.fin_sec#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.soc_mob c.soc_mob#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.immigr2 c.immigr2#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.trustsv_gov c.trustsv_gov#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// 1.socialc_daily#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.religion#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.reciprocity#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// c.tw_exp_share c.tw_exp_share#(1.right_wing 1.left_wing 1.polit_orient_na 1.fem_resp 1.eq_hh_inc5 1.edu_cat_1 1.edu_cat_3) /// $social_preferences $relig_community $social_contact 1.right_wing 1.left_wing 1.polit_orient_na if country_survey=="`country'", robust eststo `var'_`country' } }
Now I want to illustrate the interaction effects of e.g. right wing and left wing with e.g. social mobility using coefplot and group the effects by countries. For this I used the following command:
Code:
coefplot (ideal_redis_DEU, keep(1.right_wing#c.soc_mob) msymbol(s) msize(small) pstyle(p1)) /// (ideal_redis_DEU, keep(1.left_wing#c.soc_mob) msymbol(t) msize(small) pstyle(p7)) /// /// (ideal_redis_GBR, keep(1.right_wing#c.soc_mob) msymbol(s) msize(small) pstyle(p1)) /// (ideal_redis_GBR, keep(1.left_wing#c.soc_mob) msymbol(t) msize(small) pstyle(p7)) /// /// (ideal_redis_ITA, keep(1.right_wing#c.soc_mob) msymbol(s) msize(small) pstyle(p1)) /// (ideal_redis_ITA, keep(1.left_wing#c.soc_mob) msymbol(t) msize(small) pstyle(p7)) /// /// (ideal_redis_JPN, keep(1.right_wing#c.soc_mob) msymbol(s) msize(small) pstyle(p1)) /// (ideal_redis_JPN, keep(1.left_wing#c.soc_mob) msymbol(t) msize(small) pstyle(p7)) /// /// (ideal_redis_SVN, keep(1.right_wing#c.soc_mob) msymbol(s) msize(small) pstyle(p1)) /// (ideal_redis_SVN, keep(1.left_wing#c.soc_mob) msymbol(t) msize(small) pstyle(p7)) /// /// (ideal_redis_USA, keep(1.right_wing#c.soc_mob) msymbol(s) msize(small) pstyle(p1)) /// (ideal_redis_USA, keep(1.left_wing#c.soc_mob) msymbol(t) msize(small) pstyle(p7)) /// /// , groups(1 2 = "Germany" 3 4 = "Great Britain" 5 6 = "Italy" 7 8 = "Japan" 9 10 = "Slovenia" 11 12 = "United States", angle(horizontal)) /// /// title("Desired redistribution", size(msmall)) nolabel xline(0, lcolor(gs6) lpattern(dash)) xmlabel(-2.5(1)2.5, nogrid) legend(order(2 "Right-wing" 4 "Left-Wing")) xlabel(, grid glcolor(gs14)) ytick(, nogrid) ylabel(, grid glcolor(gs14)) /// graphregion(color(white)) legend(size(vsmall) col(5) region(lwidth(vthin))) plotregion(lcolor(black) margin(vsmall) lwidth(vthin)) /// bgcolor(white) xsize(5.5) /// mlabel(cond(@pval<.001, "****", cond(@pval<.01, "***", cond(@pval<.05, "**", cond(@pval<.1,"*", "")))))
Now, I would usually use a specification like:
Code:
groups(1.right_wing#c.soc_mob 1.left_wing#c.soc_mob= "Germany" ///
I hope my problem became clear and one can help me out here. Thanks in advance!
Comment