Conditional Means (Continuous) (Data Analysis)
Using the eth_allrounds_final data, now consider how an outcome varies with a continuous household-level variable by binning it.
-
Use
xtileto create quartiles (asset_q) of household asset index (hh_asset_index). Label the variable as “Asset Quartiles”. For each asset quartile, usebysandsumto compute the mean harvest value (harvest_value_USD). Which quartile has the higest mean value of harvest? -
Make a bar graph using
hbarshowing the mean harvest value (harvest_value_USD)overboth asset quartile (asset_q) andoverif the household experienced a shock to their crops (crop_shock).- Add an informative title and axis label.
- Tell Stata to treat the categories as if the first category are variables on y-axis (
asyvar). This will allow us to change the color of each bar. - Set the color and intensity of bar 1 as
navy*3 - Color bar 2
forest_green, bar 3sienna, and bar 4maroon - Place the legend on the bottom of the graph (
pos) in four column (col) - Label group 1 “lowest”, group 2 as “Lower Middle”, group 3 as “Upper Middle”, and group 4 as “Highest”