当前位置:文档之家› Using Stata to Replicate Table 1 in Bond(2002)

Using Stata to Replicate Table 1 in Bond(2002)

Using Stata to Replicate Table 1 in Bond(2002)
Using Stata to Replicate Table 1 in Bond(2002)

Using Stata to Replicate Table 1 in Bond (2002)

These notes refer to using Stata/SE 9.1, in March 2006.

Preliminaries

To use large datasets in Stata, you may first need to increase the memory space allocated to data storage.

Start Stata

In the command window, type

set memory XXm

where XX is an integer. E.g.

set memory 25m

allocates 25 megabytes for storing the dataset.

Open the dataset invrat1. E.g.

Click File Open from within Stata

Use command (use filename) in the command window, e.g.

u invrat1

Double click the file in My Computer

Six variables are listed in the variables window

year - calendar year (integer)

date - exact date (end of accounting period; string)

dscode - firm identifier (string)

firm - firm identifier (integer)

invrate - investment rate (real)

noj - number of observations on this firm (integer)

Some useful commands to learn more about the variables

describe [varlist] - lists variables and types

summarize [varlist] - basic descriptive statistics

summarize [varlist] , detail - more descriptive statistics

list [varlist] - displays values

list [varlist] if - displays specified values

Examples

su

su invrate , d

l firm year invrate if firm == 9008282

Stata’s help facility gives much more information on all these commands. E.g.

Click Help Stata Command... and then type the name of the command

Click Help Search... and then the topic

Type help followed by the command name in the command window

To use Stata’s commands for panel data, we need to tell Stata that this is a panel dataset.

In the command window, type

tsset firm year , yearly

This tells Stata that the variable firm identifies different cross-section units (like

the subscript i), the variable year identifies different time periods (like the

subscript t), and the observations are yearly. Firm and year should be integers.

This will also sort the dataset, if it is not already sorted.

For some commands, we may need to create and store the first lag of the investment rate explicitly.

In the command window, type

generate invrate1 = l.invrate

This uses Stata’s lag operator (l.) to create the first lag of the variable invrate. This requires that we have first used tsset to specify the panel nature of the dataset. The first observation on each firm is set to Stata’s missing value code. The new

variable invrate1 should appear in the variable list.

Other operators are also available. E.g.

ll. creates the second lag

d. creates the first-difference

ld. (or dl.) creates the first lag of the first-difference

Pooled OLS (OLS levels); Table 1, column (i)

In the command window, type

xi: regress invrate l.invrate i.year , robust cluster(firm)

Results for the pooled OLS levels regression should appear in the results window. Identical results are obtained with the command

xi: reg invrate invrate1 i.year , r cl(firm)

The prefix xi: allows the i.year shorthand to be used to include a set of year dummies. The robust and cluster(firm) options specify standard errors that are asymptotically robust to both heteroskedasticity and serial correlation. Using only the robust option would produce standard errors that are asymptotically robust to heteroskedasticity, but not to serial correlation.

The estimated coefficient on the lagged dependent variable is identical to that in Table 1, column (i). The standard error is almost identical, but differs at the 4th decimal place. This is not a typo in the paper, but reflects slight differences between the ways in which Stata and DPD98 for Gauss calculate the robust standard errors.

To store results to a file, first open a log file inside Stata. E.g.

In the command window, type

log using results.log

for a plain text file.

Or click File Log Begin, or click the Begin Log button on the toolbar.

See help log for more options. Typing log close in the command window stops subsequent commands and results being stored. Or click File Log Close, or click the Close Log button on the toolbar.

If the abar command is installed (see below), typing

abar , lags(2)

will produce robust versions of the Arellano-Bond (1991) tests for the absence of first-order and second-order serial correlation in the residuals.

Within Groups; Table 1, column (ii)

In the command window, type

xi: xtreg invrate l.invrate i.year , fe robust cluster(firm)

xtreg is Stata’s command for classical panel data regression estimators.

The fe option specifies “fixed effects”.

The robust option is not allowed with xtreg in earlier versions of Stata. To obtain Within Groups estimates with robust standard errors in earlier versions of Stata, use the areg command

xi: areg invrate invrate1 i.year , absorb(firm) robust cluster(firm)

These commands produce identical results, which are similar but not identical to those in Table 1, column (ii). The Within Groups option in DPD98 for Gauss uses OLS on the model transformed to orthogonal deviations. This is identical to OLS on the Within transformed model only in the case of balanced panels.

Anderson-Hsiao First-Differenced 2SLS; Table 1, column (iii)

In the command window, type

xi: ivreg d.invrate (ld.invrate=ll.invrate) i.year , robust cluster(firm)

ivreg is Stata’s command for instrumental variables regression. A more powerful alternative (ivreg2) can be installed if desired.

The dependent variable is specified in first-differences.

The second lag of invrate is specified as an instrumental variable for the lagged dependent variable in first-differences, which is treated as endogenous.

The year dummies are treated as (strictly) exogenous and also included in the instrument set.

The coefficient on the lagged dependent variable is identical to that in Table 1, column (iii). The standard error is almost identical.

Arellano-Bond First-Differenced GMM: Table 1, column (iv)

In the command window, type

xi: xtabond invrate i.year , maxldep(2) robust

xtabond is Stata’s command for first-differenced GMM estimation of panel data models. xtabond2 provides a more powerful alternative.

The dependent variable is specified in levels. This command automatically takes first-differences.

The lagged dependent variable is not specified. This command automatically includes a lagged dependent variable, and treats this as endogenous.

The year dummies are treated as (strictly) exogenous and also included in the instrument set.

There are options to include predetermined or endogenous explanatory variables. See help xtabond for details.

The maxldep(2) option specifies that lagged levels of the dependent variable dated t-2 and t-3 only should be included as instruments. I.e. At most 2 lags are used as instruments.

The robust option here produces standard errors that are robust to both heteroskedasticity and serial correlation (and are computed in an identical way to those obtained with

DPD98 for Gauss).

This produces coefficients, standard errors and serial correlation tests that are identical to those in Table 1, column (iv). These are one-step GMM estimates.

To obtain the test of overidentifying restrictions, use the twostep option to specify that the optimal two-step GMM estimator should be computed.

xi: xtabond invrate i.year , maxldep(2) two

With the xtabond command, this is an alternative to the robust option. The standard errors calculated for the two-step estimator are asymptotically robust, but are known to have very poor finite sample properties.

If the xtabond2 command has been installed, the same results can be obtained using the commands

xi: xtabond2 invrate l.invrate i.year , gmm(invrate, lag(2 3)) iv(i.year) robust

noleveleq

xi: xtabond2 invrate l.invrate i.year , gmm(invrate, lag(2 3)) iv(i.year) robust

twostep noleveleq

In this case the robust option can be specified together with the twostep option. This produces standard errors that are asymptotically robust to both heteroskedasticity and serial correlation, and which use the finite-sample correction proposed by Windmeijer (2005). This is one important advantage of using the xtabond2 command.

The syntax of xtabond2 is quite different from xtabond. The dependent variable and the list of explanatory variables are specified before the comma. The instrument set is specified after the comma.

The option gmm(invrate, lag(2 3)) includes the second and third lags of the level of invrate in the instrument set. These instruments are not “stacked”, so that coefficients on these instruments in the first-stage regressions are allowed to vary over time.

The option iv(i.year) includes the year dummies in the instrument set. These instruments are “stacked”, so that coefficients on these instruments in the first-stage regressions are restricted to be constant over time.

The option noleveleq specifies that only the equations in first-differences are used in estimation. Without this option, the xtabond2 command uses both equations in first-differences combined with equations in levels. The option to compute these “system GMM” estimators is another important advantage of using the xtabond2 command.

The latest version of xtabond2 uses the Mata programming language available in Stata 9.1. To use it with earlier versions of Stata, include the nomata option (after the comma). If xtabond2 is not already installed, and your computer is connected to the internet, it can be installed very easily from within Stata.

Click Help Search...

Check Search net resources and type xtabond2

Click on the url for the xtabond2 command

Click on the download/install option

The abar, ivreg2 and many other commands can be installed in the same way.

Note that the xtabond2 command is written by David Roodman at the Center for Global Development, Washington DC. Please include the requested citation if you use this command in your work. Details can be found using help xtabond2 after the command is installed. Please also direct any questions on this command to droodman@https://www.doczj.com/doc/6d1984839.html,

Arellano-Bond First-Differenced GMM: Table 1, column (v)

In the command window, type

xi: xtabond invrate i.year , robust

The only difference from the xtabond command used in the previous section is that we do not use the maxldep option to restrict the number of lagged levels of invrate that are used as instruments in each of the first-differenced equations. The default, used here, is to include all available lags.

The corresponding two-step GMM estimator and test of overidentifying restrictions are obtained using

xi: xtabond invrate i.year , two

These produce identical results to those in Table 1, column (v).

To obtain the same results using xtabond2, the commands are

xi: xtabond2 invrate l.invrate i.year , gmm(invrate, lag(2 .)) iv(i.year) r nol

xi: xtabond2 invrate l.invrate i.year , gmm(invrate, lag(2 .)) iv(i.year) two nol

Here the option gmm(invrate, lag(2 .)) specifies that all available lags of invrate dated t-2 and earlier should be used as instruments for the first-differenced equations.

To obtain the two-step estimates with finite-sample corrected standard errors xi: xtabond2 invrate l.invrate i.year , gmm(invrate, lag(2 .)) iv(i.year) r two nol

This produces identical results to those discussed on p.150 of Bond (2002), or pp.14-15 of the Cemmap working paper version.

While we have introduced these Stata commands as interactive commands, for serious use it is recommended that commands are saved and executed from .do files, which allows results to be replicated at a later date. A simple example would be:

set memory 10m

set more off

u c:\lisbon\invrates\invrat1, clear

tsset firm year, yearly

g invrate1 = l.invrate

log using c:\lisbon\invrates\invrat1.log, replace

xi: reg invrate invrate1 i.year, r cl(firm)

xi: xtreg invrate l.invrate1 i.year, fe r cl(firm)

xi: ivreg d.invrate (ld.invrate=ll.invrate) i.year, r cl(firm)

xi: xtabond2 invrate l.invrate i.year, gmm(invrate, lag(2 3)) iv(i.year) r nol

xi: xtabond2 invrate l.invrate i.year, gmm(invrate, lag(2 .)) iv(i.year) r nol

log close

Saved as a text file (e.g. invrat1.do) and executed from within Stata, this produces the main results in all five columns of Table 1, saved in the log file invrat1.log.

Do files can be executed either by clicking File Do, or by using Stata’s do file editor (click the Do File Editor button on Stata’s toolbar). See help do for more information.

ps基本工具介绍【初学者必看】

广军影视2015-11-15 初学者必看 工具介绍 1、移动工具:可以对PS里的图层进行移动。 2、 矩形选框工具:可以对图像选择一个矩形的选择范围 单列选框工具:可以在图像或图层中绘制出1个像素高的横线或竖线区域,主要用于修复图像中丢失的像素。 椭圆选框工具:可以对图片选择一个椭圆或正圆的选择范围。【椭圆变正圆:按着shift 画圆为正圆;按shift+alt是从中心点出发往外画正圆】 3、【取消选区:ctrl+d 或菜单栏【选择】--取消选择】 套索工具:可以用来选区不规则形状的图像【在图像适当的位置单机并按住鼠标左键,拖曳鼠标绘制出需要的选区,松开鼠标左键,选区会自动封闭】 有羽化50所以看到的效果为圆选区) 属性栏红框:为选择方式选项【相加、相减、交叉】。 黄框:用于设定边缘的羽化程度。 白框:用于清除选区边缘的锯齿。 多边形套索工具:可以用来选取不规则的多边形图像(属性与套锁工具相同)【没有圆弧的图像沟边可以用这个工具,但不能勾出弧度】

【使用套索工具选区时,按enter键封闭选区。按ESC键取消选区,按delete键,删除上一个单击建立的选区点。】 磁性套索工具:可以用来选取不规则的并与背景反差大的图像【不须按鼠标而直接移动鼠标,在工具头处会出现自动跟踪的线,这条线总是走向颜色与颜色边界处,边界越明显磁力越强,将首尾相接后可完成选择】 属性:“宽度”选项用于设定套索检测检测范围,磁性套索工具将在这个范围内选取反差最大的边缘。“对比度”选项用于设定选取边缘的灵敏度,数值越大,则要求边缘与背景的反差越大。“频率”选项用于设定选区点的速率,数值越大,标记速率越快,标记点越多。 频率57 频率71 对比度10%

stata命令总结

stata11常用命令 注:JB统计量对应的p大于0.05,则表明非正态,这点跟sktest和swilk 检验刚好相反; dta为数据文件; gph为图文件; do为程序文件; 注意stata要区别大小写; 不得用作用户变量名: _all _n _N _skip _b _coef _cons _pi _pred _rc _weight double float long int in if using with 命令: 读入数据一种方式 input x y 1 4 2 5.5 3 6.2 4 7.7 5 8.5 end su/summarise/sum x 或 su/summarise/sum x,d 对分组的描述: sort group by group:su x %%%%% tabstat economy,stats(max) %返回变量economy的最大值 %%stats括号里可以是:mean,count(非缺失观测值个数),sum(总和),max,min,range, %% sd,var,cv(变易系数=标准差/均值),skewness,kurtosis,median,p1(1%分位 %% 数,类似地有p10, p25, p50, p75, p95, p99),iqr(interquantile range = p75 – p25) _all %描述全部 _N 数据库中观察值的总个数。 _n 当前观察值的位置。 _pi 圆周率π的数值。 list gen/generate %产生数列 egen wagemax=max(wage) clear use by(分组变量)

STATA最常用命令大全

stata save命令 FileSave As 例1. 表1.为某一降压药临床试验数据,试从键盘输入Stata,并保存为Stata格式文件。 STATA数据库的维护 排序 SORT 变量名1 变量名2 …… 变量更名 rename 原变量名新变量名 STATA数据库的维护 删除变量或记录 drop x1 x2 /* 删除变量x1和x2 drop x1-x5 /* 删除数据库中介于x1和x5间的所有变量(包括x1和x5) drop if x<0 /* 删去x1<0的所有记录 drop in 10/12 /* 删去第10~12个记录 drop if x==. /* 删去x为缺失值的所有记录 drop if x==.|y==. /* 删去x或y之一为缺失值的所有记录 drop if x==.&y==. /* 删去x和y同时为缺失值的所有记录 drop _all /* 删掉数据库中所有变量和数据 STATA的变量赋值 用generate产生新变量 generate 新变量=表达式 generate bh=_n /* 将数据库的内部编号赋给变量bh。 generate group=int((_n-1)/5)+1 /* 按当前数据库的顺序,依次产生5个1,5个2,5个3……。直到数据库结束。 generate block=mod(_n,6) /* 按当前数据库的顺序,依次产生1,2,3,4,5,0。generate y=log(x) if x>0 /* 产生新变量y,其值为所有x>0的对数值log(x),当x<=0时,用缺失值代替。 egen产生新变量 set obs 12 egen a=seq() /*产生1到N的自然数 egen b=seq(),b(3) /*产生一个序列,每个元素重复#次 egen c=seq(),to(4) /*产生多个序列,每个序列从1到# egen d=seq(),f(4)t(6) /*产生多个序列,每个序列从#1到#2 encode 字符变量名,gen(新数值变量名) 作用:将字符型变量转化为数值变量。 STATA数据库的维护 保留变量或记录 keep in 10/20 /* 保留第10~20个记录,其余记录删除 keep x1-x5 /* 保留数据库中介于x1和x5间的所有变量(包括x1和x5),其余变量删除keep if x>0 /* 保留x>0的所有记录,其余记录删除

Stata命令整理教学内容

Stata 命令语句格式: [by varlist:] command [varlist] [=exp] [if exp] [in range] [weight] [, options] 1、[by varlist:] *如果需要分别知道国产车和进口车的价格和重量,可以采用分类操作来求得, sort foreign //按国产车和进口车排序 . by foreign: sum price weight *更简略的方式是把两个命令用一个组合命令来写。 . by foreign, sort: sum price weight 如果不想从小到大排序,而是从大到小排序,其命令为gsort。 . sort - price //按价格从高到低排序 . sort foreign -price /*先把国产车都排在前,进口车排在后面,然后在国产车内再按价格从大小到排序,在进口车内部,也按从大到小排序*/ 2、[=exp]赋值运算 . gen nprice=price+10 //生成新变量nprice,其值为price+10 /*上面的命令generate(略写为gen) 生成一个新的变量,新变量的变量名为 nprice,新的价格在原价格的基础上均增加了10 元。 . replace nprice=nprice-10 /*命令replace 则直接改变原变量的赋值,nprice 调减后与price 变量取值相等*/ 3、[if exp]条件表达式 . list make price if foreign==0 *只查看价格超过1 万元的进口车(同时满足两个条件),则 . list make price if foreign==1 & price>10000 *查看价格超过1 万元或者进口车(两个条件任满足一个) . list make price if foreign==1 | price>10000 4、[in range]范围筛选 sum price in 1/5 注意“1/5”中,斜杠不是除号,而是从1 到 5 的意思,即1,2,3,4,5。 如果要计算前10 台车中的国产车的平均价格,则可将范围和条件筛选联合使用。 . sum price in 1/10 if foreign==0 5、[weight] 加权 sum score [weight=num] 其中,num为每个成绩所对应的人数 6、[, options]其他可选项 例如,我们不仅要计算平均成绩,还想知道成绩的中值,方差,偏度和峰度等*/ . sum score, detail . sum score, d //d 为detail 的略写,两个命令完全等价 . list price, nohead //不要表头 Stata 数据类型转换 1、字符型转化成数值型 destring, replace //全部转换为数值型,replace 表示将原来的变量(值)更新 destring date, replace ignore(“ ”) 将字符型数据转换为数值型数据:去掉字符间的空格destring price percent, gen(price2 percent2) ignore(“$ ,%”) 与date 变量类似,变量price 前面有美元符号,变量percent 后有百分号,换为数值型时需要忽略这些非数值型字符 2、数值型转化为字符型

计量经济学的基础工具

第2章计量经济学的基础工具 在第1章中定义了计量经济学的主要工具是数学,包括优化理论和统计分析。这些工具的基础知识是计量经济学的基础知识。尽管这些知识在所有的专业书籍中都可以找到,但是考虑到知识的连贯性和应用的便利,这里将以一章来介绍这些基本知识,以备那些需要的读者参考。关于矩阵部分,主要参考了Sydsaeter,Strom和Berch(2001)的文献,关于概率统计及其推断部分,主要参考了古亚拉提(2000)的文献,古扎拉蒂(2004),Sydsaeter,Strom和Berch(2001)以及王文中(2003)的文献。

第2章 计量经济学的基础工具 ·21· 2.1 矩阵 2.1.1 矩阵的定义 11 12 121 2221 2 n n m m mn a a a a a a a a a ?? ? ? = ? ? ??? L L L L L L L A 称为m n ?阶矩阵,其中a ij 称为位于矩阵的第i 行和第j 列的元素。简记()ij m n a ?=A 。当m n =时,称矩阵为n 阶方阵,A 称为A 的n 阶行列式。如果 0,1,≠?=?=? ij i j a i j 则称该方阵为n 阶单位矩阵,记为I 。有I =1。I 是对角矩阵的特殊形式。一般 的对角矩阵记为 1122diag{,,,}nn a a a =L A 并有 1122=L nn a a a A 矩阵()ij m n a ?=A 的名称是由其元素的变化决定的。比如,所有元素都为0的矩阵叫零矩阵,所有位于主对角线下面的元素均为0,则称A 为上三角矩阵,反之则叫下三角矩阵。定义 11 21112 22212?? ? ? = ? ? ??? L L L L L L L m m n n mn a a a a a a a a a B 为矩阵()ij m n a ?=A 的转置,记为'A 。当m n =时,如果'=A A ,A 称为对称矩阵;如果'=-A A ,A 称为反对称矩阵;如果2=A A ,则A 是幂等矩阵;如果2=A I ,则A 是对合矩阵;若'=A A I ,则A 是正交阵且1=±A ;如果0=A 或0≠A ,则A 称为奇异的或非奇异的。一个高阶矩阵,根据实际需要,可分成若干小块。比如()ij m n a ?=A 可分成四块: 11122122?? = ??? A A A A A

(完整)stata命令总结,推荐文档

stata11 常用命令 注:JB统计量对应的p大于0.05 ,则表明非正态,这点跟sktest 和 swilk 检验刚好相反;dta 为数据文件;gph 为图文件;do 为程序文件;注 意stata 要区别大小写;不得用作用户变量名: _all _n _N _skip _b _coef _cons _pi _pred _rc _weight double float long int in if using with 命令:读入数据一种方式 input x y 14 2 5.5 3 6.2 47.7 58.5 end su/summarise/sum x 或su/summarise/sum x,d 对分组的描述: sort group by group:su x %%%%% tabstat economy,stats(max)%返回变量economy的最大值 %%stats括号里可以是:mean,count(非缺失观测值个数),sum(总 和),max,min,range , %% sd ,var ,cv(变易系数=标准差/ 均值),skewness,kurtosis , median,p1(1 %分位 %% 数,类似地有p10, p25, p50, p75, p95, p99),iqr(interquantile range = p75 –p25) _all %描述全部 _N 数据库中观察值的总个数。 _n 当前观察值的位置。 _pi 圆周率π 的数值。 list gen/generate % 产生数列egen wagemax=max(wage) clear use by(分组变量)

办公软件教程(含wordexcelppt)-从零基础学起

办公软件教程-从零基础学起 Office XP主要包括:字处理软件Word、Excel、PowerPoint等应用程序。它们具有统一的界面、相似的常用工具栏及大同小异的操作方法,只是各自的侧重点有所不同。 Word是文字处理软件。它集成文字处理、表格处理和图形处理于一体,汇集了对各种对象的处理工具,使图片、图表、表格、艺术字等的处理得心应手。 Excel是以表格化数据处理为基础的集成化处理软件。它不但能实现电子表格数据处理,也具有数据库管理、统计图表自动生成等功能。 PowerPoint是创作电子演示文稿的软件。利用它可以方便地制作出集文字、图形、图像、声音、视频和动画于一体的多媒体演示文稿。 一、Word特点

1.对文档提供了多种查看方法; 如:普通视图、页面视图、大纲视图、Web版式视图、文档结构图、全屏显示、Web页预览、打印预览等。 2.具有专业级的表格处理功能; 3.使用方便的多栏彩色图文混排、艺术字处理; 4.具有功能很强的数学公式编辑器; 5.具有多种类型文件的转换功能。 二、窗口介绍 菜单栏、常用工具栏、格式工具栏、正文编辑区、状态栏、标尺、滚动条等。 注:工具栏的显示与隐藏(视图→工具栏→各种工具栏。) 三、页面设置:“文件”→“页面设置”。 1.纸张的大小(常用的纸张:A3、8K、B4、A4、16K、B5。) 2.设置页边距:调整正文到纸张边界[2] []大2小。 四、文档编辑 1.建立文档(Ctrl + N) (1)录入文字,录入时不要排版,每()1一段敲一次回车,每段前空两个汉字位置。(2)特殊符号录入:“插入”→“符号”或用动态键盘。 (3)显示/隐藏文档中的非打印符号。 2.保存文档 (1)保存(Ctrl + S) (2)另存为 3.打开和关闭文件(打开:Ctrl + O) 4.文档选择基本方法 (1)拖动选择

stata命令大全(全)

*********面板数据计量分析与软件实现********* 说明:以下do文件相当一部分内容来自于中山大学连玉君STATA教程,感谢他的贡献。本人做了一定的修改与筛选。 *----------面板数据模型 * 1.静态面板模型:FE 和RE * 2.模型选择:FE vs POLS, RE vs POLS, FE vs RE (pols混合最小二乘估计) * 3.异方差、序列相关和截面相关检验 * 4.动态面板模型(DID-GMM,SYS-GMM) * 5.面板随机前沿模型 * 6.面板协整分析(FMOLS,DOLS) *** 说明:1-5均用STATA软件实现, 6用GAUSS软件实现。 * 生产效率分析(尤其指TFP):数据包络分析(DEA)与随机前沿分析(SFA) *** 说明:DEA由DEAP2.1软件实现,SFA由Frontier4.1实现,尤其后者,侧重于比较C-D与Translog生产函数,一步法与两步法的区别。常应用于地区经济差异、FDI溢出效应(Spillovers Effect)、工业行业效率状况等。 * 空间计量分析:SLM模型与SEM模型 *说明:STATA与Matlab结合使用。常应用于空间溢出效应(R&D)、财政分权、地方政府公共行为等。 * --------------------------------- * --------一、常用的数据处理与作图----------- * --------------------------------- * 指定面板格式 xtset id year (id为截面名称,year为时间名称) xtdes /*数据特征*/ xtsum logy h /*数据统计特征*/ sum logy h /*数据统计特征*/ *添加标签或更改变量名 label var h "人力资本" rename h hum *排序 sort id year /*是以STATA面板数据格式出现*/ sort year id /*是以DEA格式出现*/ *删除个别年份或省份 drop if year<1992 drop if id==2 /*注意用==*/ *如何得到连续year或id编号(当完成上述操作时,year或id就不连续,为形成panel格式,需要用egen命令) egen year_new=group(year) xtset id year_new **保留变量或保留观测值 keep inv /*删除变量*/ **或 keep if year==2000 **排序 sort id year /*是以STATA面板数据格式出现 sort year id /*是以DEA格式出现 **长数据和宽数据的转换 *长>>>宽数据 reshape wide logy,i(id) j(year)

计算机常用工具软件学习

计算机常用工具软件学习一个好的软件,除了给我们带来效率更重要的是为我们带来了快乐。下面我给大家介绍几款实用软件。 一、文件处理软件 软件名称:WinRAR 4.01 简体中文版 support 主要功能: 压缩文件 使用方法: 1.安装与卸载 winRAR的一般下载文件名为wzbeta32.exe,下载后运行该文件,按照系统的提示,选择安装路径、设置界面风格等,一般来说,一路“Enter”即可,winRAR就以默认方式安装到你的电脑上了。如果你觉得winRAR用起来不方便、不习惯,想卸掉它,你可以通过“开始=>程序=>WinRAR=>Uninstall WinRAR”或者通过控制面板的“添加/删除程序”来卸

载它。 2.启动 winRAR安装完成后,会在桌面、开始菜单和文件右键快捷菜单等处设置多种快捷启动方式,并与压缩包建立关联,压缩包的图标也将自动替换成winRAR的图标,以后双击压缩包就可方便地调用WinRAR为你打开压缩包,帮你工作了。 3.新建压缩包 启动winRAR后,让我们先来试试新建立一个压缩包。在标准界面窗口下,鼠标单击程序界面按钮工具条中的“New”,在弹出“New Archive”对话框中设置新建压缩包的名称、压缩的格式(注意,新建立的是空压缩包)等,选择“Add Dialog”复选框(如图4),单击OK,然后就可以在“Add from”列表框中选择需进行压缩打包的文件和文件夹,按“Add”按钮将其添加压缩到刚才建立的空压缩包中了。如果要压缩当前目录下列出的全部文件,点击“Add with wildcards”按钮;如果要保留压缩对象的目录结构,选择使用“Folders”项中的“Save extra folder info”复选框;如果要压缩文件夹及其下的子文件夹,选择“Include subfolders”复选框;要压缩文件夹中隐藏的文件,选择Attributes项中的“Include system and hidden files”复选框。在资源管理器窗口中,使用鼠标右键单击需进行压缩的文件夹,在弹出的菜单中选择“Add to RAR”命令,程序会弹出“Add”对话框,通过这种方式,也可以新建一个压缩包。 4.压缩包的解压 在查看压缩包中的文件时,我们可以在压缩包文件列表窗口中选择需进行解压的文件,点击界面中的“Extract”按钮,进行部分或全部文件的解压。大部分时候,我们不需要打开压缩包的文件,只需要使用鼠标右键单击需要解压的压缩包,然后在弹出的右键菜单中选择“Extract to…”选项,WinRAR将自动启动并让你制定解压后文件的存放文件夹,在弹出的右键菜单中一般还有一项“Extract to+压缩包当前目录/压缩包文件名”的选项,如果选择这一项的话,你就什么都不用费心了,WinRAR将在压缩包当前目录中建立一个新的文件夹,并将压缩包中的文件解压到这个新的文件夹中。 5.文件直接压缩成E-mail附件 为了适应网络对于压缩文档的需求,WinRAR在你选择一些文件或文件夹并单击鼠标右键时会增加一个选项“RAR and E-Mail…”(如图6),选中这个选项,它会自动压缩该文件,并打开默认的电子邮件程序新建一封信件,然后把该压缩包作为一个附件插入,这是以前版本的WinRAR所没有提供的功能。如果想将文件压缩后用电子邮件进行传送,保证你非常喜欢这个功能,因为它简直太方便了。 6.分卷压缩 虽然现在使用软盘的机会很少了,不过WinRAR的分卷压缩功能却一点没有减弱。在建立新的压缩包时,我们在创建压缩包所在盘时选择软盘盘符a:,然后在“Multiple Disk Spanning”下拉文本框中设置分卷压缩方式。其中“Automatic”项自动检测软盘可用空间,并进行分卷压缩文件的创建,一般选择此项。“Automatic +wipe first disk prompt”项自动检测软盘的可用空间,并进行分卷压缩文件的创建。在进行压缩时,提示用户是否删除软盘中已有的数据。在压缩过程中,当一张软盘满了时,WinRAR会提示插入下一张软盘。 二、汉化与翻译软件 软件名称:谷歌金山词霸合作版 2008 V1.186

[推荐] stata基本操作汇总常用命令

[推荐] Stata基本操作汇总——常用命令 help和search都是查找帮助文件的命令,它们之间的 区别在于help用于查找精确的命令名,而search是模糊查找。 如果你知道某个命令的名字,并且想知道它的具体使用方法,只须在stata的命令行窗口中输入help空格加上这个名字。回车后结果屏幕上就会显示出这个命令的帮助文件的全部 内容。如果你想知道在stata下做某个估计或某种计算,而 不知道具体该如何实现,就需要用search命令了。使用的 方法和help类似,只须把准确的命令名改成某个关键词。回车后结果窗口会给出所有和这个关键词相关的帮助文件名 和链接列表。在列表中寻找最相关的内容,点击后在弹出的查看窗口中会给出相关的帮助文件。耐心寻找,反复实验,通常可以较快地找到你需要的内容.下面该正式处理数据了。我的处理数据经验是最好能用stata的do文件编辑器记下你做过的工作。因为很少有一项实证研究能够一次完成,所以,当你下次继续工作时。能够重复前面的工作是非常重要的。有时因为一些细小的不同,你会发现无法复制原先的结果了。这时如果有记录下以往工作的do文件将把你从地狱带到天堂。因为你不必一遍又一遍地试图重现做过的工作。在stata 窗口上部的工具栏中有个孤立的小按钮,把鼠标放上去会出

现“bring do-file editor to front”,点击它就会出现do文件编 辑器。 为了使do文件能够顺利工作,一般需要编辑do文件的“头”和“尾”。这里给出我使用的“头”和“尾”。capture clear (清空内存中的数据)capture log close (关闭所有 打开的日志文件)set more off (关闭more选项。如果打开该选项,那么结果分屏输出,即一次只输出一屏结果。你按空格键后再输出下一屏,直到全部输完。如果关闭则中间不停,一次全部输出。)set matsize 4000 (设置矩阵的最大阶数。我用的是不是太大了?)cd D: (进入数据所在的盘符和文件夹。和dos的命令行很相似。)log using (文件名).log,replace (打开日志文件,并更新。日志文件将记录下所有文件运行后给出的结果,如果你修改了文件内容,replace选项可以将其更新为最近运行的结果。)use (文件名),clear (打开数据文件。)(文件内容)log close (关闭日志文件。)exit,clear (退出并清空内存中的数据。) 实证工作中往往接触的是原始数据。这些数据没有经过整理,有一些错漏和不统一的地方。比如,对某个变量的缺失观察值,有时会用点,有时会用-9,-99等来表示。回归时如果 使用这些观察,往往得出非常错误的结果。还有,在不同的数据文件中,相同变量有时使用的变量名不同,会给合并数

常用到的stata命令

常用到的sta命令 闲话不说了。help和search都是查找帮助文件的命令,它们之间的区别在于help用于查找精确的命令名,而search是模糊查找。如果你知道某个命令的名字,并且想知道它的具体使用方法,只须在sta的命令行窗口中输入help空格加上这个名字。回车后结果屏幕上就会显示出这个命令的帮助文件的全部内容。如果你想知道在sta下做某个估计或某种计算,而不知道具体该如何实现,就需要用search命令了。使用的方法和help类似,只须把准确的命令名改成某个关键词。回车后结果窗口会给出所有和这个关键词相关的帮助文件名和链接列表。在列表中寻找最相关的内容,点击后在弹出的查看窗口中会给出相关的帮助文件。耐心寻找,反复实验,通常可以较快地找到你需要的内容。 下面该正式处理数据了。我的处理数据经验是最好能用sta的do文件编辑器记下你做过的工作。因为很少有一项实证研究能够一次完成,所以,当你下次继续工作时。能够重复前面的工作是非常重要的。有时因为一些细小的不同,你会发现无法复制原先的结果了。这时如果有记录下以往工作的do文件将把你从地狱带到天堂。因为你不必一遍又一遍地试图重现做过的工作。在sta窗口上部的工具栏中有个孤立的小按钮,把鼠标放上去会出现“bring do-file editor to front”,点击它就会出现do文件编辑器。 为了使do文件能够顺利工作,一般需要编辑do文件的“头”和“尾”。这里给出我使用的“头”和“尾”。 /*(标签。简单记下文件的使命。)*/ capture clear(清空内存中的数据) capture log close(关闭所有打开的日志文件) set mem 128m(设置用于sta使用的内存容量) set more off(关闭more选项。如果打开该选项,那么结果分屏输出,即一次只输出一屏结果。你按空格键后再输出下一屏,直到全部输完。如果关闭则中间不停,一次全部输出。) set matsize4000(设置矩阵的最大阶数。我用的是不是太大了?)

PS基础知识入门学习

PS基础知识入门学习 熟悉界面 打开素材中的手提袋图片,可以看到Photoshop的六大界面: 1.需要处理的图像窗口; 2.菜单栏:可以选择其中的命令以对图形进行操作; 3.左边是工具箱:其中是各种绘制图形的工具和辅助工具; 4.工具选项栏:选择绘图工具后可以在这里选择各项参数; 5.右边是各种工作面板:在其中可以对图像进行各种操作; 6.最下面是状态栏:显示了当前对图像进行操作时的各种信息。 绘图与修图技能 1. 工具的使用方法 1)工具箱是工具大体可以分为:选取工具、绘图工具、路径工具、文字工具以及其他的一 些辅助工具。不同工具的使用方法都相似,这里我们使用制作青苹果这个例子来掌握它们的使用方法,效果图如下: 2)新建一个大小600×450像素、名为“青苹果”的图像文件。

3)建立一个图层,建立圆形选区。 4)设置渐变工具。在渐变编辑器中将左端色标设置为(R16,G69,B13),再增加新色标: (R89,G128,B42)位置17%,依次增加其他新色标:(R171,G214,B76)位置36%,(R131,G185,B49)位置55%,(R82,G118,B28)位置74%,(R108,G154,B38)位置100%

5)在工具选项栏中选择径向渐变按钮,在选区中从左上方进行填充。 中选中“动态形状”、“喷枪”和“其他动态”,把“其他动态”设置如下图:

7)工具栏中设置前景色为深棕色后用画笔工具画出苹果柄。 8)用减淡工具绘制苹果的高光。在工具选项栏中选择一种画笔,设置范围为“高光”,曝光 度为“16%”,在苹果上绘制出高光部分,取消选择。 9)最后绘制出投影部分。图层选项设置如下:

Stata统计分析命令

Stata统计分析常用命令汇总 一、winsorize极端值处理 范围:一般在1%和99%分位做极端值处理,对于小于1%的数用1%的值赋值,对于大于99%的数用99%的值赋值。 1、Stata中的单变量极端值处理: stata 11.0,在命令窗口输入“findit winsor”后,系统弹出一个窗口,安装winsor模块 安装好模块之后,就可以调用winsor命令,命令格式:winsor var1, gen(new var) p(0.01) 或者在命令窗口中输入:ssc install winsor安装winsor命令。winsor命令不能进行批量处理。 2、批量进行winsorize极端值处理: 打开链接:https://www.doczj.com/doc/6d1984839.html,/judson.caskey/data.html,找到winsorizeJ,点击右键,另存为到stata中的ado/plus/目录下即可。命令格式:winsorizeJ var1var2var3,suffix(w)即可,这样会生成三个新变量,var1w var2w var3w,而且默认的是上下1%winsorize。如果要修改分位点,则写成如下格式:winsorizeJ var 1 var2 var3,suffix(w) cuts(5 95)。 3、Excel中的极端值处理:(略) winsor2 命令使用说明 简介:winsor2 winsorize or trim (if trim option is specified) the variables in varlist at particular percentiles specified by option cuts(# #). In defult, new variables will be generated with a suffix "_w" or "_tr", which can be changed by specifying suffix() option. The replace option replaces the variables with their winsorized or trimmed ones. 相比于winsor命令的改进: (1) 可以批量处理多个变量; (2) 不仅可以winsor,也可以trimming; (3) 附加了by() 选项,可以分组winsor 或trimming; (4) 增加了replace 选项,可以不必生成新变量,直接替换原变量。 范例: *- winsor at (p1 p99), get new variable "wage_w" . sysuse nlsw88, clear . winsor2 wage *- left-trimming at 2th percentile . winsor2 wage, cuts(2 100) trim *- winsor variables by (industry south), overwrite the old variables . winsor2 wage hours, replace by(industry south) 使用方法: 1. 请将winsor 2.ado 和winsor2.sthlp 放置于stata12\ado\base\w 文件夹下; 2. 输入help winsor2 可以查看帮助文件;

Stata常用15条命令

【命令1】:导入数据 一般做实证分析使用的是excel中的数据,其后缀名为.xls,需要将其修改为.csv insheet using name.csv, clear 【命令2】:删除重复变量 sort var1 var2 duplicatesdrop var1 var2, force 【命令3】:合并数据 use data1, clear merge m:m var1 var2 using data2 drop if _merge==2 drop if _merge==1 drop _merge 【命令4】:描述性统计分析 tabstat var1var2, stat(n min mean median p25 p75 max sd), if groupvar==0 or 1 输出到word中: logout, save(name) word replace: tabstat var, stat(n min mean p50 max sd) col(stat)f(%9.2g) 【命令5】:结果输出 安装 ssc install estout, replace 单个回归 reg y x esttab using name.rtf, compress nogap r2 ar2 star(* 0.1 ** 0.05 *** 0.01) 多个回归一起 reg y x1 est store m1 reg y x2 est store m2 esttab m1 m2 using name.rtf, compress nogap r2 ar2 star(* 0.1 ** 0.05 *** 0.01)

AI CC 基础工具使用详细教程

AI CC 基础工具使用详细教程 我们可以发现AI CC 的工具栏用一条条直线将划分为几个区域,每个区域的工具所具备的功能都很相近,以下就以一个一个区其域进行每个工具功能的叙述: A. 选择工具 1选择工具(V ):选择、移动、缩放图像 功能: ●复制图形: 选择所要复制的图形--按住Alt--拖动所要复制图形到空白位置--即可复制图形 ●精确调整距离:双击选择工具--弹出选择对话框--定制精确距离--复制、预览效 果。 与PS 区别之处: ● Ctrl+Z :可无限次撤销操作●Ctrl+Shift+Z :取消撤销操作 快捷键:(使用任何快捷键时要处于无任何输入法状态下,否则快捷键无效)●Ctrl+D :复制并继续执行上一步动作(复制出相同距离的图形) ●Ctrl+R :标尺 按Ctrl+D 后:

●Ctrl+U:智能参考线 ●按住Shift,操作其他动作(移动、旋转):可以原来10倍的速度改变 ●Shift+Ctrl+Alt+K:键盘快捷键 ●Ctrl+T:调出字符面板 ●Shift+Ctrl+F9:调出路径面板 ●Ctrl+K:首选项面板 2直接选择工具(A):专用于选择锚点 ●同时选择多个锚点 法一:按住Shift,点击选择 法二:直接用鼠标框选 3编组选择工具:针对多个对象 ●与鼠标右键“编组”稍稍有区别,可以结合使用 4魔棒工具(Y):根据颜色不同进行选择,框选出颜色完全一致的所有对象 ●选择对象: 法一:加/减选对象:按住Shift进行选择 法二:(该方法前提是所选对象应有颜色)用魔棒工具点击索要选择对象, 就可以快速选择出与所点击对象颜色完全一致的所有图形 5套索工具:单独选择锚点或者选择一部分的锚点 ●与PS的区别:在AI中无选取这个概念,放开鼠标后,框选区域的线条 自动消失 B.形状工具 1矩形工具 a.圆角矩形: ●AI与PS的区别: AI有分页面区域和草稿区域,也就是说在AI中不是画布的区域(画布外的黑色区域)也可以进行作图,但是保存时并不将草稿区域的内容保存,而在 PS中只可以在画布区域进行作图 ●为什么叫圆角半径? 改变半径就可以改变弧度 ●改变圆角大小 选择圆角矩形工具绘制出所要大小----切记不要放开鼠标----点击上下方 向键:改变圆角大小;点击左方向键:变为直角;点击右方向键:变为

STATA命令应用及详细解释(汇总)

STATA命令应用及详细解释(汇总) 调整变量格式: format x1 .3f ——将x1的列宽固定为10,小数点后取三位format x1 .3g ——将x1的列宽固定为10,有效数字取三位format x1 .3e ——将x1的列宽固定为10,采用科学计数法format x1 .3fc ——将x1的列宽固定为10,小数点后取三位,加入千分位分隔符 format x1 .3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符 format x1 %-10.3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符,加入“-”表示左对齐 合并数据: use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge using "C:\Documents and Settings\xks\桌面\1999.dta" ——将1999和2006的数据按照样本(observation)排列的自然顺序合并起来 use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge id using "C:\Documents and Settings\xks\桌面 \1999.dta" ,unique sort ——将1999和2006的数据按照唯一的(unique)变量id来合并,

在合并时对id进行排序(sort) 建议采用第一种方法。 对样本进行随机筛选: sample 50 在观测案例中随机选取50%的样本,其余删除 sample 50,count 在观测案例中随机选取50个样本,其余删除 查看与编辑数据: browse x1 x2 if x3>3 (按所列变量与条件打开数据查看器)edit x1 x2 if x3>3 (按所列变量与条件打开数据编辑器) 数据合并(merge)与扩展(append) merge表示样本量不变,但增加了一些新变量;append表示样本总量增加了,但变量数目不变。 one-to-one merge: 数据源自stata tutorial中的exampw1和exampw2 第一步:将exampw1按v001~v003这三个编码排序,并建立临时数据库tempw1 clear use "t:\statatut\exampw1.dta" su ——summarize的简写 sort v001 v002 v003 save tempw1

常用到的stata命令

安装estat: ssc install estout,replace\ 2010-10-14 11:38:15来自: 杨囡囡(all a woman lack is a wife) (转自人大论坛) 调整变量格式: format x1 %10.3f ——将x1的列宽固定为10,小数点后取三位 format x1 %10.3g ——将x1的列宽固定为10,有效数字取三位 format x1 %10.3e ——将x1的列宽固定为10,采用科学计数法 format x1 %10.3fc ——将x1的列宽固定为10,小数点后取三位,加入千分位分隔符 format x1 %10.3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符 format x1 %-10.3gc ——将x1的列宽固定为10,有效数字取三位,加入千分位分隔符,加入“-”表示左对齐 合并数据: use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge using "C:\Documents and Settings\xks\桌面\1999.dta" ——将1999和2006的数据按照样本(observation)排列的自然顺序合并起来 use "C:\Documents and Settings\xks\桌面\2006.dta", clear merge id using "C:\Documents and Settings\xks\桌面\1999.dta" ,unique sort ——将1999和2006的数据按照唯一的(unique)变量id来合并,在合并时对id进行排序(sort) 建议采用第一种方法。 对样本进行随机筛选: sample 50 在观测案例中随机选取50%的样本,其余删除 sample 50,count 在观测案例中随机选取50个样本,其余删除 查看与编辑数据:

stata常用命令

面板数据估计 首先对面板数据进行声明: 前面是截面单元,后面是时间标识: tsset company year tsset industry year 产生新的变量:gen newvar=human*lnrd 产生滞后变量Gen fiscal(2)=L2.fiscal 产生差分变量Gen fiscal(D)=D.fiscal 描述性统计: xtdes :对Panel Data截面个数、时间跨度的整体描述 Xtsum:分组内、组间和样本整体计算各个变量的基本统计量 xttab 采用列表的方式显示某个变量的分布 Stata中用于估计面板模型的主要命令:xtreg xtreg depvar [varlist] [if exp] , model_type [level(#) ] Model type 模型 be Between-effects estimator fe Fixed-effects estimator re GLS Random-effects estimator pa GEE population-averaged estimator mle Maximum-likelihood Random-effects estimator 主要估计方法: xtreg: Fixed-, between- and random-effects, and population-averaged linear models xtregar:Fixed- and random-effects linear models with an AR(1) disturbance xtpcse :OLS or Prais-Winsten models with panel-corrected standard errors xtrchh :Hildreth-Houck random coefficients models

相关主题
文本预览
相关文档 最新文档