Stata讲义精要-聂辉华
- 格式:pdf
- 大小:187.29 KB
- 文档页数:28
第一章 Stata 概貌§1.1 Stata的功能、特点和背景Stata是一个用于分析和管理数据的功能强大又小巧玲珑的实用统计分析软件,由美国计算机资源中心(Computer Resource Center)研制。
从1985至1998的十四年时间里,已连续推出1.1,1.2,1.3,1.4,1.5,……及2.0,2.1,3.0,3.1,4.0,5.0,6.0等多个版本,通过不断更新和扩充,内容日趋完善。
它同时具有数据管理软件、统计分析软件、绘图软件、矩阵计算软件和程序语言的特点,又在许多方面别具一格。
Stata融汇了上述程序的优点,克服了各自的缺点,使其功能更加强大,操作更加灵活、简单,易学易用,越来越受到人们的重视和欢迎。
Stata的突出特点是只占用很少的磁盘空间,输出结果简洁,所选方法先进,内容较齐全,制作的图形十分精美,可直接被图形处理软件或字处理软件如WORD等直接调用。
一、 Stata的数据管理能力1.Stata的数据管理空间受计算机的操作系统和计算机扩展内存的影响。
对640k内存的微机,3.1版本的Stata可以管理2400个记录×99个变量,并随计算机扩展内存的增加而增加;对4.0的WINDOWS版本,Stata可以管理4800个记录×99个变量;对WINDOWS 95下的5.0版本,可根据计算机的配置情况设置变量数和记录数,如32M扩展内存的计算机,可处理2千万个数据。
变量数和记录数可以互相交易(trade),即减少记录数可以增加变量数,减少变量数可以增加记录数。
2.可以将分组变量转换成指示变量(哑变量),将字符串变量映射成数字代码。
3.可以对数据文件进行横向和纵向链接,可以将行数据转为列数据,或反之。
4.可以恢复、修改执行过的命令。
5.可以利用数值函数或字符串函数产生新变量。
6.可以从键盘或磁盘读入数据。
二、 Stata的统计功能Stata的统计功能很强,除了传统的统计分析方法外,还收集了近20年发展起来的新方法,如Cox比例风险回归,指数与Weibull回归,多类结果与有序结果的logistic回归,Poisson回归、负二项回归及广义负二项回归,随机效应模型等。
STATA 讲义目录Stata入门教程:Stata概貌Stata 第一章数据输入,存盘和调用文件命令以及数据管理命令Stata第二章 描述性统计命令与输出结果说明Stata第三章 正态检验与作图命令Stata第四章 t检验和单因素方差分析(上)Stata第四章 t检验和单因素方差分析(下)Stata第五章 多组计量资料比较的非参数检验命令与输出结果说明Stata第六章 卡方检验Stata第七章 相 关 分 析Stata第八章 单 因 素 生 存 分 析Stata第九章 多因 素 方 差 分 析 命 令 与 输 出 结 果 说 明Stata第十章 线 性 回 归 和 逐 步 回 归 命 令 和 输 出 结 果 说 明Stata第十一章 Logistic回归分析命令与输出结果说明Stata第十二章 Cox回归分析命令与输出结果说明第一章 Stata 概貌§1.1 Stata的功能、特点和背景Stata是一个用于分析和管理数据的功能强大又小巧玲珑的实用统计分析软件,由美国计算机资源中心(Computer Resource Center)研制。
从1985至1998的十四年时间里,已连续推出1.1,1.2,1.3,1.4,1.5,……及2.0,2.1,3.0,3.1,4.0,5.0,6.0等多个版本,通过不断更新和扩充,内容日趋完善。
它同时具有数据管理软件、统计分析软件、绘图软件、矩阵计算软件和程序语言的特点,又在许多方面别具一格。
Stata融汇了上述程序的优点,克服了各自的缺点,使其功能更加强大,操作更加灵活、简单,易学易用,越来越受到人们的重视和欢迎。
Stata的突出特点是只占用很少的磁盘空间,输出结果简洁,所选方法先进,内容较齐全,制作的图形十分精美,可直接被图形处理软件或字处理软件如WORD等直接调用。
一、 Stata的数据管理能力1. Stata的数据管理空间受计算机的操作系统和计算机扩展内存的影响。
Stata介绍作为流行的计量经济学软件,Stata的功能十分地全面和强大。
可以毫不夸张地说,凡是成熟的计量经济学方法,在Stata中都可以找到相应的命令,而这些命令都有许多选项以适应不同的环境或满足不同的需要。
即使是最详细的Stata手册,也难免有遗珠之憾,更何况本文仅是一个粗浅的介绍。
掌握Stata最好的办法是在实践中学习:Stata 本身提供了非常强大的帮助系统,并且关于Stata的书籍和网络资源都不少。
本文拟根据如下顺序介绍Stata:1.界面;2.文件和数据;3.语法和命令;4.数据管理;5.描述统计;6.画图;7.回归和回归分析;8.常用命令。
第3和第4部分是最体现Stata灵活性的地方,也是应用Stata的基础。
第5和第6部分介绍如何用Stata完成基本的统计功能。
Stata的功能很多,比如回归,曲线拟合,生存分析,主成分分析,因子分析,聚类分析,时间序列分析等等。
但回归无疑是其中最重要的功能。
第7部分介绍如何用Stata作线性回归和Logistic回归。
本文第2和第3部分包含了作者的观点,难免有偏颇之处。
其余部分主要来自文献的归纳和总结。
限于水平有限,错误在所难免,敬请原谅。
1.界面图1 Stata界面Stata有4个窗口:1. Stata Command(右下)用于向Stata输入命令;2. Stata Results(右上)用于显示运行结果;3. Review(左上)记录使用过的命令;4. Variables(左下)显示当前memory中的所有变量。
窗口上方是工具栏,其上的按钮依次为(从左到右)Open, Save, Print Graph/Print Log, Log Start/Stop/Suspend, Bring Log to Front, Bring Graph to Front, Do-file Editor, Data Editor, Data Browser, Clear –more- condition, Break。
STATA BASIC COMMANDS(notes for Junsoo Lee)I. BASICclearset memory 80mcd c:cd \work\statainsheet using water.txtsave water.dta* use water.dtalog using water, replacesummarize _alldescribe _allII. MORE on BASICMemoryC:\stata\wstata /k5000C:\stata\wstata /k5000 set matsize 100C:\stata\wstata /k5000 run c:\data\profile.doData filesInfile x1 x2 x3 using test.txt* only text fileInsheet x1 x2 x3 using text.txt* if saved by spreadsheetsave test, replacesave test, appenduse testlistdescribeLog FileLog using test.logLog using test.log, replaceLog using test.log, appendLog closeLog using test.log, noprocBreakCtrl-K Ctrl-breakRegressionRegress y x1 x2Predict yhatRegress y x1 x2, robustvce* variance-covariancevce, corrmatrix v = get(vce)coeff & predgent asif = _b[const] + _b[ed]*ed + _b[tenure]*tenure testregress y x1 x2test x1 = x2* b1 = b2joint restrictionstest 2*(x1+x2) = 3*x3test x4+x5 = 0, accum* two joint restrictionslr testregress y x1 x2lrtest, saving(0)regress y x1 x2 x3lrtestnon-linear restrictionsregress y x1 x2 x3eq one: 3*_b[x2]^2 = _b[x3]eq two: _b[x3] / _b[x2] = 2testnl one twoBy region: regress y x1 x2By foreign: regress y x1 x2Graph y x1 x2 if foreign ==0, correct(.1) symbol(oi)Graph y x1 x2 if foreign ==1, correct(.1) symbol(oi)t-testttest mpg, by(foreign)* Ho: diff = 0 where foreign is a dummy variableCii 97 24 6* n=97 mean=24 std=6 95 c.i.ttest 97 24 6 22* test Ho: mu = 22ListList x1 if x2 > 20List x1 – x5List x1 x2 if x4 > 10 | (x5>3 & x6 > 10)* ~ = not equal & and | or ~ not >= greater than or equal SortSort mpgCreating new variablesgen lx1 = ln(x1)* if same variable is uses, use “replace”.replace x1 = x1 / 1000Gen x3 = 1.05 * x1 if foreign == 0Replace x3 = 1.20 * x1 if foreign == 1ClearDrop _allMoreSet more offSet more onDescriptive statistics SummarizeSum if mpg > 20Sum if foreign == 0Sum x1, detailBy region: summarize x1 x2 CountCount if x == 1Count if y = float(1.1)* precision issueTabulateTab foreignTab x2 foreignTab x2 foreign, chi2* Pearson chi-square test (df=n-1) CorrelateCorr x1 x2Corr x1 x2 if foreign == 0GraphGraph x1 x2Sort foreignGraph x1 x2, by(foreign) total* three graphs; 0, 1, totalTutorial introTutorial graphicsTutorial survivalTutorial logitLong Line* semi-colon should be used.#delimit;summarize x1 x2if foreign == 1;gen x3 = x1 + x2;#delimit crDo fileDo myjobDo myjob.doDo myjob, nostop* don’t stop even with errorsBatch Jobs* at DOSc:\stata\wstata /b do bigjob.doADO filesWhich fitType c:\stata\ado\f\fit.adoType c:\stata\ado\f\fit.hlpThree places to putOfficial C:\stata\adoPersonal C:\adoCurrent .Global S_ADO “C\stata\ado;d:\ado;.”* to refine pathsmacro list S_ADOCDCd d:Cd \work\dataCd “\work\detailed data”Lags and LeadsGen xlag1 = x[_n-1]Gen xlead1 = x[_n+1]Procedures (Program)Program define helloDisplay “hi there”EndDo helloScoreProbit y x1, x2, score(u)* will be stored in UPoisson Regression (Example provided by Todd)#delimit ;* Poisson regression (Ex. 5.3, Greene, p. 208); * For Junsoo Lee;input id y x ;1 6 1.5;2 7 1.8;3 4 1.8;4 10 2.0;5 10 1.3;6 6 1.6;7 4 1.2;8 7 1.9;9 2 1.8;10 3 1.0;11 6 1.4;12 5 0.5;13 3 0.8;14 3 1.1;15 4 0.7;end;list;* Poisson regression;poisson y x ;Poisson MLE (Example provided by David/Todd)clearinsheet using c:\temp\poisson_data.txtlog using c:\temp\poisson_output.log, replace/* this is the "canned" routine that estimates the poisson regression */ poisson y x/* this maximizes lnL directly, using logged factorial of y */program define poisreg1args lnf thetaquietly replace `lnf' = -exp(`theta') + $ML_y1*(`theta') - lnfact($ML_y1) endml model lf poisreg1 (y=x)ml maximize/* this maximizes lnL directly, using the logged gamma function */program define poisreg2version 6args lnf thetaquietly replace `lnf' = -exp(`theta') + $ML_y1*(`theta') - lngamma($ML_y1 + 1)endml model lf poisreg2 (y=x)ml maximizePanel Estimationclearset memory 40mset more offset matsize 350log using panel.log, replaceuse panel.dta, cleartsset state yearregress y x1 x2 state2-state51 yr82-yr95xtivreg y l1.y x1 x2 yr82-yr95 (l.y = l2.y), i(state) fextivreg y l1.y x1 x2 yr82-yr95 (l.y = l2.y), i(state) fdxtivreg y l1.y x1 x2 yr82-yr95 (l.y = l2.y), i(state) re ec2slsxtabond y x1 x2 yr82-yr95, lags(1)xtabond y x1 x2 yr82-yr95, lags(1) twostep log closeOn-line HelpH weibullHelp for ^brier^。
Stata操作讲义第一讲Stata操作入门第一节概况Stata最初由美国计算机资源中心(Computer Resource Center)研制,现在为Stata公司的产品,其最新版本为7.0版。
它操作灵活、简单、易学易用,是一个非常有特色的统计分析软件,现在已越来越受到人们的重视和欢迎,并且和SAS、SPSS一起,被称为新的三大权威统计软件。
Stata最为突出的特点是短小精悍、功能强大,其最新的7.0版整个系统只有10M左右,但已经包含了全部的统计分析、数据管理和绘图等功能,尤其是他的统计分析功能极为全面,比起1G以上大小的SAS系统也毫不逊色。
另外,由于Stata在分析时是将数据全部读入内存,在计算全部完成后才和磁盘交换数据,因此运算速度极快。
由于Stata的用户群始终定位于专业统计分析人员,因此他的操作方式也别具一格,在Windows席卷天下的时代,他一直坚持使用命令行/程序操作方式,拒不推出菜单操作系统。
但是,Stata的命令语句极为简洁明快,而且在统计分析命令的设置上又非常有条理,它将相同类型的统计模型均归在同一个命令族下,而不同命令族又可以使用相同功能的选项,这使得用户学习时极易上手。
更为令人叹服的是,Stata语句在简洁的同时又拥有着极高的灵活性,用户可以充分发挥自己的聪明才智,熟练应用各种技巧,真正做到随心所欲。
除了操作方式简洁外,Stata的用户接口在其他方面也做得非常简洁,数据格式简单,分析结果输出简洁明快,易于阅读,这一切都使得Stata成为非常适合于进行统计教学的统计软件。
Stata的另一个特点是他的许多高级统计模块均是编程人员用其宏语言写成的程序文件(ADO文件),这些文件可以自行修改、添加和下载。
用户可随时到Stata网站寻找并下载最新的升级文件。
事实上,Stata的这一特点使得他始终处于统计分析方法发展的最前沿,用户几乎总是能很快找到最新统计算法的Stata程序版本,而这也使得Stata自身成了几大统计软件中升级最多、最频繁的一个。
10Listing data and basic command syntaxCommand syntaxThis chapter gives a basic lesson on Stata’s command syntax while showing how to control the appearance of a data list.As we have seen throughout this manual,you have a choice between using menus and dialogs and using the Command window.Although many find the menus more natural and the Command window baffling at first,some practice makes working with the Command window often much faster than using menus and dialogs.The Command window can become a faster way of working because of the clean and regular syntax of Stata commands.We will cover enough to get you started;help language has more information and examples,and [U ]11Language syntax has all the details.The syntax for the list command can be seen by typing help list :list varlistif in ,optionsHere is how to read this syntax:•Anything inside square brackets is optional.For the list command,a.varlist is optional.A varlist is a list of variable names.b.if is optional.The if qualifier restricts the command to run only on those observations for which the qualifier is true.We saw examples of this in [GSW ]6Using the Data Editor .c.in is optional.The in qualifier restricts the command to run on particular observation numbers.d.,and options are optional.options are separated from the rest of the command by a comma.•Optional pieces do not preclude one another unless explicitly stated.For the list command,it is possible to use a varlist with if and in .•If a part of a word is underlined,the underlined part is the minimum abbreviation.Any abbreviation at least this long is acceptable.a.The l in list is underlined,so l ,li ,and lis are all equivalent to list .•Anything not inside square brackets is required.For the list command,only the command itself is required.Keeping these rules in mind,let’s investigate how list behaves when called with different arguments.We will be using the dataset afewcarslab.dta from the end of the previous chapter.list with a variable listVariable lists (or varlist s)can be specified in a variety of ways,all designed to save typing and encourage good variable names.•The varlist is optional for list .This means that if no variables are specified,it is equivalent to specifying all variables.Another way to think of it is that the default behavior of the command is to run on all variables unless restricted by a varlist .•You can list a subset of variables explicitly,as in list make mpg price .•There are also many shorthand notations:m*means all variables starting with m .price-weight means all variables from price through weight in the dataset order.ma?e means all variables starting with ma ,followed by any character,and ending in e .12[GSW]10Listing data and basic command syntax•You can list a variable by using an abbreviation unique to that variable,as in list gear r~o.If the abbreviation is not unique,Stata returns an error message..listmake price mpg weight gear_r~o foreign1.VW Rabbit4697251930 3.78foreign2.Olds988814214060 2.41domestic3.Chev.Monza3667.2750 2.73domestic4.4099222930 3.58domestic5.Datsun5105079242280 3.54foreign6.Buick Regal5189203280 2.93domestic7.Datsun8108129.2750 3.55foreign.l make mpg pricemake mpg price1.VW Rabbit2546972.Olds982188143.Chev.Monza.36674.2240995.Datsun5102450796.Buick Regal2051897.Datsun810.8129.list m*make mpg1.VW Rabbit252.Olds98213.Chev.Monza.4.225.Datsun510246.Buick Regal207.Datsun810..li price-weightprice mpg weight1.46972519302.88142140603.3667.27504.40992229305.50792422806.51892032807.8129.2750[GSW]10Listing data and basic command syntax3.list ma?emake1.VW Rabbit2.Olds983.Chev.Monza4.5.Datsun5106.Buick Regal7.Datsun810.l gear_r~ogear_r~o1. 3.782. 2.413. 2.734. 3.585. 3.546. 2.937. 3.55list with ifThe if qualifier uses a logical expression to determine which observations to use.If the expression is true,the observation is used in the command;otherwise,it is skipped.The operators whose results are either true or false are<less than<=less than or equal==equal>greater than>=greater than or equal!=not equal&and|or!not(logical negation;~can also be used)()parentheses are for grouping to specify order of evaluationIn the logical expressions,&is evaluated before|(similar to multiplication before addition in arithmetic).You can use this in your expressions,but it is often better to use parentheses to ensure that the expressions are evaluated in the proper order.See[U]13.2Operators for complete details.4[GSW]10Listing data and basic command syntax.listmake price mpg weight gear_r~o foreign1.VW Rabbit4697251930 3.78foreign2.Olds988814214060 2.41domestic3.Chev.Monza3667.2750 2.73domestic4.4099222930 3.58domestic5.Datsun5105079242280 3.54foreign6.Buick Regal5189203280 2.93domestic7.Datsun8108129.2750 3.55foreign.list if mpg>22make price mpg weight gear_r~o foreign1.VW Rabbit4697251930 3.78foreign3.Chev.Monza3667.2750 2.73domestic5.Datsun5105079242280 3.54foreign7.Datsun8108129.2750 3.55foreign.list if(mpg>22)&!missing(mpg)make price mpg weight gear_r~o foreign1.VW Rabbit4697251930 3.78foreign5.Datsun5105079242280 3.54foreign.list make mpg price gear if(mpg>22)|(price>8000&gear<3.5)make mpg price gear_r~o1.VW Rabbit254697 3.782.Olds98218814 2.413.Chev.Monza.3667 2.735.Datsun510245079 3.547.Datsun810.8129 3.55.list make mpg if mpg<=22in2/4make mpg2.Olds98214.22In the listings above,we see more examples of Stata treating missing numerical values as large values, as well as the care that should be taken when the if qualifier is applied to a variable with missing values.See[GSW]6Using the Data Editor.[GSW]10Listing data and basic command syntax5 list with if,common mistakesHere is a series of listings with common errors and their corrections.See if you canfind the errors before reading the correct entry..listmake price mpg weight gear_r~o foreign1.VW Rabbit4697251930 3.78foreign2.Olds988814214060 2.41domestic3.Chev.Monza3667.2750 2.73domestic4.4099222930 3.58domestic5.Datsun5105079242280 3.54foreign6.Buick Regal5189203280 2.93domestic7.Datsun8108129.2750 3.55foreign.list if mpg=21=exp not allowedr(101);The error arises because“equal”is expressed by==,not by=.Corrected,it becomes.list if mpg==21make price mpg weight gear_r~o foreign2.Olds988814214060 2.41domesticOther common errors with logic:.list if mpg==21if weight>4000invalid syntaxr(198);.list if mpg==21and weight>4000invalid’and’r(198);Joint tests are specified with&,not with the word and or multiple if s.The if qualifier should be if mpg==21&weight>4000,not if mpg==21if weight>4000.Here is its correction:.list if mpg==21&weight>4000make price mpg weight gear_r~o foreign2.Olds988814214060 2.41domestic6[GSW]10Listing data and basic command syntaxA problem with string variables:.list if make==Datsun510Datsun not foundr(111);Strings must be in double quotes,as in make=="Datsun510".Without the quotes,Stata thinks thatDatsun is a variable that it cannotfind.Here is the correction:.list if make=="Datsun510"make price mpg weight gear_r~o foreign5.Datsun5105079242280 3.54foreignConfusing value labels with strings:.list if foreign=="domestic"type mismatchr(109);Value labels look like strings,but the underlying variable is numeric.Variable foreign takes on values 0and1but has the value label that attaches0to“domestic”and1to“foreign”(see[GSW]9Labeling data).To see the underlying numeric values of variables with labeled values,use the label list command(see[D]label),or investigate the variable with codebook varname.We can correct the error here by looking for observations where foreign==0.There is a second construction that also allows the use of the value label directly..list if foreign==0make price mpg weight gear_r~o foreign2.Olds988814214060 2.41domestic3.Chev.Monza3667.2750 2.73domestic4.4099222930 3.58domestic6.Buick Regal5189203280 2.93domestic.list if foreign=="domestic":originmake price mpg weight gear_r~o foreign2.Olds988814214060 2.41domestic3.Chev.Monza3667.2750 2.73domestic4.4099222930 3.58domestic6.Buick Regal5189203280 2.93domestic[GSW]10Listing data and basic command syntax7 list with inThe in qualifier uses a numlist to give a range of observations that should be listed.numlist s have the form of one number orfirst/last.Positive numbers count from the beginning of the dataset.Negative numbers count from the end of the dataset.Here are some examples:.listmake price mpg weight gear_r~o foreign1.VW Rabbit4697251930 3.78foreign2.Olds988814214060 2.41domestic3.Chev.Monza3667.2750 2.73domestic4.4099222930 3.58domestic5.Datsun5105079242280 3.54foreign6.Buick Regal5189203280 2.93domestic7.Datsun8108129.2750 3.55foreign.list in1make price mpg weight gear_r~o foreign1.VW Rabbit4697251930 3.78foreign.list in-1make price mpg weight gear_r~o foreign7.Datsun8108129.2750 3.55foreign.list in2/4make price mpg weight gear_r~o foreign2.Olds988814214060 2.41domestic3.Chev.Monza3667.2750 2.73domestic4.4099222930 3.58domestic.list in-3/-2make price mpg weight gear_r~o foreign5.Datsun5105079242280 3.54foreign6.Buick Regal5189203280 2.93domesticControlling the list outputThefine control over list output is exercised by specifying one or more options.You can use sepby()to separate observations by variable.abbreviate()specifies the minimum number of characters to abbreviate a variable name in the output.divider draws a vertical line between the variables in the list.8[GSW]10Listing data and basic command syntax.sort foreign.list ma p g f,sepby(foreign)make price gear_r~o foreign1.Olds9888142.41domestic2.Chev.Monza3667 2.73domestic3.Buick Regal5189 2.93domestic4.4099 3.58domestic5.Datsun5105079 3.54foreign6.VW Rabbit4697 3.78foreign7.Datsun8108129 3.55foreign.list make weight gear,abbreviate(10)make weight gear_ratio1.Olds9840602.412.Chev.Monza2750 2.733.Buick Regal3280 2.934.2930 3.585.Datsun5102280 3.546.VW Rabbit1930 3.787.Datsun8102750 3.55.list,dividermake price mpg weight gear_r~o foreign1.Olds9888142140602.41domestic2.Chev.Monza3667.2750 2.73domestic3.Buick Regal5189203280 2.93domestic4.4099222930 3.58domestic5.Datsun5105079242280 3.54foreign6.VW Rabbit4697251930 3.78foreign7.Datsun8108129.2750 3.55foreignThe separator()option draws a horizontal line at specified intervals.When not specified,it defaults to a value of5.[GSW]10Listing data and basic command syntax9.list,separator(3)make price mpg weight gear_r~o foreign1.Olds9888142140602.41domestic2.Chev.Monza3667.2750 2.73domestic3.Buick Regal5189203280 2.93domestic4.4099222930 3.58domestic5.Datsun5105079242280 3.54foreign6.VW Rabbit4697251930 3.78foreign7.Datsun8108129.2750 3.55foreignMoreWhen you see a more prompt at the bottom of the Results window,it means that there is more information to be displayed.This happens,for example,when you are list ing many observations..list make mpgmake mpg1.Linc.Continental122.Linc.Mark V123.Cad.Deville144.Cad.Eldorado145.Linc.Versailles146.Merc.Cougar147.Merc.XR-7148.Peugeot604149.Buick Electra1510.Merc.Marquis1511.Buick Riviera1612.Chev.Impala1613.Dodge Magnum1614.Olds Toronado1615.AMC Pacer1716.Audi50001717.Dodge St.Regis1718.Volvo2601719.Buick LeSabre1820.Dodge Diplomat18moreIf you want to see the next screen of text,you have a few options:press any key,such as the Spacebar;click on the More button,;or click on the blue more at the bottom of the Results window.To see just the next line of text,press Enter.10[GSW]10Listing data and basic command syntaxBreakIf you want to interrupt a Stata command,click on the Break button,.If you see a more prompt at the bottom of the Results window and wish to interrupt it,click on the Break button or press q..list make mpgmake mpg1.Linc.Continental122.Linc.Mark V123.Cad.Deville144.Cad.Eldorado145.Linc.Versailles146.Merc.Cougar147.Merc.XR-7148.Peugeot604149.Buick Electra1510.Merc.Marquis1511.Buick Riviera1612.Chev.Impala1613.Dodge Magnum1614.Olds Toronado1615.AMC Pacer1716.Audi50001717.Dodge St.Regis1718.Volvo2601719.Buick LeSabre1820.Dodge Diplomat18breakr(1);It is always safe to click on the Break button.After you click on Break,the state of the system is the same as if you had never issued the original command.。
Stata及数据处理目录第一章STATA基础 (3)1.1 命令格式 (4)1.2 缩写、关系式和错误信息 (6)1.3 do文件 (6)1.4 标量和矩阵 (7)1.5 使用Stata命令的结果 (8)1.6 宏 (10)1.7 循环语句 (11)1.8 用户写的程序 (15)1.9 参考文献 (15)1.10 练习 (15)第二章数据管理和画图 (18)2.1数据类型和格式 (18)2.2 数据输入 (19)2.3 画图 (21)第3章线性回归基础 (22)3.1 数据和数据描述 (22)3.1.1 变量描述 (23)3.1.2 简单统计 (23)3.1.3 二维表 (23)3.1.4 加统计信息的一维表 (26)3.1.5 统计检验 (26)3.1.6 数据画图 (27)3.2 回归分析 (28)3.2.1 相关分析 (28)3.2.2 线性回归 (29)3.2.3 假设检验 Wald test (30)3.2.4 估计结果呈现 (30)3.3 预测 (34)3.4 Stata 资源 (35)第4章数据处理的组织方法 (36)1、可执行程序的编写与执行 (36)方法1:do文件 (36)方法2:交互式-program-命令 (36)方法3:在do文件中使用program命令 (38)方法4:do文件合并 (39)方法5:ado 文件 (40)2、do文件的组织 (40)3、数据导入 (40)4、_n和_N的用法 (44)第一章STATA基础STATA的使用有两种方式,即菜单驱动和命令驱动。
菜单驱动比较适合于初学者,容易入学,而命令驱动更有效率,适合于高级用户。
我们主要着眼于经验分析,因而重点介绍命令驱动模式。
图1.1Stata12.1的基本界面关于STATA的使用,可以参考Stata手册,特别是[GS] Getting Started with Stata,尤其是第1章A sample session和第2章The Stata User Interface。