Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65070

how to plot different variables of different observations

$
0
0
Hey All,
I have a question concerning the plotting functions. Consider:

Code:
// IMPORT DATA

// The first part just generates data the way I have it,
//such that you know my data structure.
//Skip to "PLOT MY RESULTS"

clear
webuse grunfeld, clear
g ret=invest/1500
bys company (year): g cumul=ret if _n==1
replace cumul=ret + l.cumul if missing(cumul)
gen country = "empty"
keep if company <8
replace country = "FR" if company ==1
replace country = "US" if company ==2
replace country = "DE" if company ==3
replace country = "FR" if company ==4
replace country = "US" if company ==5
replace country = "DE" if company ==6     
replace country = "FR" if company ==7
    

// Generate EMU identifier
gen emu                  = 0
replace emu              = 1  if (country == "AT") | (country == "BE") |  (country == "ES") | (country == "DE") | (country == "CY")| (country == "FI") | (country == "FR") | (country == "IT") | (country == "NL") | (country == "GR") | (country == "SI")

// compute abnormal returns for countries and countrygroups (EMU)
egen mean_country_cum = mean(cumul), by(year country)  // averages for each country
egen mean_euro_cum = mean(cumul), by(year emu)         // emu average based on averaging all emu companies


// PLOT MY RESULTS 
// here begins the interesting part

// Cumulative returns Euro vs. US
// code that displays mean_country_cum(US) vs. mean_euro_cum against time
As described in the code I want to plot the cumulative abnormal returns of the EU area vs. the cumulative abnormal returns of the States. I guess in terms of Stata I want to plot two different variables of two different observations against time. Is this possible? If yes, how? if no, does anyone know a workarround that procudes what I am looking for?

I guess in pseudo code I look for:

Code:
twoway plot mean_country_cum if company == 1, mean_euro_cum if company == 2
It seems like cheap trick to just choose a company of which I know it is based in Euro / US, but this could work I guess. Unfortunately Stata syntax is still a bit of a mystery to me. Can anyone help out?

Thanks in advance!

Best,
Harvey

Viewing all articles
Browse latest Browse all 65070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>