Eviews作图操作

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Eviews7中的图形操作
Wfcreate wfopen wfselect wfstats wfsave
一、图形的分类
1.线条图,如errbar、hile、line、spike
2.填充图,如area、bar、pie
3.XY图,如xy、xyline、xypair、scat
4.统计图,如boxplot、cdfplot、hist、distplot kernel、qqplot
5.其他对象的特有图形,如方程对象的置信椭圆cellipse
图形能方便地实现数据和计量分析结果的可视化。

图形对象包含对象的图形视图和图形对象。

可以把图象视图定格成图形对象再进行修改。

二、创建图形对象
图形可以用graph命令创建,也可以从其他对象的图形视图定格而来。

如graph gf.line gdp(或graph gf gdp,默认为线条图)
用freeze命令把其他对象的图形视图定格成图形对象。

如freeze(gf) gdp.line
merge命令是合并已有的图形对象
freeze(g1) gdp.line
show g1
graph g2.bar m1
show g2
graph g3.merge gf gg
show g3
多个子图,用align命令设置排列方式,例如
Graph gfan.line(m) log(gdp) log(m1) rs Gfan.align(2,1.5,1)
三、定制图形
图形对象可以通过程序修改的部分有:线型(pattern)和填充,图例(legend)和图框(frame),坐标轴,还可以在图形对象上增加文本、线和阴影等。

1.图框 使用options 命令,例如 graph gf1.line rs Copy gf1 gf2
Gf2.options indent (缩进) Copy gf1 gf3
Gf3.options –inbox (去掉边框) Copy gf1 gf4
Gf4.options size(8,3)(修改为8,3虚拟英寸)
4
5
6
7
8
LOG(GDP)
LOG(M1)
4
8
12
16
RS
Graph gffr.merge gf1 gf2 gf3 gf4 Gffr.legend –display Gffr.align(2,1,1) Delete gf?
2.坐标轴
有些图形命令,如line ,对多个序列作图时,有如下坐标轴选项: a:自动选择坐标轴,横轴在底部,纵轴在左边。

d :双坐标轴,第一个序列对应左边的坐标轴,其他序列对应右边的坐标轴,第一个序列的图形与其他序列不相交。

x :同d ,但允许相交。

n :将序列标准化。

例如
graph gf1.line rs pr copy gf1 gf2
gf2.scale(left) log(采用对数坐标) copy gf1 gf3
gf3.setelem(2) axis(right)(将价格水平的坐标放到右边)
RS
RS
RS
RS
gf4.scale overlap (允许相交) graph gfas.merge gf1 gf2 gf3 gf4 gfas.align(2,2,2) delete gf? show gfas
命令scale 有invert 和range 等选项,设置反向坐标轴和坐标轴
的标注范围。

如 Graph gf1.line log(gdp) Copy gf1 gf2 Gf2.scale invert Copy gf1 gf3 Gf3.scale linearzero
Gf4.scale range(4,8)
Graph gfa1.merge gf1 gf2 gf3 gf4 Gfa1.legend –display Gfa1.align(2,1,1) Delete gf? Show gfa1
坐标的外观,时间标度等也可以进行设置。

例如
Graph gf1.line log(rs) Copy gf1 gf2
Gf2.axis mirror zeroline (增加零线,左右同时给出刻度) Copy gf1 gf3
Gf3.datelabel interval(year,10) (横轴刻度是10年)
LOG(GDP)
LOG(GDP)
LOG(GDP)
LOG(GDP)
Gf4.axis –label grid ticksin (去掉标度,增加网格线,刻度在里面) Graph gfag.merge gf1 gf2 gf3 gf4 Gfag.legend –display Gfag.align(2,1,1) Delete gf? Show gfag
wfopen hs smpl 1988 @last graph gf1.line hs show gf1
gf1.datelabel format(yyyy) interval(year,1) gf1.legend -display
LOG(RS)
LOG(RS)
LOG(RS)
LOG(RS)
gf2.datelabel format(yyyy) interval(year,1) -span graph gf.merge gf1 gf2 gf.align(2,1,1) show gf
3.颜色和线型 wfopen demo smpl 1990 @last graph gf1.line gdp m1 copy gf1 gf2 show gf2
gf2.setelem(2) lcolor(orange) lwidth(2)
Housing Starts
Housing Starts
gf3.setelem(1) lpat(dash1) symbol(star)
copy gf3 gf4
show gf4
gf4.options -color
Graph gf1c.merge gf1 gf2 gf3 gf4
Gf1c.align(2,1,1)
Delete gf?
Smpl @all
Show gf1c
4.填充和纹线 matrix(2,3) mm mm.fill 1,5,3,4,6,2 show mm
freeze(gf1) mm.bar show gf1
1990
1991
1992
199319941995
1996
1990
1991
1992
199319941995
1996
1990
1991
1992
199319941995
1996
1990
1991
1992
199319941995
1996
Gf2.options –color
show gf2
gf2.options -color
copy gf1 gf3
gf3.setelem(1) gray(5) hatch(7) gf3.setelem(2) gray(1) hatch(3) gf3.setelem(3) gray(3) hatch(4) copy gf3 gf4
show gf4
gf4.options -color
graph gff.merge gf1 gf2 gf3 gf4 gff.align(2,2,2)
show gff
5.标注
可以用addtext 命令在图形中添加文字,用draw 命令突出某些内容。

例如graph gf1.line rs show rs close rs show gf1 copy gf1 gf2
gf1.addtext(t) "short trem interest rate" gf1.addtext(l) "percent" show gf2
gf2.draw(shade,bottom,rgb(235,200,180)) 80 85
1234567
gf2.draw(dashline,left,color(red)) 8 graph gfat.merge gf1 gf2 gfat.align(2,1,1) gfat.legend -display show gfat
6.图例
可以控制图例的位置、文本和外观。

graph gf1.line log(gdp) log(m1) pr rs show gf1
(3) Price Level copy gf1 gf2
gf2.legend -inbox position(0.4,0.5) columns(1) (4)
graph gfag.merge gf1 gf2 gfag.align(2,2,2) show gfag
short trem interest rate
p e r c e n t
RS
gfag.legend font(20) 设置字体 gfag.legend –display 不要图例
四、图形模板
通过模板,可以复制图形类型、线型和填充的设置、坐标轴的标度方式、图例的各种属性和图框的各种设定等。

graph gf0.line log(gdp) log(m1) show gf0
gf0.setelem(1) lwidth(4) gf0.setelem(2) symbol(1) gf0.draw(shade,bottom) 80 85
graph gf1.line(o=gf0) pr*10 rs show gf1
graph gf2.line(t=gf0) pr*10 rs
show gf2
还可以在图形创建后再应用模板,例如
Graph gf1.line pr*10 rs
Gf1.template(o) gf0
Graph gf2.line pr*10 rs
Gf2.template(t) gf0
五、打印和导出
保存成图形文件。

Save命令支持三种常用的矢量图形文件,分别是wmf 文件、emf文件、eps文件。

例如
gf2.save(t=wmf,u=in,w=4,-c) mygf
命令名:
freeze\graph\save\merge\align\template\options\name\addtext\legend\
draw \scale\setelem
直方图
x.distplot hist
关键字hist 为命令distplot 的分析设定(analytical spec)。

hist 有自己的选项。

标度类型:scale={dens,freq,relfreg},分别表示密度直方图、频数直方图(默认)和频率直方图。

柱宽:binw={eviews,sigma,iqr,silverman,freefman}. 锚点:anchor=num 分界点:rightclosed
图例文字:leg={def,n,s,det},默认给出最少信息,其他三个选项对应的图例文字信息分别为无文本、短文本和详细信息。

折现直方图:distplot freqpoly 边线直方图:distplot edgefreqpoly 移位直方图:distplot ash wfopen demo gdp.hist
freeze(gf01) gdp.distplot freqpoly show gf01
Freeze(gf02) gdp.distplot edgefreqpoly(fill) show gf02
freeze(gf03) gdp.distplot hist ash show gf03
freeze(gf04)gdp.distplot hist(binw=silverman,anchor=0.6) ash show gf04
F r e q u e n c y
GDP
F
r e q u e n c y
GDP
F r e q u e n c y
GDP
增加正态分布曲线:
选中要画图的序列,打开,点view/gragh 在specific 里选中distribution ,右边的distribution 框选择histogram 。

点击右边的option ,在弹出来的框里点add ,弹出的add 框里选Theoretical Density 。

点击ok 再点击ok 。

最后点击ok 。

经验分布函数图
Eviews5 cdfplot Eviews7 distplot cdf
Distplot cdf 命令,默认绘制累积分布函数函数(选项c),还支持生存函数(选项s)和分位数函数(选项q)。

例如 lnwage.distplot cdf
(说明:shows the cumulative distribution plot for lnwage, along with the default 95% confidence intervals. )
F r e q u e n c y
GDP
lnwage.distplot cdf(noci)则是不显示95%的置信区间 lnwage.distplot survivor(noci) group gro1 weight height
gro1.distplot logsurvivor(ci=0.9, leg=det)
(说明displays the log-survivor plots for WEIGHT and HEIGHT along with 90% confidence intervals, and a detailed legend. The plots will be displayed in individual graph frames. )
gro1.distplot(s) quantile
(说明shows the quantile plots for WEIGHT and HEIGHT in the same graph frame. )
QQ 图
比较两个分布的工具。

如果分布相同,QQ 图应该是一条直线。

理论QQ 图(正态分布n ,均匀分布u ,指数分布e ,Logistic 分布l ,第一类极值分布x),经验QQ 图(s=name). series wage=exp(lnwage) group w wage log(wage) freeze(gfw) w.qqplot(n) show gfw gfw.align(2,1,1)
P r o b a b i l i t y
LNWAGE
wfopen demo
rndseed(type=mt) 12357 group dist @rnorm @rchisq(5) freeze(gf) rs.qqplot(s=dist) show gf gf.align(2,1,1)
直接比较PDF.如何绘制序列和某种分布的PDF ? Do rs.distplot kernel(@obsrange,b=3,o=mrs) series x series rsk group g x rsk mtos(mrs,g) genr y=@dchisq(x,5)
Quantiles of WAGE Q u a n t i l e s o f N o r m a
l
WAGE
Quantiles of LOG(WAGE)
Q u a n t i l e s o f N o r m a l
LOG(WAGE)
Quantiles of RS
Q u a n t i l e s o f N o r m a l
y.displayname chi-squre(5) rsk.displayname interest rate graph gfd.xyline x y rsk show gfd
gfd.legend -inbox position(2.4,0.2) columns(1)
盒图
wfopen garch group g raaa r3 freeze(gfb) g.boxplot show gfb
产生盒图的命令中,boxplot 是群对象命令,进行多个序列的盒图比较。

而boxplotby 是序列对象的命令,绘制单个序列内不同分组的盒图。

修改盒图元素的命令为setbpelem.例如
Copy gfb gfn
Gfn.setbpelem ci(notch)
将盒图中间的阴影部分改为凹槽。

.00
.04
.08
.12
.16
.20
Syntax 语法
boxplot (options) o1 [o2 o3 ... ]
object_name.boxplot (options) [categorical_spec(arg)]
where o1, o2, ..., are series or group objects. You may specify general options after the boxplot keyword.
The optional categorical_spec allows you to specify a categorical graph (see "Categorical Spec").
Basic examples
wage.boxplot
displays boxplots for the series WAGE.
group g1 wage sex race
g1.boxplot
displays boxplots for WAGES, SEX and RACE in a single graph frame.
.00
.04
.08
.12
.16
.20
g1.boxplot(m, rotate)
places the rotated boxplots for each series in a separate frame.
Panel examples
ser1.boxplot(panel=individual)
displays boxplots for each cross-section in a separate frame, while,
ser1.boxplot(panel=stack)
displays a single boxplot computed from the stacked panel data.
ser1.boxplot(panel=combined, rotate)
shows rotated boxplots computed for each period (across cross-sections) in a single frame. Categorical spec examples
ser1.boxplot across(firm, dispname)
displays a categorical boxplot graph of SER1 using distinct values of FIRM to define the categories, and displaying the resulting graphs in multiple frames with common scaling. Each frame is labeled using the FIRM display name.
ser1.boxplot across(firm, dispname, iscale)
constructs the same graph with individual scaling.
ser1.boxplot within(firm, label=value)
constructs a boxplot for each value of FIRM and displays the results in a single frame. The individual boxplots are labeled using the value of FIRM associated with the category.
ser1.boxplot across(firm) within(income, bintype=quant, bincount=4)
constructs a categorical boxplot with FIRM defining the across dimension, and INCOME defining the within dimension. Boxplots for each INCOME quartile of a given firm will be contained in a single frame, with different firms displayed in different frames.
grp1.boxplot within(sex) within(union)
creates an boxplot for within categories based on both SEX and UNION. Since we have not specified behavior for the implicit @SERIES in GRP1, each series in the group will be displayed in a separate frame, with individual scaling.
graph_name.setbpelem element_list
graph01.setbpelem -far width(n) ci(notch)
hides the far outliers, sets the box widths proportional to the number of observations, and enables notching of the confidence intervals.
distplot
Display a distribution graph.
Syntax
distplot(options) o1[o2 o3 ... ]
object_name.distplot(options) analytical_spec(arg) [categorical_spec(arg)]
where o1, o2, ..., are series or group objects.
When used as a command, distplot only allows you to display the default histogram view. When used as an object view, you must specify the type of distribution graph you wish to create in the analytical_spec. You may select from: histogram, histogram polygon, histogram edge polygon, average shifted histogram, kernel density, theoretical distribution, empirical CDF, empirical survivor, empirical log survivor, or empirical quantile (see "Analytical Spec").
The optional categorical_spec allows you to specify a categorical graph (see "Categorical Spec")
Options
on or off the option. The "+" is optional.
Panel options
The following option applies when graphing panel structured data.
Specify the distribution graph you wish to create in the analytical spec. For a description of distribution graphs, see "Analytical Graph Types". The analytical spec contains components of the form:
dist_type(dist_options)
single graph frame by providing multiple components.
Each distribution type has its own set of options, to be entered in dist_options: Histogram, Histogram Polygon, Histogram Edge Polygon, and Avg. Shifted
Histogram, Histogram Polygon, Histogram Edge Polygon, and Avg. Shifted Histogram Examples
inf.distplot hist
displays the default histogram view of the frequencies in each bin.
inf.distplot hist(scale=dens, anchor=100, binw=sigma)
constructs a density histogram computed using anchor position 100 and binwidth
determined by the normal reference rule using as the measure of dispersion.
group g1 inf unemp
g1.distplot hist(scale=relfreq)
displays a relative frequency histogram for the series in INF and UNEMP, each in their own graph frame, while:
g1.distplot(s) histpoly
displays the two frequency histograms in the same graph frame.
g1.distplot freqpoly(fill)
constructs filled frequency polygons for the series in G1, displayed in individual frames. inf.distplot edgefreqpoly(leg=detailed)
shows the edge frequency polygon for INF with detailed legend entries.
g1.distplot ash(scale=dens, rightclosed, nshifts=100)
constructs average shifted density histograms using 100 shifts, with right-closed bins.
group gg weight height
gg.distplot kernel(ngrid=200, fill)
constructs kernel density estimates of HEIGHT and WEIGHT using 200 grid points and linear binning, and displays filled graphs in individual graph frames.
gg.displot(s) kernel(k=u, x)
computes the estimates using a uniform kernel with exact evaluation at each of the grid points, and displays the graphs in the same frame.
gg.displot kernel(leg=det)
displays the kernel plots along with detailed legend information.
Theory Options
gdp50.distplot theory(leg=det)
displays a normal density plot fitted to the data in GDP50 with detailed legend information. gdp50.distplot theory(p1=0)
fits a normal density using GDP50, restricting the mean of the distribution to be zero. group gro1 weight height
gro1.distplot theory(dist=exp, fill)
constructs filled plots of the exponential densities fitted to the data in WEIGHT and HEIGHT, and displays them in separate frames.
gro1.distplot(s) theory(dist=weibull, p1=5, c=1e-5)
fits weibull densities to the data in the series setting the first parameter to 5 and estimating the second with a convergence tolerance of 1e-5. The graphs are displayed in a single frame.
gdp50.distplot cdf
shows the cumulative distribution plot for GDP50, along with the default 95% confidence intervals.
gdp50.distplot survivor(noci)
displays the survivor plot for GDP50 without displaying confidence intervals.
group gro1 weight height
gro1.distplot logsurvivor(ci=0.9, leg=det)
displays the log-survivor plots for WEIGHT and HEIGHT along with 90% confidence intervals, and a detailed legend. The plots will be displayed in individual graph frames.
gro1.distplot(s) quantile
shows the quantile plots for WEIGHT and HEIGHT in the same graph frame.
Examples
Basic examples
distplot height weight length
displays default histograms for the three series.
group g1 age height weight length
g1.distplot hist(scale=dens, binw=sigma, leg=short) kernel theory
displays distribution plots for AGE, HEIGHT, WEIGHT, and LENGTH in separate frames, along with a short legend identifying each distribution plot. Each frame contains a
histogram constructed using the -normal reference rule, a kernel density plot, and a plot of the theoretical normal distribution fitted to the data. (Note that the "scale=dens" option in the hist specification is redundant since combining a histogram with either the kernel or theory plot automatically sets the scaling.)
height.distplot theory theory(dist=weibull)
plots theoretical normal and weibull densities fit to the data in HEIGHT.
height.distplot quantile
displays a plot of the quantiles of height along with the confidence intervals.
g1.displot(s) cdf
plots the empirical CDF of the AGE, HEIGHT, WEIGHT, and LENGTH, and displays them in a single frame.
Panel examples
height.distplot(panel=individual) hist
displays histograms for each cross-section in separate frames while,
weight.distplot kern ash
displays a kernel density graph and average shifted histogram using the panel stacked WEIGHT data.
Categorical spec examples
height.distplot hist across(firm, dispname)
displays a categorical histogram graph of SER1 using distinct values of FIRM to define the categories, and displaying the resulting graphs in multiple frames.
height.distplot hist across(firm, dispname, iscale)
shows the same graph with individual scaling for each of the frames.
weight.distplot kernel ash within(firm, inctot, label=value)
displays kernel and average shifted histograms categorized by firm (with an added category for the total), with all of the graphs in a single frame and the category value used as labels.
length.distplot cdf across(firm, dispname) within(income, bintype=quant, bincount=4)
constructs a categorical cdf graph with FIRM defining the across dimension, and INCOME defining the within dimension. Observations will be classified in the within dimension using the quartiles of INCOME.。

相关文档
最新文档