stata:应用stata学习计量经济学原理 practice 2 stata绘图基础

应用stata学习计量经济学原理

Practice 2

在这里插入图片描述
在这里插入图片描述

* Q1 
clear all
* 1
sysuse uslifeexp.dta
* 2
scatter le year
scatter le year,connect(1)
scatter le year,connect(1) msymbol(i)
* 3
scatter le year,  ///
ylabel(30(5)80) xlabel(1890(10)2010)  ///
xtitle(year) ytitle(life expectancy) ///
 title(1900-1940 US life expectancy)
* 4
twoway (scatter le_male year) (scatter le_female year), ///
title(US male and female life expectancy) ///
xtitle(year) ytitle(life expendency) ///
legend (subtitle("Legend") all cols(1) ring(0) pos(5))

* Q2
clear all
cd "F:\stata与计量经济学\week 2 计量实验"
dir
use WAGE.DTA
*1
scatter educ wage
scatter exper wage
*2
scatter educ wage if female == 1, mcolor(green) scheme(p9) msymbol(O) msize(medium)

scatter exper wage if female == 1, mcolor(blue) scheme(p8) msymbol(x) msize(medium)

Another vision


*Q1
sysuse uslifeexp, clear

scatter le year,connect(l) msymbol(i)  
* connect(1): connect with straight lines 
* msymbol(i): remove the points

su le
*check the range of y-axis
su year
*check the range of x-axis

scatter le year, ylabel(35(5)80) xlabel(1900(10)2000) xtitle(year) ytitle(life expectancy) title(1900-1999 US life expectancy)

twoway(scatter le_male year)(scatter le_female year), title(1900-1999 US life expectancy for male and female) xtitle(year) ytitle(life expectancy) legend(ring(0) cols(1) position(5))
*or
scatter le_male year||scatter le_female year,title(1900-1999 US life expectancy for male and female) xtitle(year) ytitle(life expectancy) legend(ring(0) cols(1) position(5))
* ring(0): represents the legend be moved inside the plot
* cols(1): only one columns of legend
* position(5): the legend will be moved to 5 o'clock position



*Q2
use wage.dta ,clear
twoway(scatter educ wage if female == 1)(scatter exper wage if female == 1)
* by default

twoway ///
(scatter educ wage if female == 1, ///
msymbol(O) mcolor(green) msize(medium) mstyle(p9)) ///
(scatter exper wage if female == 1, ///
msymbol(X) mcolor(blue) msize(medium) mstyle(p8))
* msymbol:散点形状
* mcolor: 散点颜色
* msize:  散点大小
* mstyle: 散点整体样式

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值