- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 21223 个
- 通用积分
- 362.9526
- 学术水平
- 256 点
- 热心指数
- 263 点
- 信用等级
- 167 点
- 经验
- 94930 点
- 帖子
- 905
- 精华
- 2
- 在线时间
- 1403 小时
- 注册时间
- 2013-12-19
- 最后登录
- 2025-11-9
已卖:1287份资源
教授
还不是VIP/贵宾
- 威望
- 0 级
- 论坛币
 - 21223 个
- 通用积分
- 362.9526
- 学术水平
- 256 点
- 热心指数
- 263 点
- 信用等级
- 167 点
- 经验
- 94930 点
- 帖子
- 905
- 精华
- 2
- 在线时间
- 1403 小时
- 注册时间
- 2013-12-19
- 最后登录
- 2025-11-9
 | 开心 2020-12-29 09:29:04 |
|---|
签到天数: 754 天 连续签到: 1 天 [LV.10]以坛为家III
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
自用Stata绘图(1) | 1.带标注的散点图:
- sysuse lifeexp, clear
- keep if region==2 | region==3
- replace gnppc = gnppc / 1000
- label var gnppc "GNP per capita (thousands of dollars)"
- gen lgnp = log(gnp)
- qui reg lexp lgnp
- predict hat
- label var hat "Linear prediction"
- replace country = "Trinidad" if country=="Trinidad and Tobago"
- replace country = "Para" if country == "Paraguay"
- gen pos = 3
- replace pos = 9 if lexp > hat
- replace pos = 3 if country == "Colombia"
- replace pos = 3 if country == "Para"
- replace pos = 3 if country == "Trinidad"
- replace pos = 9 if country == "United States"
- #delimit ;
- twoway (scatter lexp gnppc, mlabel(country) mlabv(pos))
- (line hat gnppc, sort)
- , xsca(log) xlabel(.5 5 10 15 20 25 30, grid)
- legend(off)
- title("Life expectancy vs. GNP per capita")
- subtitle("North, Central, and South America")
- note("Data source: World bank, 1998")
- ytitle("Life expectancy at birth (years)") ;
- #delimit cr
复制代码 |
2.针式图 - sysuse lifeexp, clear
- keep if region==3
- gen lngnp = ln(gnppc)
- quietly regress le lngnp
- predict r, resid
- twoway dropline r gnp, ///
- yline(0, lstyle(foreground)) mlabel(country) mlabpos(9) ///
- ylab(-6(1)6) ///
- subtitle("Regression of life expectancy on ln(gnp)" "Residuals:" " ", pos(11)) ///
- note("Residuals in years; positive values indicate" "longer than predicted life expectancy")
复制代码
3.直方图 - sysuse sp500, clear
- #delimit ;
- histogram volume, freq
- xaxis(1 2)
- ylabel(0(10)60, grid)
- xlabel(12321 "mean"
- 9735 "-1 s.d."
- 14907 "+1 s.d."
- 7149 "-2 s.d."
- 17493 "+2 s.d."
- 20078 "+3 s.d."
- 22664 "+4 s.d.", axis(2) grid gmax)
- xtitle("", axis(2))
- subtitle("S&P 500, January 2001 - December 2001")
- note("Source: Yahoo!Finance and Commodity Systems, Inc.")
- ;
- #delimit cr
复制代码
4.带拟合分布曲线的直方图 - sysuse sp500, clear
- #delimit ;
- histogram volume, freq normal
- xaxis(1 2)
- ylabel(0(10)60, grid)
- xlabel(12321 "mean"
- 9735 "-1 s.d."
- 14907 "+1 s.d."
- 7149 "-2 s.d."
- 17493 "+2 s.d."
- 20078 "+3 s.d."
- 22664 "+4 s.d."
- , axis(2) grid gmax)
- xtitle("", axis(2))
- subtitle("S&P 500, January 2001 - December 2001")
- note("Source: Yahoo!Finance and Commodity Systems, Inc.")
- ;
- #delimit cr
复制代码
5.区间图 - sysuse sp500, clear
- gen month = month(date)
- sort month
- by month: egen lo = min(volume)
- by month: egen hi = max(volume)
- format lo hi %10.0gc
- by month: keep if _n==_N
- #delimit ;
- twoway rcap lo hi month,
- xlabel(1 "J" 2 "F" 3 "M" 4 "A" 5 "M" 6 "J"
- 7 "J" 8 "A" 9 "S" 10 "O" 11 "N" 12 "D")
- xtitle("Month of 2001")
- ytitle("High and Low Volume")
- yaxis(1 2) ylabel(12321 "12,321 (mean)", axis(2) angle(0))
- ytitle("", axis(2))
- yline(12321, lstyle(foreground))
- msize(*2)
- title("Volume of the S&P 500", margin(b+2.5))
- note("Source: Yahoo!Finance and Commodity Systems Inc.")
- ;
- #delimit cr
复制代码
6.区域图:
- sysuse gnp96, clear
- #delimit ;
- twoway area d.gnp96 date, xlabel(36(8)164, angle(90))
- ylabel(-100(50)200, angle(0))
- ytitle("Billions of 1996 Dollars")
- xtitle("")
- subtitle("Change in U.S. GNP", position(11))
- note("Source: U.S. Department of Commerce, Bureau of Economic Analysis")
- ;
- #delimit cr
复制代码
5.根据函数制作的曲线图
- #d;
- twoway function y=exp(-x/6)*sin(x), range(0 12.57)
- yline(0, lstyle(foreground))
- xlabel(0 3.14 "pi" 6.28 "2 pi" 9.42 "3 pi" 12.57 "4 pi")
- plotregion(style(none))
- xscale(noline)
- ;
- #d cr
复制代码
6.正态曲线下的面积图 - #delimit ;
- twoway
- function y=normalden(x), range(-4 -1.96) bcolor(gs12) recast(area) ||
- function y=normalden(x), range(1.96 4) bcolor(gs12) recast(area) ||
- function y=normalden(x), range(-4 4) clstyle(foreground) ||,
- plotregion(style(none))
- yscale(off) xscale(noline)
- legend(off)
- xlabel(-4 "-4 sd" -3 "-3 sd" -2 "-2 sd" -1 "-1 sd" 0 "mean" 1 "1 sd" 2 "2 sd" 3 "3 sd" 4 "4 sd", grid gmin gmax)
- xtitle("")
- ;
- #delimit cr
复制代码
|
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
-
总评分: 经验 + 200
论坛币 + 200
学术水平 + 8
热心指数 + 8
信用等级 + 8
查看全部评分
|