I am having trouble thinking how I can graph an average of two products ("Coca-Cola" and "tonic water") as "Soft Drinks" within the prod variable along with an average price line of all other goods listed in the sample over time. I had tried to graph many individual lines together, but it becomes quite messy and you are unable to see exactly what is being graphed where. Instead, just have one line for "Soft Drinks" and one line for everything else. I think a "twoway" line should work, but I am not sure how to get the averages for "Soft Drinks" and for the remaining other product average lines (ideally without creating a new "total" observation which would change the results of any regressions that I run). A snippet of my data is attached below. Thanks so much for any ideas!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double abs_price str23 combined str66 prod float store_type int year str3 currency str7 country str10 city float tax 2.99 "2014IrelandDublinEUR" "Apples (1 kg)" 0 2014 "EUR" "Ireland" "Dublin" 0 2.24 "2014IrelandDublinEUR" "Apples (1 kg)" 1 2014 "EUR" "Ireland" "Dublin" 0 3 "2015IrelandDublinEUR" "Apples (1 kg)" 0 2015 "EUR" "Ireland" "Dublin" 0 2.48 "2015IrelandDublinEUR" "Apples (1 kg)" 1 2015 "EUR" "Ireland" "Dublin" 0 3 "2016IrelandDublinEUR" "Apples (1 kg)" 0 2016 "EUR" "Ireland" "Dublin" 1 2.34 "2016IrelandDublinEUR" "Apples (1 kg)" 1 2016 "EUR" "Ireland" "Dublin" 1 3.2 "2017IrelandDublinEUR" "Apples (1 kg)" 0 2017 "EUR" "Ireland" "Dublin" 1 2.15 "2017IrelandDublinEUR" "Apples (1 kg)" 1 2017 "EUR" "Ireland" "Dublin" 1 2.99 "2018IrelandDublinEUR" "Apples (1 kg)" 0 2018 "EUR" "Ireland" "Dublin" 1 2.19 "2018IrelandDublinEUR" "Apples (1 kg)" 1 2018 "EUR" "Ireland" "Dublin" 1 2.54 "2019IrelandDublinEUR" "Apples (1 kg)" 0 2019 "EUR" "Ireland" "Dublin" 1 2.4 "2019IrelandDublinEUR" "Apples (1 kg)" 1 2019 "EUR" "Ireland" "Dublin" 1 2.61 "2020IrelandDublinEUR" "Apples (1 kg)" 0 2020 "EUR" "Ireland" "Dublin" 1 2.25 "2020IrelandDublinEUR" "Apples (1 kg)" 1 2020 "EUR" "Ireland" "Dublin" 1 2.52 "2014UKManchesterGBP" "Apples (1 kg)" 0 2014 "GBP" "UK" "Manchester" 0 1.95 "2014UKLondonGBP" "Apples (1 kg)" 0 2014 "GBP" "UK" "London" 0 1.86 "2014UKLondonGBP" "Apples (1 kg)" 1 2014 "GBP" "UK" "London" 0 1.93 "2014UKManchesterGBP" "Apples (1 kg)" 1 2014 "GBP" "UK" "Manchester" 0 1.85 "2015UKLondonGBP" "Apples (1 kg)" 0 2015 "GBP" "UK" "London" 0 2.2 "2015UKManchesterGBP" "Apples (1 kg)" 0 2015 "GBP" "UK" "Manchester" 0 1.75 "2015UKManchesterGBP" "Apples (1 kg)" 1 2015 "GBP" "UK" "Manchester" 0 1.75 "2015UKLondonGBP" "Apples (1 kg)" 1 2015 "GBP" "UK" "London" 0 2.1 "2016UKManchesterGBP" "Apples (1 kg)" 0 2016 "GBP" "UK" "Manchester" 1 2 "2016UKLondonGBP" "Apples (1 kg)" 0 2016 "GBP" "UK" "London" 1 2 "2016UKLondonGBP" "Apples (1 kg)" 1 2016 "GBP" "UK" "London" 1 1.75 "2016UKManchesterGBP" "Apples (1 kg)" 1 2016 "GBP" "UK" "Manchester" 1 2 "2017UKLondonGBP" "Apples (1 kg)" 0 2017 "GBP" "UK" "London" 1 2.2 "2017UKManchesterGBP" "Apples (1 kg)" 0 2017 "GBP" "UK" "Manchester" 1 1.75 "2017UKManchesterGBP" "Apples (1 kg)" 1 2017 "GBP" "UK" "Manchester" 1 1.98 "2017UKLondonGBP" "Apples (1 kg)" 1 2017 "GBP" "UK" "London" 1 2.3 "2018UKManchesterGBP" "Apples (1 kg)" 0 2018 "GBP" "UK" "Manchester" 1 2.12 "2018UKLondonGBP" "Apples (1 kg)" 0 2018 "GBP" "UK" "London" 1 2 "2018UKLondonGBP" "Apples (1 kg)" 1 2018 "GBP" "UK" "London" 1 1.97 "2018UKManchesterGBP" "Apples (1 kg)" 1 2018 "GBP" "UK" "Manchester" 1 2.04 "2019UKLondonGBP" "Apples (1 kg)" 0 2019 "GBP" "UK" "London" 1 2.16 "2019UKManchesterGBP" "Apples (1 kg)" 0 2019 "GBP" "UK" "Manchester" 1 1.79 "2019UKLondonGBP" "Apples (1 kg)" 1 2019 "GBP" "UK" "London" 1 2.01 "2019UKManchesterGBP" "Apples (1 kg)" 1 2019 "GBP" "UK" "Manchester" 1 2.14 "2020UKManchesterGBP" "Apples (1 kg)" 0 2020 "GBP" "UK" "Manchester" 1 2.1 "2020UKLondonGBP" "Apples (1 kg)" 0 2020 "GBP" "UK" "London" 1 1.85 "2020UKLondonGBP" "Apples (1 kg)" 1 2020 "GBP" "UK" "London" 1 1.87 "2020UKManchesterGBP" "Apples (1 kg)" 1 2020 "GBP" "UK" "Manchester" 1 12.45 "2014IrelandDublinEUR" "Bacon (1 kg)" 0 2014 "EUR" "Ireland" "Dublin" 0 8.77 "2014IrelandDublinEUR" "Bacon (1 kg)" 1 2014 "EUR" "Ireland" "Dublin" 0 10.14 "2015IrelandDublinEUR" "Bacon (1 kg)" 0 2015 "EUR" "Ireland" "Dublin" 0 7.44 "2015IrelandDublinEUR" "Bacon (1 kg)" 1 2015 "EUR" "Ireland" "Dublin" 0 9.99 "2016IrelandDublinEUR" "Bacon (1 kg)" 0 2016 "EUR" "Ireland" "Dublin" 1 7.08 "2016IrelandDublinEUR" "Bacon (1 kg)" 1 2016 "EUR" "Ireland" "Dublin" 1 8.64 "2017IrelandDublinEUR" "Bacon (1 kg)" 0 2017 "EUR" "Ireland" "Dublin" 1 6 "2017IrelandDublinEUR" "Bacon (1 kg)" 1 2017 "EUR" "Ireland" "Dublin" 1 6.82 "2018IrelandDublinEUR" "Bacon (1 kg)" 0 2018 "EUR" "Ireland" "Dublin" 1 6.32 "2018IrelandDublinEUR" "Bacon (1 kg)" 1 2018 "EUR" "Ireland" "Dublin" 1 6.54 "2019IrelandDublinEUR" "Bacon (1 kg)" 0 2019 "EUR" "Ireland" "Dublin" 1 4.92 "2019IrelandDublinEUR" "Bacon (1 kg)" 1 2019 "EUR" "Ireland" "Dublin" 1 5.9 "2020IrelandDublinEUR" "Bacon (1 kg)" 0 2020 "EUR" "Ireland" "Dublin" 1 4.57 "2020IrelandDublinEUR" "Bacon (1 kg)" 1 2020 "EUR" "Ireland" "Dublin" 1 10 "2014UKManchesterGBP" "Bacon (1 kg)" 0 2014 "GBP" "UK" "Manchester" 0 13.96 "2014UKLondonGBP" "Bacon (1 kg)" 0 2014 "GBP" "UK" "London" 0 9.5 "2014UKManchesterGBP" "Bacon (1 kg)" 1 2014 "GBP" "UK" "Manchester" 0 5 "2014UKLondonGBP" "Bacon (1 kg)" 1 2014 "GBP" "UK" "London" 0 12.36 "2015UKLondonGBP" "Bacon (1 kg)" 0 2015 "GBP" "UK" "London" 0 9.5 "2015UKManchesterGBP" "Bacon (1 kg)" 0 2015 "GBP" "UK" "Manchester" 0 6.67 "2015UKLondonGBP" "Bacon (1 kg)" 1 2015 "GBP" "UK" "London" 0 8.32 "2015UKManchesterGBP" "Bacon (1 kg)" 1 2015 "GBP" "UK" "Manchester" 0 11.96 "2016UKLondonGBP" "Bacon (1 kg)" 0 2016 "GBP" "UK" "London" 1 9.33 "2016UKManchesterGBP" "Bacon (1 kg)" 0 2016 "GBP" "UK" "Manchester" 1 7.67 "2016UKManchesterGBP" "Bacon (1 kg)" 1 2016 "GBP" "UK" "Manchester" 1 6.67 "2016UKLondonGBP" "Bacon (1 kg)" 1 2016 "GBP" "UK" "London" 1 10.84 "2017UKLondonGBP" "Bacon (1 kg)" 0 2017 "GBP" "UK" "London" 1 8.14 "2017UKManchesterGBP" "Bacon (1 kg)" 0 2017 "GBP" "UK" "Manchester" 1 6.18 "2017UKManchesterGBP" "Bacon (1 kg)" 1 2017 "GBP" "UK" "Manchester" 1 6.67 "2017UKLondonGBP" "Bacon (1 kg)" 1 2017 "GBP" "UK" "London" 1 9.09 "2018UKLondonGBP" "Bacon (1 kg)" 0 2018 "GBP" "UK" "London" 1 8.04 "2018UKManchesterGBP" "Bacon (1 kg)" 0 2018 "GBP" "UK" "Manchester" 1 7.48 "2018UKLondonGBP" "Bacon (1 kg)" 1 2018 "GBP" "UK" "London" 1 6.4 "2018UKManchesterGBP" "Bacon (1 kg)" 1 2018 "GBP" "UK" "Manchester" 1 8.33 "2019UKManchesterGBP" "Bacon (1 kg)" 0 2019 "GBP" "UK" "Manchester" 1 10.93 "2019UKLondonGBP" "Bacon (1 kg)" 0 2019 "GBP" "UK" "London" 1 7.33 "2019UKLondonGBP" "Bacon (1 kg)" 1 2019 "GBP" "UK" "London" 1 6.67 "2019UKManchesterGBP" "Bacon (1 kg)" 1 2019 "GBP" "UK" "Manchester" 1 8.5 "2020UKManchesterGBP" "Bacon (1 kg)" 0 2020 "GBP" "UK" "Manchester" 1 10.9 "2020UKLondonGBP" "Bacon (1 kg)" 0 2020 "GBP" "UK" "London" 1 7.8 "2020UKLondonGBP" "Bacon (1 kg)" 1 2020 "GBP" "UK" "London" 1 7.09 "2020UKManchesterGBP" "Bacon (1 kg)" 1 2020 "GBP" "UK" "Manchester" 1 1.25 "2014IrelandDublinEUR" "Bananas (1 kg)" 0 2014 "EUR" "Ireland" "Dublin" 0 1.25 "2014IrelandDublinEUR" "Bananas (1 kg)" 1 2014 "EUR" "Ireland" "Dublin" 0 1.25 "2015IrelandDublinEUR" "Bananas (1 kg)" 0 2015 "EUR" "Ireland" "Dublin" 0 1.25 "2015IrelandDublinEUR" "Bananas (1 kg)" 1 2015 "EUR" "Ireland" "Dublin" 0 1.39 "2016IrelandDublinEUR" "Bananas (1 kg)" 0 2016 "EUR" "Ireland" "Dublin" 1 1.25 "2016IrelandDublinEUR" "Bananas (1 kg)" 1 2016 "EUR" "Ireland" "Dublin" 1 1.89 "2017IrelandDublinEUR" "Bananas (1 kg)" 0 2017 "EUR" "Ireland" "Dublin" 1 1.59 "2017IrelandDublinEUR" "Bananas (1 kg)" 1 2017 "EUR" "Ireland" "Dublin" 1 1.59 "2018IrelandDublinEUR" "Bananas (1 kg)" 0 2018 "EUR" "Ireland" "Dublin" 1 1.39 "2018IrelandDublinEUR" "Bananas (1 kg)" 1 2018 "EUR" "Ireland" "Dublin" 1 1.59 "2019IrelandDublinEUR" "Bananas (1 kg)" 0 2019 "EUR" "Ireland" "Dublin" 1 1.19 "2019IrelandDublinEUR" "Bananas (1 kg)" 1 2019 "EUR" "Ireland" "Dublin" 1 1.46 "2020IrelandDublinEUR" "Bananas (1 kg)" 0 2020 "EUR" "Ireland" "Dublin" 1 1.19 "2020IrelandDublinEUR" "Bananas (1 kg)" 1 2020 "EUR" "Ireland" "Dublin" 1 .68 "2014UKLondonGBP" "Bananas (1 kg)" 0 2014 "GBP" "UK" "London" 0 1.2 "2014UKManchesterGBP" "Bananas (1 kg)" 0 2014 "GBP" "UK" "Manchester" 0 end
0 Response to Graphing one product verses an average of all other products
Post a Comment