Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to display "Fixed effects: heterogeneity across years (stripplot)?"

    Good morning to the community Stata!

    I would like to show a graph like the picture showing geometric mean of performance across years.
    I would like a log scale of performance in y axis and years from 2010 until 2020 in x axis.



    I ran this command [see below the picture] but I got an error in the x_axis. The date are not correctly ordered. I have 2010, 2012, 2014, 2016, 2015, 2011, 2017, 2013, 2018 instead of 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020.

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	82.3 KB
ID:	1613515



    Code:
    use"File4.dta", clear
    
    
    *means and standard deviations of intangible assets by industry
    preserve
    collapse (mean) mean_intangible_assets_industry=intangible_assets (sd) sd_intangible_assets_industry=intangible_assets, by (industry)
    asdoc list, replace
    restore
    *means and standard deviations of intangible assets by year
    preserve
    collapse (mean) mean_intangible_assets_year=intangible_assets (sd) sd_intangible_assets_year=intangible_assets, by (year)
    asdoc list, replace
    restore
    *descriptive statistics for control variables (average, mean, sd)
    asdoc tabstat enterprise_value_added market_capitalization leverage stock_growth dividend_payout_ratio stock_volatility, stat(mean p50 sd), replace
    *correlation for control variables 
    corr enterprise_value_added market_capitalization leverage stock_growth dividend_payout_ratio stock_volatility
    *setting panel data
    xtset i year
    *exploring panel data
    xtline ln_firm_performance
    xtline ln_firm_performance, overlay
    
    
    
    *Fixed effects: Heterogeneity across entities (stripplot)
    clear
    set obs 900
    set seed 2803
    
    gen performance = exp(rnormal(-2, 1))
    gen type_industry = ceil(_n/ 100)
    
    label def type_industry 1 `" "Basic" "Materials" "'  ///
    2  `" "Communi-" "cations" "' 3 `" "Consumer" "Cyclical" "' 4 `" "Consumer" "Non-Cyclical" "' ///
    5  "Energy"  6 "Financial"  7 "Industrial"  8 "Technology" 9  "Utilities" , modify
    
    label val type_industry type_industry
    
    * get a gmean() function (don't remove the *) 
    * ssc inst egenmore
    
    * sort on geometric mean (don't remove the *) 
    * ssc inst myaxis
    myaxis xaxis=type_industry, sort(gmean performance)
    
    * ssc inst stripplot
    stripplot performance, over(xaxis) centre vertical cumul cumprob refline scheme(s1color) xla(, noticks labsize(small)) xsize(7) xtitle("") ysc(log) yla(5 2 1 0.5 0.2 0.1 0.05 0.02, ang(h))  reflevel(gmean) mc(blue)
    
    
    
    *Fixed effects: Heterogeneity across years (stripplot)
    clear
    set obs 900
    set seed 2803
    
    gen performance = exp(rnormal(-2, 1))
    gen type_year = ceil(_n/ 100)
    
    label def type_year 1 "2010" 2 "2011" 3 "2012" 4 "2013" 5 "2014" 6 "2015" 7 "2016" 8 "2017" 9 "2018" 10 "2019" 11 "2020", modify
    
    label val type_year type_year
    
    * get a gmean() function (don't remove the *) 
    * ssc inst egenmore
    
    * sort on geometric mean (don't remove the *) 
    * ssc inst myaxis
    myaxis xaxis=type_year, sort(gmean performance)
    
    * ssc inst stripplot
    stripplot performance, over(xaxis) centre vertical cumul cumprob refline scheme(s1color) xla(, noticks labsize(small)) xsize(7) xtitle("") ysc(log) yla(5 2 1 0.5 0.2 0.1 0.05 0.02, ang(h))  reflevel(gmean) mc(blue)

    Thank you for your help.
    Attached Files

    Lucas BORDURE
    Student MSc. in International Finance
    Rennes School of Business
    Stata SE 16.1
Working...
X