相似文件
换一批
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
近期需要stata进行统计,特别是统计图,总结了做图命令如下,希望能够给战友帮助。
STATA GRAPHICS
Graphics Basics
sysuse auto, clear
graph bar (mean) mpg turn, by(foreign)
graph bar (mean) mpg turn, over(foreign)
graph hbar (mean) mpg turn, over(foreign)
graph hbar (mean) mpg, over(foreign) over(class)
graph hbar (mean) mpg, over(class) over(foreign)
graph hbar (mean) mpg, over(class) over(foreign, sort(1) descending)
graph hbar (sum) mpg turn, over(class) stack
graph hbar (sum) mpg turn, over(class) by(foreign)
graph hbar (sum) mpg turn, over(class) by(foreign) stack
graph dot (mean) mpg, over(class)
graph dot (mean) mpg, over(class) over(foreign)
graph matrix mpg price turn, half
graph pie, over(class)
graph pie mpg turn trunk, plabel(_all name)
Scatter and Two-way Plotting (Examples)
scatter mpg weight
scatter mpg weight, sort
scatter mpg weight, sort connect(1)
scatter mpg weight, sort title("MPG versus Weight") subtitle("Year 2006")
scatter mpg weight, title("MPG versus Weight") caption("Source: Stata Corp. 2006")
scatter mpg weight, title("MPG versus Weight") xsize(4) ysize(3)
scatter mpg weight, ytitle("MPG (Mileage)") xtitle("Car Weight")
scatter mpg weight, title("MPG versus Weight") ylabel(#8) xlabel(0(2000)6000)
scatter mpg weight, title("MPG versus Weight") ylabel(minmax) xlabel(minmax)
scatter mpg weight, title("MPG versus Weight") yscale(log) xlabel(#5) // log scales
scatter mpg weight, sort xline(4000) yline(25)
scatter mpg weight, title("MPG versus Weight") msymbol(triangle)
scatter mpg weight || fpfit mpg weight
twoway fpfitci mpg weight
twoway fpfitci mpg weight || scatter mpg weight, m(d)
scatter mpg weight, sort title("MPG versus Weight") m(diamond) by(foreign)
scatter mpg weight, sort m(t) by(foreign, total row(1))
twoway fpfitci mpg weight, sort m(t) by(foreign, total row(1))
twoway fpfitci mpg weight || scatter mpg weight, sort m(t) by(foreign, total row(1))
scatter mpg turn weight
scatter mpg turn weight , yline(30) xline(3500)
scatter mpg trunk turn weight
scatter mpg weight || scatter trunk weight || scatter turn weight
scatter mpg weight, sort c(1) || line trunk weight, sort || scatter turn weight
twoway (line mpg weight, sort c(1)) (dropline trunk weight, sort) (scatter turn weight)
Plotting by Functions
twoway function y=x^3, range(-5 5) xsize(4) ysize(3) xlabel(#10) xline(0)
twoway function y=normalden(x), range(-5 5) xsize(4) ysize(2) xlabel(#10) xline(0)
twoway function y=1/sqrt(2*_pi)*exp(-x^2/2), range(-5 5) xsize(4) ysize(2) xlabel(#10) xline(0)
twoway function y=normalden(x), range(-4 -1.96) xlabel(#10) xline(0) recast(area) || function y=normalden(x), range(1.96 4) recast(area) || function y=normalden(x), range(-1.96 1.96) lstyle(foreground)
twoway function t=tden(3, x), range(-5 5) xsize(4) ysize(2) xline(0)
twoway function t=tden(1, x), range(-5 5) xsize(4) ysize(2) color(blue) lstyle(p1solid) xlabel(-5(1)5) recast(area) || function z=normden(x), range(-5 5) color(maroon) lwidth(thick)
scatter gear_ratio headroom, xsize(4) || function y=x, range(0 5)
twoway function c=chi2(1,x), range(0 5) xsize(4) ysize(3) yline(.5)
twoway function c=Fden(5, 10, x), range(0 5) xsize(4) ysize(3) yline(.3)
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝