Hello!
I am hoping to get some insights for my analysis where I am plotting predicted values by group with CI showing for each group.
I'm running a fixed effects model below for each age group separately (because these are time invariant, I cannot add them in the model as an independent variable, hence no margins or marinsplot) below.
This gives me predicted values for each observation and I want to make a graph showing predicted values for each age groups (onsetage_cat wrklimage_cat wrkprvage_cat tage_cat) that has three categories. So the y-axis is the predicted values and the x-axis is the three age groups. I can get upper/lower bounds for each observation, but I want to plot mean predicted values and CI for each age groups, not for each observation. My sample data are shown below.
I really appreciate any comments in advance.
Thank you very much!
Hyun Ju
I am hoping to get some insights for my analysis where I am plotting predicted values by group with CI showing for each group.
I'm running a fixed effects model below for each age group separately (because these are time invariant, I cannot add them in the model as an independent variable, hence no margins or marinsplot) below.
Code:
foreach var of varlist onsetage_cat wrklimage_cat wrkprvage_cat tage_cat { forvalues i = 1(1)3 { qui reghdfe anyasset female i.race_eth educ married curr_emp dis hpov hhchildren rhnumper if `var'==`i' [pw=finpnl4], absorb(pid year) vce(cluster tehc_st) predict yhat`i'all_`var' } }
I really appreciate any comments in advance.
Thank you very much!
Hyun Ju
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float anyasset byte female float race_eth byte(educ married curr_emp dis) float(hpov hhchildren) byte rhnumper float(onsetage_cat wrklimage_cat wrkprvage_cat) byte tage_cat double finpnl4 float(pid year) str2 tehc_st 1 1 1 1 0 0 0 0 0 1 . . . 3 6665.257622628558 1 2014 "20" 1 1 1 1 0 0 0 0 0 1 . . . 3 6665.257622628558 1 2015 "20" 1 1 1 1 0 0 0 0 0 1 . . . 3 6665.257622628558 1 2016 "20" 1 1 1 1 0 0 0 0 0 1 . . . 3 6665.257622628558 1 2017 "20" 1 1 . 1 1 1 0 0 1 5 . . . 2 20963.994881006787 2 2014 "20" 1 1 . 1 1 1 0 0 1 5 . . . 2 20963.994881006787 2 2015 "20" 1 1 . 1 1 0 1 0 1 5 . . . 2 20963.994881006787 2 2016 "20" 1 1 . 1 1 0 0 0 1 4 . . . 3 20963.994881006787 2 2017 "20" 1 0 . 0 1 1 0 0 0 5 . . . 3 25169.738975914108 3 2014 "20" 1 0 . 0 1 1 0 0 0 5 . . . 3 25169.738975914108 3 2015 "20" 1 0 . 0 1 1 1 0 0 5 . . . 3 25169.738975914108 3 2016 "20" 1 0 . 0 1 1 0 0 0 4 . . . 3 25169.738975914108 3 2017 "20" 1 1 . 1 0 0 0 0 0 5 . . . 1 22782.40487469756 4 2014 "20" 0 1 . 1 0 0 0 0 0 5 . . . 1 22782.40487469756 4 2015 "20" 1 1 . 1 0 1 0 0 0 5 . . . 2 22782.40487469756 4 2016 "20" 1 1 . 1 0 1 0 0 0 4 . . . 2 22782.40487469756 4 2017 "20" 1 0 . 1 0 1 0 0 0 5 . . . 1 0 5 2014 "20" 0 0 . 1 0 1 0 0 0 5 . . . 1 0 5 2015 "20" 1 0 . 1 0 1 0 0 0 5 . . . 1 0 5 2016 "20" 0 0 . . . . 0 0 0 5 . . . 1 19311.30721139168 6 2014 "20" end label values anyasset yesno label values hhchildren yesno label def yesno 0 "no", modify label def yesno 1 "yes", modify label values female female label def female 0 "male", modify label def female 1 "female", modify label values race_eth race_eth label def race_eth 1 "Non-Hispanic White", modify label values educ educ label def educ 0 "Less than highschool", modify label def educ 1 "Highschool or higher", modify label values married married label def married 0 "Unmarried", modify label def married 1 "Married", modify label values curr_emp curr_emp label def curr_emp 0 "Not working", modify label def curr_emp 1 "Working", modify label values dis dis label def dis 0 "no", modify label def dis 1 "yes", modify label values hpov pov label def pov 0 "Not in poverty", modify label values onsetage_cat onsetage_cat label values wrklimage_cat wrklimage_cat label values wrkprvage_cat wrkprvage_cat label values tage_cat tage_cat label def tage_cat 1 "Before age 26", modify label def tage_cat 2 "Ages 26-45", modify label def tage_cat 3 "After age 46", modify
Comment