Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

Stata: Label Continuous Variable

I want to create a histogram for my continuous variable x that has lots of outliers (let's say values greater than 100 and less than -100 are where the outliers are). In order to make the histogram easy to read, I aggregate the values of x greater than 100 and less than -100.

However, I also want to label the values 100 and -100 as >=100 and <=-100 respectively. However, I couldn't figure out how to label only two values of a continuous variable in Stata.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
 gen whatever2 = clip(whatever, -100, 100)
 label def whatever2 -100 "{&le}-100" 100 "{&ge}100" 
 label val whatever2 whatever2 
 histogram whatever2 , start(-100) width(10) xla(, valuelabel) 

should get you started. You may need to specify which xlabel()s are shown.

I would just use -- or want to see -- a quantile plot for some transformed scale, such as cube root, sign(y) log(1 + |y|) or asinh(y). Don't hide outliers!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...