stata上机实验第二讲
- 格式:ppt
- 大小:344.00 KB
- 文档页数:15
计量经济学stata上机教程2014计量经济学上机教程1Stata操作基础主要内容:1. Stata的特点与功能2. Stata的界面管理3. Stata的命令语法4. 数据处理5. 统计描述、制图与输出结果6. log文档与do文档7. 常用函数8. Stata的帮助系统与学习资源9. 课后练习1. Stata的特点与功能, 将统计功能与计量分析完整地结合起来。
不仅可以实现诸多统计分析方法,比如描述统计、假设检验、方差分析、主成分分析等,而且可以实现多种计量经济模型的估计和检验,包括经典单方程回归模型、方程组模型、微观数据模型(离散选择模型、计数模型、截断模型、归并模型等)、时间序列数据模型(ARMA、VAR、GARCH等)以及面板数据分析。
, 强大的数据处理功能。
, 精致的作图功能。
, 丰富的网络资源。
Stata 12有各种版本,其中尤以SE(特殊版)最为常用。
用户可以在命令栏中输入about命令查看所安装的版本信息。
2--per ml sodium hydroxide [c (NaOH) =1.000 mol/L] potassium hydrogen phthalate standard solution of quality g. ... After dilution to 1000mL. 1.1.2 0.000 35mol/L iodine solution: dissolve 20 g of potassium iodide in Cheng You (30~40) 500mL mL water bottle; 5mL iodine stock solution, and then diluted to scale and mix. This solution every other day to prepare. 1.1.3 acetate buffer (PH5.3): dissolve 87g sodium acetate (CH3COONa • 3H2O) 400mL water and 10.5mL in glacial acetic acid is dissolved in a small amount of water. volume and then mixing the two together and add water to 500mL, using regulation to PH5.3. 1.1.40.5mol/L sodium chloride: 14.5 g of sodium chloride dissolved in boiled water, and constant volume to 500mL. 1.1.5 soluble starch: pure before use should determine its value. Accurate said take amount starch (equivalent to dry state 1g) Yu 250mL high type beaker in the, added80~90mL distilled water, Yu asbestos online in constantly mixing Xia quickly heating to boiling, then with fire keep micro-boiling 3min, stamped and cooling to at room temperature, transfer to 100mL capacity bottle in the, into 40 ? water bath in the makes solution reached this temperature, and in 40 ? Shi with distilled water (40 ?) set capacity, this starch solution placed 40 ? thermostat water bath in the for determination samples with. 1.2 the instrument a) constant temperaturewater bath: (40+-0.2) 0C. B) spectrophotometer. 1.3 procedures 1.3.1 preparation of samples: weighing 50mL 10G sample不同的版本对于样本容量、变量个数、矩阵阶数等有着不同的限制,用户可以通过以下命令了解和改变这些设定:memory 显示目前存储空间query memory 查看目前实际设定的存储空间set memory 10m 设定存储空间的大小set matsize 250 设定最大矩阵阶数set maxvar 2500 设定最大变量数(最小设定为2048)help limits 显示Stata的各种极限 2. Stata的界面管理, 首次打开Stata,将会出现一个询问是否进行更新的对话框。
Lab 2Four topics :Do file , Data Management, Graphics and Test after estimation1 Do file⏹s tore the commands in a file⏹s ame as Program Editor in SAS⏹s ame as m-file in MATLABthe grammar of STATA:[by varlist:] command [varlist] [=exp] [if exp] [in range] [weight][using filename] [, options] Example : create a do file and save it2 Data Management(1) Stata commands in this unitcd Change directorymemory Display a report on memory usageset memory Set the size of memoryinfile Read unformatted ASCII (text) dataclear Clear the entire dataset and everything elseinput Enter data from keyboardsave Store the dataset currently in memory on disk in Stata data formatuse Load a Stata-format dataset describe Describe contents of data in memory or on diskcount Show the number of observations list List values of variableslabel data Apply a label to a data set label variable Apply a label to a variablerename Rename a variable generate Creates a new variable keep if Keep observations if condition is metkeep Keep variables orobservationsdrop Drop variables or observationsappend Append a data file to current filesort Sort observationsmerge Merge a data file with current file(2) Example:cd d:\stata /*the folder of my Stata dataset*/ memoryset memory 200minfile str20 month RM_RF SMB HML RF using ff.txt, clearinput id str20 name math1 “Jim”952 “Lucy”803 “Li Lei”90endsave math1input id str20 name math4 “Carl”100endsave math2input id str20 name economics1 “Jim”902 “Lucy”903 “Li Lei”854 “Carl”95endsave economicsuse math1describecountlistuse math1label data “grade”label variable id “the student ID”label variable name “the student name”label variable math “the student grade of math”rename math Chineserename Chinese mathgen meanmath=90gen devmath=math-meanmathuse GPA, clearkeep if female==1keep id sat race term blackdrop race blackuse math1, cleardrop meanmath devmathappend using math2save, replaceuse math1, clearsort idsave, replaceuse economics, clearsort idsave, replaceuse math1, clearmerge id using economicssave gradeuse grade, clearlist3 Graphics(1) Benchmark[graph] twoway plot [if] [in] [, twoway_options]plot is[(] plottype varlist ..., options [)] [||](2)plottypescatterlinelfitqfitlfitci(3) example: CEO Salary and Return on Equityuse ceosal1, cleargraph twoway scatter salary roetwoway (scatter salary roe) (lfit salary roe)tw (scatter salary roe) (qfit salary roe)tw (scatter salary roe) (lfitci salary roe)tw function x^2, ra(-10 10)4 Test after estimation⏹t est coeflist⏹t est exp=exp[=...]ExampleEx 4.1use wage1, clearreg lwage educ exper tenure test educ=0.1di (0.092029-0.1)/0 .0073299 Ex 4.。
Stata操作讲义知识讲解S t a t a操作讲义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 自身成了几大统计软件中升级最多、最频繁的一个。
实验(实训)报告项目名称多元回归模型的矩阵计算所属课程名称应用回归分析项目类型验证性实验实验(实训)日期11年10月22 日班级09统计1学号姓名指导教师浙江财经学院教务处制实验二报告多元回归模型的矩阵计算(验证性实验)实验类型:验证性实验实验目的:使学生学会用stata 软件掌握多元回归模型的相关矩阵的计算。
实验内容:多元回归模型的矩阵计算 实验要求:运用Stata 计算多元回归的矩阵计算,按具体的题目要求完成实验报告。
并及时上传到给定的FTP !实验题目: [abstracted from 《Applied Linear Regression Models 》 (FourthEdition) chapter6 Problems 6.27]In a small-scale regression study ,the following data obtained:Using matrix methods , obtaina. βˆ b. e c. P, M d. SSR, SSEe. )(ˆ),ˆ(ˆe ar V ar Vβ f. 30,10ˆ20100==x x when yg. 30,10)ˆ(ˆ20100==x x when y ar Vh. R 2, F实验题目分析报告:a. egen one=fill(1,1). browse. mkmat y,mat(y). mkmat one x1 x2 ,mat(x). mat b=inv(x'*x)*x'*y. mat list bb[3,1]yone 33.932103x1 2.7847614x2 -.26441893b. mat m=I(6)-x*inv(x'*x)*x'. mat e=m*y. mat list ee[6,1]yr1 -2.6996084r2 -1.2299728r3 -1.6373532r4 -1.32986r5 -.08999801r6 6.9867923c. mat p=x*inv(x'*x)*x'. mat list psymmetric p[6,6]r1 r2 r3 r4 r5 r6r1 .23143293r2 .25167585 .31240459r3 .21178735 .09437844 .70442026r4 .14886839 .26627729 -.31917435 .61425632r5 -.05475543 -.14787283 .10446672 .14143492 .94039955r6 .21099091 .22313666 .20412159 .14833743 .01632707 .19708635. mat m=I(6)-p. mat list msymmetric m[6,6]r1 r2 r3 r4 r5 r6 r1 .76856707r2 -.25167585 .68759541 r3 -.21178735 -.09437844 .29557974r4 -.14886839 -.26627729 .31917435 .38574368 r5 .05475543 .14787283 -.10446672 -.14143492 .05960045 r6 -.21099091 -.22313666 -.20412159 -.14833743 -.01632707 .80291365 d. mat i=J(6,1,1). mat m0=I(6)-i*inv(i'*i)*i' . mat ssr=e'*e . mat yhat=p*y. mat sse=yhat'*m0*yhat . mat sst=y'*m0*y . mat list ssesymmetric sse[1,1] yy 3009.9265 . mat list ssrsymmetric ssr[1,1] yy 62.073538 . mat list sstsymmetric sst[1,1] yy 3072 e=2ˆδ62.073538/3=20.6912)ˆ(ˆβar V=20.6912* one x1 x2 one 34.578557 x1 -1.6508927 .08030796 x2 -.65704022 .03112763 .01268501 =onex1 x2one 715.47114 x1 -34.158917 1.6616664 x2 -13.594937 .64406737 .26246775)(ˆe ar V= r1 r2 r3 r4 r5 r6 r1 15.902559 r2 -5.2074701 14.22716 r3 -4.38213 -1.9528013 6.1158935 r4 -3.0802625 -0 5.5095913 6.6040938 7.9814916 r5 1.1329543 3.0596634 -2.1615395 -2.9264554 1.2332036 r6 -4.3656507 -4.6169606 -4.2235164 -3.0692763 -.33782638 16.61323f12ˆ33.932 2.7850.264i i i yx x =+- 时当30,102010==x x ,y0=53.862g)ˆ(ˆ0y ar V=79.653hR2=sse/sst =0.9798F=-0.758。
第六章第二题:1. 建立完成的教育年数(ED )对到最近大学的距离(Dist )的回归:. reg ed dist, robust斜率估计值是:-0.0732. reg ed dist bytest female black hispanic incomehi ownhome dadcoll cue80 stwmfg80,robustDist 对ED 的效应估计是:-0.0323. 系数下降50%,存在很大差异,(1)中回归存在遗漏变量偏差4. di e(r2_a)(可看到调整后的R2)第一问中=0.0074 调整的2R =0.00718796_cons 13.95586 .0378112 369.09 0.000 13.88172 14.02999dist -.0733727 .0134334 -5.46 0.000 -.0997101 -.0470353ed Coef. Std. Err. t P>|t| [95% Conf. Interval]RobustRoot MSE = 1.8074R-squared = 0.0074Prob > F = 0.0000F( 1, 3794) = 29.83Linear regression Number of obs = 3796. reg ed dist , robust2R第二问中=0.2788 2R = 0.27693235可以得到第二问中的拟合效果要优于第一问。
第二问中相似的原因:因为n 很大。
5. Dadcoll 父亲有没有念过大学:系数为正(0.6961324)衡量父亲念过大学的学生接受的教育年数平均比其父亲没有年过大学的学生多。
-.0517777 1)原因:这些参数在一定程度上构成了上大学的机会成本。
2)它们的系数估计值的符号应该如此。
当Stwmfg80增加时,放弃的工资增加,所以大学入学率降低了;因而Stwmfg80的系数对应为负。
实验指导书武汉理工大学政治与行政学院2013年4月实验一STATA基本介绍实验目的掌握什么是STATA?该软件具有什么功能?熟悉STATA菜单各项的含义,数据输入、存储以及数据运算与处理等。
实验内容1.什么是STATA2.STATA的菜单3.数据输入与保存4、数据文件的合并与汇总5.数据编辑整理6.变量重新赋值7.数据的运算与新变量的生成8.数据的排序9.数据分组基本步骤当打开STATA后,展现在我们面前的界面如下:菜单栏共有11个选项,常用的有以下8个选项:1.文件:文件管理菜单,有关文件的调入、存储、显示和打印等;2.编辑:编辑菜单,有关文本内容的选择、拷贝、剪贴、寻找和替换等; 3.显示:显示菜单,有关状况栏、工具条、网格线是否显示,以及数据显示的字体类型、大小等设置;4.数据:数据管理菜单,有关数据变量定义、数据格式选定、观察对象的选择、排序、加权、数据文件的转换、连接、汇总等;5.转换:数据转换处理菜单,有关数值的计算、重新赋值、缺失值替代等;6.分析:统计菜单,有关一系列统计方法的应用;7.图形:作图菜单,有关统计图的制作;8.使用程序:用户选项菜单,有关命令解释、字体选择、文件信息、定义输出标题、窗口设计等;实验报告自己草拟10名学生的序号、姓名、统计学成绩、管理学成绩、每天学习时间特征资料。
(以自己的姓名作为第一号,并以自己的名字设为文件名)要求:(1)添加性别数据特征;粘贴处(2)按统计学成绩由高到低排序;粘贴处(3)按统计学成绩数量标志进行等距分组,并进行汇总统计。
粘贴处(4)计算生成统计学与管理学两科的总成绩与平均成绩两个变量。
粘贴处实验二STATA统计绘图实验目的掌握条形图、线形图、散点图、直方图等常用统计图的绘制方法与技巧。
实验内容1.条形图2.线形图单线形图(Simple)多线形图(Multiple)垂线形图(Drop-line)3.散点图简单散点图(Simple)——显示一对相关变量关系;重叠散点图(Overlay) ——显示多对相关变量关系;矩阵散点图(Matrix) ——显示多个相关变量关系;3维散点图(3-D) ——显示3个相关变量关系。
Lab 2Four topics :Do file , Data Management, Graphics and Test after estimation1 Do file⏹s tore the commands in a file⏹s ame as Program Editor in SAS⏹s ame as m-file in MATLABthe grammar of STATA:[by varlist:] command [varlist] [=exp] [if exp] [in range] [weight][using filename] [, options] Example : create a do file and save it2 Data Management(1) Stata commands in this unitcd Change directorymemory Display a report on memory usageset memory Set the size of memoryinfile Read unformatted ASCII (text) dataclear Clear the entire dataset and everything elseinput Enter data from keyboardsave Store the dataset currently in memory on disk in Stata data formatuse Load a Stata-format dataset describe Describe contents of data in memory or on diskcount Show the number of observations list List values of variableslabel data Apply a label to a data set label variable Apply a label to a variablerename Rename a variable generate Creates a new variable keep if Keep observations if condition is metkeep Keep variables orobservationsdrop Drop variables or observationsappend Append a data file to current filesort Sort observationsmerge Merge a data file with current file(2) Example:cd d:\stata /*the folder of my Stata dataset*/ memoryset memory 200minfile str20 month RM_RF SMB HML RF using ff.txt, clearinput id str20 name math1 “Jim”952 “Lucy”803 “Li Lei”90endsave math1input id str20 name math4 “Carl”100endsave math2input id str20 name economics1 “Jim”902 “Lucy”903 “Li Lei”854 “Carl”95endsave economicsuse math1describecountlistuse math1label data “grade”label variable id “the student ID”label variable name “the student name”label variable math “the student grade of math”rename math Chineserename Chinese mathgen meanmath=90gen devmath=math-meanmathuse GPA, clearkeep if female==1keep id sat race term blackdrop race blackuse math1, cleardrop meanmath devmathappend using math2save, replaceuse math1, clearsort idsave, replaceuse economics, clearsort idsave, replaceuse math1, clearmerge id using economicssave gradeuse grade, clearlist3 Graphics(1) Benchmark[graph] twoway plot [if] [in] [, twoway_options]plot is[(] plottype varlist ..., options [)] [||](2)plottypescatterlinelfitqfitlfitci(3) example: CEO Salary and Return on Equityuse ceosal1, cleargraph twoway scatter salary roetwoway (scatter salary roe) (lfit salary roe)tw (scatter salary roe) (qfit salary roe)tw (scatter salary roe) (lfitci salary roe)tw function x^2, ra(-10 10)4 Test after estimation⏹t est coeflist⏹t est exp=exp[=...]ExampleEx 4.1use wage1, clearreg lwage educ exper tenure test educ=0.1di (0.092029-0.1)/0 .0073299 Ex 4.。
计量经济学stata上机教程2014计量经济学上机教程1Stata操作基础主要内容:1. Stata的特点与功能2. Stata的界面管理3. Stata的命令语法4. 数据处理5. 统计描述、制图与输出结果6. log文档与do文档7. 常用函数8. Stata的帮助系统与学习资源9. 课后练习1. Stata的特点与功能, 将统计功能与计量分析完整地结合起来。
不仅可以实现诸多统计分析方法,比如描述统计、假设检验、方差分析、主成分分析等,而且可以实现多种计量经济模型的估计和检验,包括经典单方程回归模型、方程组模型、微观数据模型(离散选择模型、计数模型、截断模型、归并模型等)、时间序列数据模型(ARMA、VAR、GARCH等)以及面板数据分析。
, 强大的数据处理功能。
, 精致的作图功能。
, 丰富的网络资源。
Stata 12有各种版本,其中尤以SE(特殊版)最为常用。
用户可以在命令栏中输入about命令查看所安装的版本信息。
2--per ml sodium hydroxide [c (NaOH) =1.000 mol/L] potassium hydrogen phthalate standard solution of quality g. ... After dilution to 1000mL. 1.1.2 0.000 35mol/L iodine solution: dissolve 20 g of potassium iodide in Cheng You (30~40) 500mL mL water bottle; 5mL iodine stock solution, and then diluted to scale and mix. This solution every other day to prepare. 1.1.3 acetate buffer (PH5.3): dissolve 87g sodium acetate (CH3COONa • 3H2O) 400mL water and 10.5mL in glacial acetic acid is dissolved in a small amount of water. volume and then mixing the two together and add water to 500mL, using regulation to PH5.3. 1.1.40.5mol/L sodium chloride: 14.5 g of sodium chloride dissolved in boiled water, and constant volume to 500mL. 1.1.5 soluble starch: pure before use should determine its value. Accurate said take amount starch (equivalent to dry state 1g) Yu 250mL high type beaker in the, added80~90mL distilled water, Yu asbestos online in constantly mixing Xia quickly heating to boiling, then with fire keep micro-boiling 3min, stamped and cooling to at room temperature, transfer to 100mL capacity bottle in the, into 40 ? water bath in the makes solution reached this temperature, and in 40 ? Shi with distilled water (40 ?) set capacity, this starch solution placed 40 ? thermostat water bath in the for determination samples with. 1.2 the instrument a) constant temperaturewater bath: (40+-0.2) 0C. B) spectrophotometer. 1.3 procedures 1.3.1 preparation of samples: weighing 50mL 10G sample不同的版本对于样本容量、变量个数、矩阵阶数等有着不同的限制,用户可以通过以下命令了解和改变这些设定:memory 显示目前存储空间query memory 查看目前实际设定的存储空间set memory 10m 设定存储空间的大小set matsize 250 设定最大矩阵阶数set maxvar 2500 设定最大变量数(最小设定为2048)help limits 显示Stata的各种极限 2. Stata的界面管理, 首次打开Stata,将会出现一个询问是否进行更新的对话框。