楼主: sulight
6882 10

[学习心得] STATA GRAPHICS做图及统计命名汇总 [推广有奖]

  • 0关注
  • 43粉丝

院士

44%

还不是VIP/贵宾

-

威望
0
论坛币
118614 个
通用积分
1632.3438
学术水平
363 点
热心指数
437 点
信用等级
344 点
经验
236948 点
帖子
4124
精华
0
在线时间
2226 小时
注册时间
2010-1-16
最后登录
2024-10-28

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+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)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Graphics GRAPHIC GRAPH Stata tata stata 做图

已有 4 人评分经验 论坛币 学术水平 热心指数 收起 理由
我的素质低 + 10 精彩帖子
statax + 5 + 1 精彩帖子
zhanghui0931 + 20 + 20 + 2 精彩帖子
葫芦娃大王 + 1 + 1 精彩帖子

总评分: 经验 + 21  论坛币 + 36  学术水平 + 1  热心指数 + 2   查看全部评分

沙发
sulight 学生认证  发表于 2018-2-8 16:20:47 |只看作者 |坛友微信交流群
Probability Distribution相关的命令

binomal(h,k,p) // joint cumulative distribution of bivariate normal
chi2(df,x) // cumulative chi squared distribution
chi2tail(n,x) // reverse of chi2()
F(df1, df2, f) // cumulative F distribution
Ftail(df1, df2, f) // reverse cumulative (upper-tail) F
normal(z); normal(1.96) // returns .9750002
ttail(df, t) // reverse cumulative (upper-tail) T
uniform() // uniform distributionreverse cumulative (upper-tail) T
di chi2tail(10,18.31) // returns .04995417, p-value
di F(5, 10, 3.325) // returns .9499661
di Ftail(5, 10, 3.325) // returns .05000, the pa-value
di (1-normal(z))*2 // compute the p-value for the two-tailed test
di ttail(20, 2.086) // returns .02499818
di ttail(df, t)*2 // compute the p-value for the two-tailed test

使用道具

藤椅
sulight 学生认证  发表于 2018-2-8 16:21:38 |只看作者 |坛友微信交流群

Reshaping Data Sets相关命令


  • set obs 100 // to change the numnber of observations
  • sort male grade
  • gsort -grade name, gen(rank)
  • append using c:\data\class
  • app using c:\data\class, keep(id state q1-q10)
  • expand 5 in -10/-1 // duplicate observations n-1 times
  • merge using school // one-to-one merging
  • merge state using school // match merging
  • merge state using school university, update replace
  • joinby id using secondary, unmatched(master) // unm(both), unm(using)
  • move male grade
  • order grade male // order variables as listed
  • rename male gender; /* from male to gender */
  • expand 5 if state=="IN" // duplicate a subset of observations
  • collapse a b (sd) c (count) d (max)
  • collapse a b (sd) c (count) d (max), by state
  • contract gender degree area, freq(count) zero
  • reshape long choice, i(id) j(orders)
  • stack best1-best3, into(best) clear
  • pkshape id row col1-col3, order(abc cab bca) outcome(y) sequence(rows) treat(treat) period(columns)
  • compress // all variable
  • compress name grade
  • xpose, clear varname

使用道具

板凳
sulight 学生认证  发表于 2018-2-8 16:23:21 |只看作者 |坛友微信交流群

Advanced Models

  • boxcox //Box-Cox regression model
  • eivreg // errors-in-variables regression
  • fracpoly // Fractional polynomial regression
  • frontier //Stochastic frontier models
  • glm // generalized linear model
  • intreg //interval regression
  • ivreg //instrumental variables (two-stage least squares) regression
  • ivreg dv iv1 iv2 (iv3= x1 x2 x3) iv4 iv5
  • mfp //multivariable fractional polynomial models
  • mvreg //multivariate regression
  • newey //Regression with Newey-West standard errors
  • nl //nonlinear least-squares estimation
  • orthog //Orthogonalize variables and compute orthogonal polynomials
  • prais dv1 rhs, rho(tscorr) twostep //Prais-Winsten two-step
  • prais dv1 rhs, rho(dw) // iterative two-step
  • prais dv1 rhs, rho(dw) corc // Cochrane-Orcutt
  • qreg //Quantile (including median) regression
  • reg3 //three-stage estimation for systems of simultaneous equations
  • reg3 (dv1 x1 x2) (dv2 x1 x3)
  • reg3 (dv1 dv2 = x1 x2 x3)
  • reg3 (dv1 dv2 = x1 x2 x3) (dv3 x1 x3)
  • rocfit //fit ORC model
  • rreg //robust regression
  • stcox //fit Cox proportional hazards model
  • streg //fit parametric survival model
  • sureg //Zellner's seemingly unrelated regression
  • stepwise //stepwise estimation
  • treatreg //treatment-effects model
  • treatreg y x1 x2 x3, treat(x4=z1 z2) twostep
  • vwls //variance-weighted least squares




使用道具

报纸
sulight 学生认证  发表于 2018-2-8 16:24:12 |只看作者 |坛友微信交流群

PANEL DATA相关命令


  • tsset group year // set group and time
  • xtreg y x1 x2, re i(year) // random effect model
  • xtreg y x1 x2, fe i(group) // random effect model
  • xtreg y x1 x2, be i(group) // between effect model
  • areg // linear regression with a large dummy-variable set
  • xtabond // Arellano-Bond linear, dynamic panel-data estimator
  • xtcloglog // Random-effects, population-averaged cloglog models
  • xtgee // fit population-averaged panel-data models using GEE
  • xtfrontier // stochastic frontier models for panel data
  • xtgls // fit panel-data models using GLS
  • xthtaylor // Hausman-Taylor estimator for error components models
  • xtinreg // random-effects interval data regression models
  • xtivreg // Instrumental variables and two-stage least squares
  • xtlogit //fixed-effects, random-effects, population-averaged logit
  • xtmixed // multilevel mixed-effects linear regression
  • xtprobit // random-effects and population averaged probit models
  • xttobit // random-effects tobit models
  • xtnbreg //fixed-effects, random-effects, and population-averaged NB
  • xtpcse // Prais-Winsten models with panel-corrected standard errors
  • xtpoisson //fixed-effects, random-effects, population-averaged Poisson
  • xtrc // random-coefficients models
  • xtregar // fixed-and random-effects linear models with an AR(1)

使用道具

地板
sulight 学生认证  发表于 2018-2-8 16:26:55 |只看作者 |坛友微信交流群
参数统计和非参统计的命令

T-Test

  • ttest grade==10
  • ttest grade, by(male)
  • ttest grade, by(male), unequal welch
  • ttest math=english; ttest math==english, unpaired
  • ttesti 100 88.1 5.2 90; /* N mean sd hypothesis */
  • ttesti 100 88.1 5.2 200 91 10.2; /* N1 mean1 sd1 N2 mean2 sd2 */
  • ttesti 100 88.1 5.2 200 91 10.2, unequal
  • mean // estimate means
  • total // estimate totals
  • ratio // estimate ratios
  • proportion // one- and two-sample tests of proportions
  • ci // confidence intervals for means, proportions, and counts


ANOVA
  • anova score gender
  • anova score gender year gender*year
  • oneway score gender, tabulate
  • loneway //large one-way ANOVA, random effect, and reliability
  • sdtest // Variance-comparison test
  • Related: .manova; .pkshape; .xtmixed

MULTIVARIATE ANALYSIS

Correlation Analysis

  • correlate gnp interest inflation
  • corr gnp interest inflation, covariance
  • pcorr x1-x10 // partial correlation coefficients
  • pwcorr gnp interest inflation, sig
  • pwcorr gnp interest inflation, print(5) // .05 significance level
  • pwcorr gnp interest inflation, sig star(.05) // .05 level

Factor Analysis

  • factor x1-x30 // by default pcf (principal component factor)
  • factor x1-x30, ml // maximum likelihood factor
  • factor x1-x30, factors(5)
  • rotate, varimax // orthogonal, oblique, quartimax, equamax, parsimax, promax
  • pca // principal component analysis

Other Analysis

  • alphar // Cronbach's alpha
  • ca // correspondence analysis
  • canon // Canonical correlation
  • cluster // cluster analysis
  • mvreg // multivariate regression
  • manova // multivariate MANOVA
  • mds // multidimensional scaling for two way data
  • mdslong
  • mdsmat
  • biplot

NONPARAMETRIC ANALYSIS

  • swilk math english
  • sfrancia x1-x10
  • ranksum //Equality tests on unmatched data
  • signrank math=english // Equality tests on matched data
  • runtest // test for random order
  • spearman x1-x10
  • kwallis score, by(gender)
  • ksmirnov math, by(area)
  • alpha x1-x10, item
  • kappa eval1 eval2
  • bitest //Binomial probability test
  • prtest // one- and two-sample tests of proportions

END
为了不增加网站负担,请根据需要下载附件。

祝各位战友学习顺利!!!

stata常用命令汇总.docx

31.7 KB

需要: 8 个论坛币  [购买]

使用道具

7
GKINGLIU 在职认证  发表于 2018-2-8 17:24:10 |只看作者 |坛友微信交流群
good!!

使用道具

8
zhanghui0931 在职认证  发表于 2018-2-9 01:46:51 |只看作者 |坛友微信交流群
继续加油支持论坛啊

使用道具

9
sulight 学生认证  发表于 2018-2-9 08:15:07 |只看作者 |坛友微信交流群
zhanghui0931 发表于 2018-2-9 01:46
继续加油支持论坛啊
必须的,谢谢版大!!!

使用道具

10
阿笨猫真笨 在职认证  发表于 2018-2-10 09:39:32 来自手机 |只看作者 |坛友微信交流群
sulight 发表于 2018-2-8 16:14
近期需要stata进行统计,特别是统计图,总结了做图命令如下,希望能够给战友帮助。

STATA GRAPHICS
棒棒哒

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-11-6 03:36