Dear Statalisters.
I have been puzzling over what I would have thought would be a simple challenge. I have an index which has a distribution that is pareto-like on both sides of the x-axis. It is distributed over the interval [-1;1], with a mass point at zero, and most of the distribution very close to zero (either positive or negative) with a very flimsy tail extending to 1 or -1. I wanted to produce an histogram in the spirit of the screenshot I have attached (which I believe was produced in R, but not by me). But using xscale(log) does not seem to work.
Here is a way to generate a toy dataset with something that looks like the index:
set obs 10000
set seed 876
gen u=runiform()
gen v=runiform()
gen w1=runiform()
gen w2=runiform()
gen t=runiform()
gen double ypareto = 1000/(u^2.1)
quietly sum ypareto
gen y=ypareto/`r(max)'
replace y=0 if w1<0.025
gen double zpareto = 1000/(v^2.1)
quietly sum zpareto
gen z=zpareto/`r(max)'
replace z=0 if w2<0.025
gen d=y
replace d=-z if t>0.5
keep d
sum d, d
twoway histogram d, bin(100)
twoway histogram d, bin(100) xscale(log)
If someone could point me in the general direction to produce a graph like this, I would be grateful.
Regards,
Pierre
Related Posts with Histogram with log scale both below and above 0
Why does Stata allow a random effect without a level-1 effect?The command for an HLM model in Stata is: Code: mixed depvar indepvars . . . || levelvar: revars, …
Select US listed companies only (Compustat)Hi all, I would like to select only the firms (gvkey) in my dataset which are listed in the US (US …
How to estimate the risk difference with margins after meprobitDear Statalist, Happy new year! Here is my question: Code: clear set seed 2020 set obs 400 set …
Missing deciles with Portfolio SortHi, I have the following problem. When using the fastxtile command to sort my values into deciles, …
Annualized Sharpe ratios and VolatilitiesGood morning, I have Monthly excess returns of two portfolios P1 and P8 over 29 years. For my maste…
Subscribe to:
Post Comments (Atom)
0 Response to Histogram with log scale both below and above 0
Post a Comment