计量经济学Stata软件应用2---【Stata软件之回归分析】--2次课分解
STATA软件操作相关与回归分析
![STATA软件操作相关与回归分析](https://img.taocdn.com/s3/m/abbb9e45cd1755270722192e453610661ed95ad5.png)
STATA软件操作相关与回归分析一、相关分析相关分析用于研究两个变量之间的相关性。
在STATA中,可以使用命令"correlate"进行相关分析。
语法:correlate 变量列表例子:我们以一个示例数据集"auto"为例,研究汽车价格与里程数和马力之间的相关性。
```sysuse autocorrelate price mpg turn```上述命令将计算汽车价格(price)与里程数(mpg)和轮胎转向(turn)之间的相关系数。
输出结果将显示相关系数矩阵,其中包括Pearson相关系数、Spearman相关系数和Kendall相关系数。
二、简单线性回归简单线性回归分析用于研究一个因变量和一个自变量之间的关系。
在STATA中,可以使用命令“regress”进行简单线性回归分析。
语法:regress 因变量自变量例子:我们继续使用上述示例数据集"auto",研究汽车价格与里程数之间的关系。
```sysuse autoregress price mpg```上述命令将进行汽车价格(price)与里程数(mpg)之间的简单线性回归分析。
输出结果将包括回归系数估计值、拟合优度、标准误差、t值、P值等。
另外,使用命令“predict”可以进行预测。
例子:我们可以使用上述回归模型,对新数据进行价格的预测。
```predict new_price, x```上述命令将对新数据集中的里程数进行预测,并将结果保存在新的变量new_price中。
三、多元回归分析多元回归分析用于研究一个因变量和多个自变量之间的关系。
在STATA中,可以使用命令“regress”进行多元回归分析。
语法:regress 因变量自变量1 自变量2 ...例子:我们使用示例数据集"auto",研究汽车价格与里程数、马力和重量之间的关系。
```sysuse autoregress price mpg displacement weight```上述命令将进行汽车价格(price)与里程数(mpg)、马力(displacement)和重量(weight)之间的多元线性回归分析。
金融数据库如何使用STATA做回归分析 ppt课件
![金融数据库如何使用STATA做回归分析 ppt课件](https://img.taocdn.com/s3/m/3b5a5c8b10a6f524cdbf8546.png)
行观测得到
• 通常情况下,社会科学使用非实验数据。
金融数据库如何使用STATA做回归 分析
数据类型
• 时间序列:变量由不同时间的观测值构成。如1993年至 2015年股票价格,GDP, CPI,汽车销售量。
• 横截面数据:在某个时点对个人、企业、家庭、国家等个 体采集样本形成的数据。如某时点股票价格、GDP, CPI, 汽车销售量,某年份个人、家庭收入,企业销售额。
– 多元回归,回归分析推断,大样本理论 – 虚拟变量回归 – 异方差,自相关
• 使用STATA做多元回归分析
– 数据导入、描述、画图 – 回归分析、回归诊断
金融数据库如何使用STATA做回归 分析
教材
• 计量经济学
– 伍德里奇,计量经济学导论,人民大学出版社 – Chattefueer & Hadi, Regression Analysis by Sample – Stock & Watson, 计量经济学导论 – Jonhnston: Econometric Methods
–
金融数据库如何使用STATA做回归 分析
国内常用微观数据5
• 中国家庭动态跟踪调查数据。( Chinese Family Panel Studies, CFPS) 。
– 是北京大学中国社会科学调查中心(ISSS)实施的一项旨在通过跟 踪搜集个体、家庭、社区三个层次的数据,反映中国社会、经济、 人口、教育和健康的变迁。2008年在北京、上海、广东的展开探 索性调查,调查规模为2400户;2009年在北京、上海、广东三地 展开工具性测试跟踪调查,测试CAPI技术、调查进程实时管理技 术、调查进程实时技术支持系统、数据质量实时监控技术的稳定 性和可靠性。2010年在全国(西藏、青海、新疆、宁夏、内蒙古、 海南、香港、澳门、台湾不在其列)正式实施,调查规模为 16000户,每年一次跟踪调查。
回归分析及Stata软件应用
![回归分析及Stata软件应用](https://img.taocdn.com/s3/m/d0bbd8a918e8b8f67c1cfad6195f312b3169ebd1.png)
阅读感受
在阅读这本书的过程中,我不仅学会了如何进行回归分析,还学会了如何更 有效地使用Stata软件。这些知识和技能将对我的未来学习和职业生涯产生积极 的影响。我相信这本书对于其他读者也会有很大的帮助,无论是初学者还是有一 定经验的统计学者。
目录分析
目录分析
在当今的统计分析领域,回归分析是一种广泛应用的方法,用于探索变量之 间的关系,以及预测和解释数据的变化。而Stata软件则是一款功能强大且易用 的统计软件,被广泛应用于各种数据分析和处理任务中。《回归分析及Stata软 件应用》这本书,以其独特的视角和实用的方法,为读者提供了回归分析和 Stata软件应用方面的深入指导。
目录分析
在这一章中,本书介绍了一些高级的回归分析方法,包括多重共线性处理、 交互效应模型、时间序列回归模型等。还介绍了如何在Stata中实现这些方法。
目录分析
在这一章中,本书详细介绍了Stata编程的基础知识和自定义函数的编写方法。 通过学习这一章,读者可以了解如何编写自己的Stata程序,以实现更复杂的分 析和数据处理任务。
阅读感受
《回归分析及Stata软件应用》是一本理论与实践相结合的好书。它不仅提供 了回归分析的基础知识,还通过Stata软件的应用展示了如何在实际问题中应用 这些知识。这本书的案例和实例非常丰富,使得我可以深入理解回归分析的应用 场景和技巧。书中的软件操作指南也为我提供了极大的帮助,让我可以轻松地使 用Stata软件进行各种统计分析任务。
精彩摘录
Stata软件是一款功能强大的统计分析软件,广泛应用于各种领域。它可以帮 助用户完成从数据管理到高级统计分析的各种任务。Stata软件支持多种回归分 析方法,包括线性回归、逻辑回归、有序回归等。
精彩摘录
计量经济学Stata软件应用【Stata软件之回归分析】次课PPT课件
![计量经济学Stata软件应用【Stata软件之回归分析】次课PPT课件](https://img.taocdn.com/s3/m/ce96aa78f705cc17552709cb.png)
obs:
1,225
vars:
11
25 Aug 2009 08:38
size:
58,800 (99.4% of memory free)
storage display variable name type format
value label
variable label
age female married edulevel
y 1xu
即假定截距系数 0 0 时,该模型被称为过原点回归;过 原点回归在实际中有一定的应用,但除非有非常明确的理 论分析表明 0 0 ,否则不宜轻易使用过原点回归模型。
.
4
二、简单回归分析的Stata基本命令
➢ regress y x 以 y 为被解释变量,x 为解释变量进行普通最小二乘 (OLS)回归。regress命令可简写为横线上方的三个字 母reg。
结果显示“工资方程1.dta”数据文件包含1225个样本和11个 变
量;11个变量的定义及说明见第3列。
.
8Hale Waihona Puke 三、简单回归分析的Stata软件操作实例
3、变量的描述性统计分析。对于定量变量,使用summarize 命令:su age edu exp expsq wage lnwage,得到以下运行结 果,保存该运行结果;
2、给出数据的简要描述。使用describe命令,简写为: des 得到以下运行结果;
.
7
三、简单回归分析的Stata软件操作实例
Contains data fromD:\½²¿Î×ÊÁÏ\ÖÜÝíµÄÉÏ¿Î×ÊÁÏ\Êý¾Ý\¡¾ÖØÒª¡¿\¡¾¼ÆÁ¿¾¼ÃѧÈí¼þÓ¦Ó
> ÿμþ¡¿\10649289\stata10\¹¤×Ê·½³Ì1.dta
第二讲stata画图和线性回归基础
![第二讲stata画图和线性回归基础](https://img.taocdn.com/s3/m/e0a64734caaedd3383c4d372.png)
例三:我国某地区1955---1984农产品收购 量sg、库存量kc存放在文件 warehouse.dta中
估计如下方程:
Sgt=a+b0kct+b1kct-1+u 存
220 240 260消费280 300 320
1
250
OLS原理
11
10
9 8
7
6
5
4 2
3
300
350
400
年收入
垂直线
拟合线
消费
Y 0 1X1 2 X2 k Xk u
Y Xβ μ
OLS假设条件:
1. E[u|X] = 0 2. 条件同方差、没有序列自相关 3. X与u不相关 4. Y和X之间存在线性关系。 5. 解释变量 X 是非随机变量,被解释变量Y
是随机变量。 6. X 是满秩的, rank(X) = k
我们得到:
βˆ (X' X)1 X'y
习惯上我们用 y_hat = X*b (被解释变量的拟合值) e = Y - y_hat = Y - Xb ( 残差 )
建立回归方程
打开系统文件auto,建立如下方程: regress命令详解: regress depvar [indepvars] [if] [in] [weight] [, options]
组合图形
画出price与weight的散点图,并画出其拟 合线。
图形界面设计:
图形标题,X轴标志,Y轴标志,样式选择, 图例,分组标志。
两个练习:
1。完成下列汽车拟合图。 2。查阅数据,并按照要求完成图形。
改上面五个标注,用twoway graph里面的legend (override default keys): 1 "国产车" 2 "进口车" 3 "国 产车拟合" 4 "进口车拟合" 5 "整体拟合"
计量经济学Stata软件应用2---【Stata软件之回归分析】--2次课
![计量经济学Stata软件应用2---【Stata软件之回归分析】--2次课](https://img.taocdn.com/s3/m/ff4a5a29bcd126fff7050bd5.png)
Std. Err. .0488491 .4589088
[95% Conf. Interval] .2979069 2.684359 .4895815 4.485031
(1) 表下方区域为基本的回归结果。第1列依次为被解释变量wage,解释 变量edu,截距项constant;第2列回归系数的OLS估计值;第3列回归系 数的标准误;第4列回归系数的 t 统计量值; 写出样本回归方程为: wage 3.5847 0.3937edu ˆ
三、简单回归分析的Stata软件操作实例
Contains data from D:\´²¿Î×ÊÁÏ\ÖÜÝíµÄÉÏ¿Î×ÊÁÏ\Êý¶Ý\¡¶ÖØÒª¡¿\¡¶µÆÁ¿¶µÃѧÈíµþÑ¦Ñ > ÿεþ¡¿\10649289\stata10\¹¤×Ê·´³Ð1.dta obs: 1,225 vars: 11 25 Aug 2009 08:38 size: 58,800 (99.4% of memory free) variable name age female married edulevel edu exp expsq health migrant wage more storage type float float float float float float float float float float display format %9.0g %9.0g %9.0g %9.0g %9.0g %9.0g %9.0g %9.0g %9.0g %9.0g value label variable label age in years 1:female; 0:male 1:married; 0:unmarried 1:primary; 2:junior; 3:senior; 4:college years of education years of work experience: age-edu-6 exp^2 1:bad; 2:good; 3:very good 1:migrant worker; 0:local worker hourly wage
STATA回归分析讲解学习
![STATA回归分析讲解学习](https://img.taocdn.com/s3/m/e39174a9ccbff121dd3683c0.png)
STATA一章回第归析分.在此处利用两个简单的回归分析案例让初学者学会使用STATA进行回归分析。
STATA版本:11.0案例1:某实验得到如下数据x 1 23455.56.27.7 y48.5对x y 进行回归分析。
第一步:输入数据(原始方法)1.在命令窗口输入input x y /有空格回车2.得到:3.再输入:1 42 5.53 6.24 7.75 8.5end4.输入list 得到5.输入reg y x 得到回归结果回归结果:x1.12?3.02?y2=0.98 T= (15.15) (12.32) R解释一下:SS是平方和,它所在列的三个数值分别为回归误差平方和(SSE)、残差平方和(SSR)及总体平方和(SST),即分别为Model、Residual和Total相对应的数值。
df(degree of freedom)为自由度。
MS为SS与df的比值,与SS对应,SS是平方和,MS是均方,是指单位自由度的平方和。
coef.表明系数的,因为该因素t检验的P值是0.001,所以表明有很强的正效应,认为所检验的变量对模型是有显著影响的。
_cons表示常数项6.作图可以通过Graphics——>twoway—twoway graphs——>plots——>Create案例2:加大一点难度1.格式文件CSV另存为excel首先将.2. 将csv文件导入STATA,选第一个>——>import——File3.输入list4.进行回归reg inc emp inv pow5.回归结果pow30.22?inv4.35?emp18.18?395741.7??inc。
stata教程2:回归
![stata教程2:回归](https://img.taocdn.com/s3/m/3b54ffc758f5f61fb73666bb.png)
Introduction to Stata–Lecture2:RegressionHayley Fisher24February2010Key references:Cameron and Trivedi(2009)chapters3and14,Wooldridge(2009)parts I and II, Greene(2008)chapters1,2,21and23.1IntroductionThis lecture introduces basic econometric techniques using Stata.It uses the dataset from lecture1,an an additional dataset of fertility rates.The examples given here are illustrative only rather than being part of a valid research project.We start by making some small changes to the dataset we have.First create two dummy variables for‘female’and‘married’:generate female=sex==2generate married=marst==1Next we drop all observations with missing values for lnearn,as we will use this as our dependent variable.Of course,this generates a selected sample which introduces biases.It would be better to perform analysis controlling for this selection–see chapter16of Cameron and Trivedi(2009)for more information..drop if lnearn==.(18894observations deleted)Finally,we take a random10%sample of the dataset to give a more manageable size for analysis(esti-mating models for very large datasets can take some time).It is important to ensure this is reproduceable so we set the seed of the pseudo-random number generatorfirst..set seed10101.sample10(57086observations deleted)2Ordinary Least SquaresStandard OLS is implemented using the regress command which has the following syntax: regress depvar[indepvars][if][in][weight][,options]Here anything in square brackets is optional.This is a typical syntax for Stata commands(very similar to the probit and logit commands we will see later).We start by regressing log earnings on various characteristics and hours worked:.regress lnearn age age2female married white hours eddummy1eddummy2unemp Source|SS df MS Number of obs=6343-------------+------------------------------F(9,6333)=595.68 Model|3752.580349416.953371Prob>F=0.0000 Residual|4432.879996333.69996526R-squared=0.4584-------------+------------------------------Adj R-squared=0.4577 Total|8185.460336342 1.29067492Root MSE=.83664------------------------------------------------------------------------------lnearn|Coef.Std.Err.t P>|t|[95%Conf.Interval]-------------+----------------------------------------------------------------age|.0911226.006112214.910.000.0791406.1031047age2|-.0009574.0000751-12.750.000-.0011046-.0008101 female|-.3825226.0216173-17.700.000-.4248999-.3401453married|.099764.023389 4.270.000.0539137.1456142 white|.0044039.02974290.150.882-.0539023.06271hours|.0004843.000011841.200.000.0004613.0005074 eddummy1|-.8259626.0359312-22.990.000-.8964-.7555252eddummy2|-.3996877.0234855-17.020.000-.4457273-.3536482 unemp|.0164931.0132896 1.240.215-.0095591.0425453_cons|7.463438.130369957.250.0007.2078697.719007------------------------------------------------------------------------------The output reports coefficients,standard errors,t-statistics,p-values and confidence intervals for all regressors.Note that a constant is automatically included.We see here that the coefficient on the white dummy is insignificantly different from zero,as is that on the state unemployment rate.Since our independent variable is in logs,the coefficients should be interpreted as semielasticities–getting a year older is associated with a9.1%increase in earnings.The regressors are jointly statistically significant, with an overall F statistic of595.68.2.1Hypothesis testsWe can test simple hypotheses using the test command,for example:.test white(1)white=0F(1,6333)=0.02Prob>F=0.8823.test female married white(1)female=0(2)married=0(3)white=0F(3,6333)=113.79Prob>F=0.0000.test married=white(1)married-white=0F(1,6333)= 5.67Prob>F=0.0173In all cases the p-values are reported making it easy to assess whether the hypothesis is rejected(as it is in all cases above).2.2Standard errorsThe standard OLS estimates above assume homoscedasticity of the error term.We can include the option vce()to report standard errors that are robust to heteroscedasticity–for example vce(robust)where observations are independent,or vce(robust clustvar)where there is correlation between observations in particular clusters(for example if you have multiple observations from the same individual).Below are the results for robust standard errors,and robust standard errors clustered by state:.regress lnearn age age2female married white hours eddummy1eddummy2unemp,vce(robust)Linear regression Number of obs=6343F(9,6333)=432.16Prob>F=0.0000R-squared=0.4584Root MSE=.83664------------------------------------------------------------------------------|Robustlnearn|Coef.Std.Err.t P>|t|[95%Conf.Interval]-------------+----------------------------------------------------------------age|.0911226.006637713.730.000.0781105.1041347age2|-.0009574.0000822-11.640.000-.0011186-.0007961 female|-.3825226.0214864-17.800.000-.4246431-.3404021married|.099764.0229021 4.360.000.0548682.1446598 white|.0044039.02929620.150.881-.0530266.0618343hours|.0004843.000015730.830.000.0004535.0005151 eddummy1|-.8259626.0379387-21.770.000-.9003353-.7515899eddummy2|-.3996877.0235131-17.000.000-.4457813-.3535942 unemp|.0164931.0132059 1.250.212-.0093949.0423811_cons|7.463438.140055153.290.0007.1888827.737993------------------------------------------------------------------------------.regress lnearn age age2female married white hours eddummy1eddummy2unemp,vce(cluster state)Linear regression Number of obs=6343F(9,50)=363.60Prob>F=0.0000R-squared=0.4584Root MSE=.83664(Std.Err.adjusted for51clusters in statefip)------------------------------------------------------------------------------|Robustlnearn|Coef.Std.Err.t P>|t|[95%Conf.Interval]-------------+----------------------------------------------------------------age|.0911226.007129412.780.000.0768029.1054424age2|-.0009574.0000876-10.920.000-.0011334-.0007813 female|-.3825226.020186-18.950.000-.4230674-.3419778married|.099764.0186103 5.360.000.0623842.1371438 white|.0044039.0318670.140.891-.0596028.0684106hours|.0004843.000016429.520.000.0004514.0005173 eddummy1|-.8259626.0401027-20.600.000-.9065113-.7454139eddummy2|-.3996877.0259839-15.380.000-.4518778-.3474976 unemp|.0164931.02202070.750.457-.0277368.060723_cons|7.463438.167014244.690.0007.127987.798896------------------------------------------------------------------------------The standard error on the unemployment rate coefficient is notably larger when standard errors are clustered by state.2.3Comparing results for different groupsWe can perform this regression separately for men and women using the by prefix.The data mustfirstbe sorted by the variable in question:.sort sex.by sex:regress lnearn age age2married white hours eddummy1eddummy2unemp,vce(robust)------------------------------------------------------------------------------------------->sex=MaleLinear regression Number of obs=3178F(8,3169)=214.42Prob>F=0.0000R-squared=0.4257Root MSE=.79875------------------------------------------------------------------------------|Robustlnearn|Coef.Std.Err.t P>|t|[95%Conf.Interval]-------------+----------------------------------------------------------------age|.1113265.009360511.890.000.0929733.1296797age2|-.001178.0001148-10.260.000-.001403-.0009529 married|.2060571.0310567 6.630.000.1451638.2669505 white|.0686291.0397102 1.730.084-.0092313.1464894hours|.00038.000020518.560.000.0003399.0004202 eddummy1|-.7206743.0462098-15.600.000-.8112784-.6300703eddummy2|-.3835108.0324672-11.810.000-.4471695-.319852 unemp|-.0010111.0172191-0.060.953-.0347728.0327505_cons|7.172249.193713437.030.000 6.7924337.552066-------------------------------------------------------------------------------------------------------------------------------------------------------------------------->sex=FemaleLinear regression Number of obs=3165F(8,3156)=222.97Prob>F=0.0000R-squared=0.4364Root MSE=.85867------------------------------------------------------------------------------|Robustlnearn|Coef.Std.Err.t P>|t|[95%Conf.Interval]-------------+----------------------------------------------------------------age|.0750468.00932288.050.000.0567675.0933262age2|-.0008003.0001164-6.870.000-.0010286-.000572 married|.0265275.03295670.800.421-.0380913.0911463 white|-.0365954.0424572-0.860.389-.1198418.046651hours|.0005827.000023524.840.000.0005367.0006287 eddummy1|-.9438047.0622072-15.170.000-1.065775-.8218341eddummy2|-.4094905.0335273-12.210.000-.475228-.3437529 unemp|.0299791.0196914 1.520.128-.0086302.0685884_cons|7.332451.199256836.800.000 6.9417667.723137------------------------------------------------------------------------------Whilst this provides the estimates,it is easier to compare the differences between the results for men and women by putting the results into a table–two ways of doing this are the estimates table command and the(user-written)esttab command.To use these the estimates must be stored.Here I use the quietly prefix to omit the initial output from the estimation..quietly regress lnearn age age2married white hours eddummy1eddummy2unemp if sex==1, vce(robust).estimates store men.quietly regress lnearn age age2married white hours eddummy1eddummy2unemp if sex==2, vce(robust).estimates store womenThe simplest table using estimates table is shown below..estimates table men women----------------------------------------Variable|men women-------------+--------------------------age|.11132648.07504684age2|-.00117797-.00080028married|.20605714.02652752white|.06862907-.03659541hours|.00038002.00058268eddummy1|-.72067435-.94380466eddummy2|-.38351076-.40949046unemp|-.00101113.0299791_cons|7.17224937.3324514----------------------------------------A better table can be produced by adding some options–for example reporting coefficients,standard errors and t-statistics with three decimal places(see help estimates table for more options):.estimates table men women,b(%5.3f)se(%5.3f)t(%5.3f)------------------------------------Variable|men women-------------+----------------------age|0.1110.075|0.0090.009|11.8938.050age2|-0.001-0.001|0.0000.000|-10.263-6.873married|0.2060.027|0.0310.033| 6.6350.805white|0.069-0.037|0.0400.042| 1.728-0.862hours|0.0000.001|0.0000.000|18.56324.836eddummy1|-0.721-0.944|0.0460.062|-15.596-15.172eddummy2|-0.384-0.409|0.0320.034|-11.812-12.214unemp|-0.0010.030|0.0170.020|-0.059 1.522_cons|7.1727.332|0.1940.199|37.02536.799------------------------------------legend:b/se/tBetter tables of estimates are created using esttab.These can also be outputted in several formats to be put directly into reports or papers(for example rich text format to put into a word processor,or tex to put directly into latex)..esttab men women,b(%5.3f)se(%5.3f)r2--------------------------------------------(1)(2)lnearn lnearn--------------------------------------------age0.111***0.075***(0.009)(0.009)age2-0.001***-0.001***(0.000)(0.000)married0.206***0.027(0.031)(0.033)white0.069-0.037(0.040)(0.042)hours0.000***0.001***(0.000)(0.000)eddummy1-0.721***-0.944***(0.046)(0.062)eddummy2-0.384***-0.409***(0.032)(0.034)unemp-0.0010.030(0.017)(0.020)_cons7.172***7.332***(0.194)(0.199)--------------------------------------------N31783165R-sq0.4260.436--------------------------------------------Standard errors in parentheses*p<0.05,**p<0.01,***p<0.001.esttab men women using results,b(%5.3f)se(%5.3f)r2rtf replace(output written to results.rtf)When you are running several regressions with the same independent variables,it often makes sense to create a local macro containing the variable list to save you typing it out each time.This is done by typing local macroname varlist,and the macro is called by typing‘macroname’(note that thefirst single quote is a backtick)..local xlist"age age2female married white hours eddummy1eddummy2unemp"2.4Predicted valuesAfter estimating a model,new variables can be created which contain predicted values and residuals. These can then be used to create e the command predict.After using regress the default is to calculate the linear prediction(other regression commands have different defaults)–other results can be calculated by including an option,eg.residuals..quietly regress lnearn‘xlist’,vce(robust).predict yhat(option xb assumed;fitted values).predict resid,residuals.twoway(scatter resid yhat)3Binary outcome modelsWe now consider estimation for models where the dependent variable has a binary outcome.Here we consider the outcome of marital status–whether an individual is married or not.We might estimate the association between being married and various other outcomes using a linear probability model (implemented by OLS as above),or by probit or logit models.Let’s start by creating a local macro for our RHS variables:.local xlist1"age age2nchild race eddummy1eddummy2earnings hours unemp"Whilst the linear probability model is implemented using regress,we use probit and logit for the alternative methods(which have the same syntax as regress).If we store the results we can create a table to easily compare the coefficient estimates..regress married‘xlist1’output omitted.estimates store LPM.probit married‘xlist1’Iteration0:log likelihood=-4346.6806Iteration1:log likelihood=-3320.7888Iteration2:log likelihood=-3272.4848Iteration3:log likelihood=-3272.077Iteration4:log likelihood=-3272.077Probit regression Number of obs=6343LR chi2(9)=2149.21Prob>chi2=0.0000 Log likelihood=-3272.077Pseudo R2=0.2472------------------------------------------------------------------------------married|Coef.Std.Err.z P>|z|[95%Conf.Interval] -------------+----------------------------------------------------------------age|.0823594.01099887.490.000.0608021.1039167age2|-.0005835.0001347-4.330.000-.0008475-.0003195 nchild|.5518246.018919629.170.000.514743.5889063 race|-.0009319.0001765-5.280.000-.0012779-.0005859 eddummy1|-.3668029.0636444-5.760.000-.4915436-.2420621 eddummy2|-.1662635.0410681-4.050.000-.2467554-.0857716 earnings| 3.26e-067.55e-07 4.320.000 1.78e-06 4.74e-06 hours|.0000449.0000204 2.200.028 4.83e-06.0000849 unemp|-.0054954.0226362-0.240.808-.0498616.0388708 _cons|-2.417738.2279786-10.610.000-2.864568-1.970908 ------------------------------------------------------------------------------.estimates store probit.logit married‘xlist1’Iteration0:log likelihood=-4346.6806Iteration1:log likelihood=-3326.4994Iteration2:log likelihood=-3258.5613Iteration3:log likelihood=-3256.2592Iteration4:log likelihood=-3256.2551Logistic regression Number of obs=6343LR chi2(9)=2180.85Prob>chi2=0.0000 Log likelihood=-3256.2551Pseudo R2=0.2509 ------------------------------------------------------------------------------married|Coef.Std.Err.z P>|z|[95%Conf.Interval] -------------+----------------------------------------------------------------age|.1275906.0186985 6.820.000.0909422.1642389age2|-.0008544.0002285-3.740.000-.0013022-.0004067 nchild|.9995099.036255127.570.000.9284513 1.070569 race|-.0015718.0003055-5.140.000-.0021706-.000973 eddummy1|-.6138059.1095583-5.600.000-.8285363-.3990755 eddummy2|-.2716175.0700338-3.880.000-.4088814-.1343537earnings| 5.68e-06 1.37e-06 4.140.000 2.99e-068.36e-06 hours|.0000699.000035 1.990.046 1.20e-06.0001386unemp|-.0161583.0384904-0.420.675-.0915982.0592815_cons|-3.849691.3891784-9.890.000-4.612466-3.086915------------------------------------------------------------------------------.estimates store logitNote that the probit and logit results here report coefficient estimates which are not equal to marginal effects as they are in the linear probability model.We do not expect coefficients from the different models to be equal(see p.451in Cameron and Trivedi(2009)for rough conversions)..esttab LPM probit logit,b(%5.3f)se(%5.3f)mtitles------------------------------------------------------------(1)(2)(3)LPM probit logit------------------------------------------------------------age0.026***0.082***0.128***(0.003)(0.011)(0.019)age2-0.000***-0.001***-0.001***(0.000)(0.000)(0.000)nchild0.163***0.552*** 1.000***(0.005)(0.019)(0.036)race-0.000***-0.001***-0.002***(0.000)(0.000)(0.000)eddummy1-0.100***-0.367***-0.614***(0.019)(0.064)(0.110)eddummy2-0.045***-0.166***-0.272***(0.012)(0.041)(0.070)earnings0.000***0.000***0.000***(0.000)(0.000)(0.000)hours0.0000.000*0.000*(0.000)(0.000)(0.000)unemp-0.003-0.005-0.016(0.007)(0.023)(0.038)_cons-0.255***-2.418***-3.850***(0.064)(0.228)(0.389)------------------------------------------------------------N634363436343------------------------------------------------------------Standard errors in parentheses*p<0.05,**p<0.01,***p<0.001The mtitles option for esttab includes the estimates titles in the header of the table.Here we see that the signs and significance of the coefficients are similar between the three models.However,it is better to compare marginal effects between models,shown later.Another useful trick to making simple do-files and saving stages of work is to use the xi prefix if you wish to include a set of dummy variables from a categorical variable.For example,if we want to allow the marriage rate to vary across states,we can take this approach and save having to create a large set of dummy variables.This reduces the size of the dataset,but adds to the time taken to calculate the results. We include i.statefip as a regressor here,and Stata creates a set of variables_Istatefip_1-56,of which one is immediately dropped to avoid collinearity..xi:probit married‘xlist1’i.statefipi.statefip_Istatefip_1-56(naturally coded;_Istatefip_1omitted)(further output omitted).estimates store probit1We can compare these results to the probit model without the state dummies in a table–dropping the state dummies here..esttab probit probit1,b(%5.3f)se(%5.3f)mtitles drop(_Istate*)--------------------------------------------(1)(2)probit probit1--------------------------------------------age0.082***0.083***(0.011)(0.011)age2-0.001***-0.001***(0.000)(0.000)nchild0.552***0.557***(0.019)(0.019)race-0.001***-0.001***(0.000)(0.000)eddummy1-0.367***-0.365***(0.064)(0.065)eddummy2-0.166***-0.181***(0.041)(0.042)earnings0.000***0.000***(0.000)(0.000)hours0.000*0.000(0.000)(0.000)unemp-0.005-0.118(0.023)(0.111)_cons-2.418***-1.915**(0.228)(0.605)--------------------------------------------N63436343--------------------------------------------Standard errors in parentheses*p<0.05,**p<0.01,***p<0.0013.1Marginal effectsThe marginal effects of variables can be found using the mfx command after estimation.1The default output of mfx after probit and logit is the marginal effects desired..quietly probit married‘xlist1’.mfxMarginal effects after probity=Pr(married)(predict)=.57985984------------------------------------------------------------------------------variable|dy/dx Std.Err.z P>|z|[95%C.I.]X---------+--------------------------------------------------------------------age|.0321961.004317.460.000.02374.04065238.624age2|-.0002281.00005-4.320.000-.000331-.0001251637.34 nchild|.2157205.007329.560.000.201418.230023.900836 race|-.0003643.00007-5.280.000-.0005-.000229131.696 eddummy1*|-.1452232.02514-5.780.000-.194488-.095958.124862 eddummy2*|-.0648577.01597-4.060.000-.096149-.033566.530348 earnings| 1.27e-06.00000 4.320.0007.0e-07 1.9e-0630367.8 hours|.0000175.00001 2.200.028 1.9e-06.0000331704.92unemp|-.0021483.00885-0.240.808-.019492.015195 4.07124------------------------------------------------------------------------------(*)dy/dx is for discrete change of dummy variable from0to1So here being a year older is associated with a3%increase in the probability of being married;having an extra child is associated with a22%increase(compared to3%and16%from the linear probability model).4Time seriesTo illustrate some basic features of Stata with time series,I am using a dataset of the general fertility rate and personal tax exemptions for the US from1913to1984.This is based on an example in chapter 10of Wooldridge(2009),and ultimately on an article by Whittington,Alm and Peters from1990.The dataset is available from my website.We start offby summarizing the small dataset..summarizeVariable|Obs Mean Std.Dev.Min Max-------------+--------------------------------------------------------gfr|7295.6319419.8046465.4126.6pe|72100.401565.875630243.83year|721948.520.9284519131984pill|72.3055556.463874901ww2|72.0694444.255992301gfr is the general fertility rate,and we are looking to explain it using personal tax exemption(pe), whether World War II was occurring,and whether the contraceptive pill was available.We can naively estimate the relationship using regress..regress gfr pe ww2pill,vce(robust)1This command has been superceded by“margins”in Stata11–see help margins within Stata11for more information.“mfx”still works.Linear regression Number of obs=72F(3,68)=51.57Prob>F=0.0000R-squared=0.4734Root MSE=14.685------------------------------------------------------------------------------|Robustgfr|Coef.Std.Err.t P>|t|[95%Conf.Interval]-------------+----------------------------------------------------------------pe|.08254.0269359 3.060.003.0287902.1362898ww2|-24.2384 3.351355-7.230.000-30.92592-17.55087pill|-31.59403 3.131765-10.090.000-37.84337-25.34469_cons|98.68176 4.22299623.370.00090.2549107.1086------------------------------------------------------------------------------As would be expected,the fertility rate is lower during World War II and when the contraceptive pill is available.However,it is also hypothesised that there may be a lag in the response to the personal tax exemption.We should therefore include lagged values of the personal exemption.Stata makes it easy to create variables such as lags,leads andfirst differences.To take advantage of these wefirst need to declare the data to be time series using the tsset command:.tsset yeartime variable:year,1913to1984delta:1unitOnce this has been done,we can create variables using the lag(L.),lead(F.)andfirst difference (D.)operators:.generate Lgfr=L.gfr(1missing value generated).generate Fgfr=F.gfr(1missing value generated).generate Dgfr=D.gfr(1missing value generated)A missing value is created each time at the beginning,or end,of the dataset.We can check that these are correct by listing thefirstfive values:.list year gfr Lgfr Fgfr Dgfr in1/5+------------------------------------------+|year gfr Lgfr Fgfr Dgfr||------------------------------------------|1.|1913124.7.126.6.|2.|1914126.6124.7125 1.900002|3.|1915125126.6123.4-1.599998|4.|1916123.4125121-1.599998|5.|1917121123.4119.8-2.400002|+------------------------------------------+However,it is not necessary to create all of these variables if you wish to just use them in a regression. To include the lagged values of pe we can conduct the regression directly including the lag operator as follows:.regress gfr pe L.pe L2.pe pill ww2,vce(robust)Linear regression Number of obs=70F(5,64)=31.21Prob>F=0.0000R-squared=0.4986Root MSE=14.27------------------------------------------------------------------------------|Robustgfr|Coef.Std.Err.t P>|t|[95%Conf.Interval]-------------+----------------------------------------------------------------pe|--.|.0726718.09798770.740.461-.1230812.2684248L1.|-.0057796.1132301-0.050.959-.2319826.2204235L2.|.0338268.08944370.380.707-.1448575.2125111pill|-31.30499 3.123293-10.020.000-37.54448-25.06549ww2|-22.1265 6.950919-3.180.002-36.01256-8.24044 _cons|95.8705 4.28418922.380.00087.31185104.4291------------------------------------------------------------------------------The coefficients on the lags of pe are imprecisely estimated,but we can test their joint significance using the test command introduced above:.test pe L.pe L2.pe(1)pe=0(2)L.pe=0(3)L2.pe=0F(3,64)= 4.67Prob>F=0.0051The three coefficients are jointly significantly different from zero at the1%level.We may also want to include a time trend.This can be generated(plus a quadratic)if the data is sorted by date:.sort year.generate t=_n.generate t2=t^2These are easily included in a regression model.However,we must also consider the possibility of a unit root in the series we are trying to explain. Time series can be simply displayed using the tsline command once the data have been declared to be time series.Graphing the fertility rate suggests that a unit root is very likely..tsline gfrTo investigate further we can look at the autocorrelations of both the fertility rate and itsfirst difference. These too strongly suggest a unit root which is removed byfirst differencing the series..ac gfr,lags(10).ac Dgfr,lags(10)A formal test for a unit root can be conducted using a Dickey-Fuller test and the dfuller command. .dfuller gfrDickey-Fuller test for unit root Number of obs=71----------Interpolated Dickey-Fuller---------Test1%Critical5%Critical10%CriticalStatistic Value Value Value------------------------------------------------------------------------------Z(t)-0.857-3.551-2.913-2.592------------------------------------------------------------------------------MacKinnon approximate p-value for Z(t)=0.8019.dfuller DgfrDickey-Fuller test for unit root Number of obs=70----------Interpolated Dickey-Fuller---------Test1%Critical5%Critical10%CriticalStatistic Value Value Value------------------------------------------------------------------------------Z(t)-6.161-3.552-2.914-2.592------------------------------------------------------------------------------MacKinnon approximate p-value for Z(t)=0.0000Here the null hypothesis is that there is a unit root.So there is insufficient evidence to suggest that there is no unit root in the gfr series,but the null hypothesis is rejected in thefirst difference of the series,as suggested by the autocorrelations.ReferencesCameron,A.Colin and Pravin K.Trivedi,Microeconometrics Using Stata,Texas:Stata Press, 2009.Greene,William H.,Econometric Analysis,6th ed.,Pearson/Prentice Hall,2008.Wooldridge,Jeffrey M.,Introductory Econometrics:A Modern Approach,4th ed.,South Western/ Cengage Learning,2009.。
计量经济学Stata软件应用1---【Stata软件基本操作】--2次课
![计量经济学Stata软件应用1---【Stata软件基本操作】--2次课](https://img.taocdn.com/s3/m/df385ed876eeaeaad1f330d5.png)
二、Stata常用基本操作
图形分析(散点图基本命令:scatter) 键入 scatter rjgdp rjcap 回车(以第一个变量rjgdp为纵 轴,以第二个变量rjcap为横轴)→打开绘图窗口,显示 散点图→点击绘图窗口工具栏中的保存图标保存图 →file菜单Open Graph选中打开图;
二、Stata常用基本操作
3、Stata基本操作实例 首先要形成Stata数据文件。 形成Stata数据文件最简单方式是在Stata窗口中直接录 入数据,这种方式虽然简单,但并不实用。经常用的其 他方式是先在其他软件(Excel)中将数据编排好,然 后导入到Stata中。具体操作如下: 复制Excel表格中的数据和变量(数据连同变量一并选取 复制) →在Stata中打开数据编辑( Data Editor)窗口,即 点击Stata10窗口工具栏中右起第4个“数据编辑”小图 标,然后粘帖→关闭数据编辑窗口,在Stata工具栏中 点击左起第2个“Save”将数据保存,保存时需给数据文 件命名;以后再用该数据时,只需在Stata窗口中打开该 文件即可。
2、数据文件的合并
(2) 在原数据文件中加入有新变量的文件 需要新文件中标识变量身份的变量与原文件的相同。比如在 前述过程后,现在又获得了06年和07年各省人口数,文件名 为“中国各省人口数2006-07.dta”,该文件中两个标识变量 code和year,与原文件相同,pop变量为人口数(即新增加变 量);现将该文件合并到“中国经济与投资省级数据200607.dta”文件中,两文件的标识变量均为code和year。 基本命令为: merge [varlist] using filename [filename…][, options] 其中merge为基本命令名称;varlist为标识变量,可以是一个, 也可以是多个,视具体情况而定;filename为要合并的具体的 文件名(注意不要漏下前面的using),可以加入多个文件; option是选项,视具体情况而定是否需要加入。
stata回归分析
![stata回归分析](https://img.taocdn.com/s3/m/080ccadca58da0116c17492c.png)
clear sysuse auto reg mpg weight outreg using d:\temp.txt, replace 3aster bdec(4) tdec(4) nol adjr2 reg mpg dis outreg using d:\temp.txt, append 3aster bdec(4) tdec(4) nol adjr2 reg mpg headroom outreg using d:\temp.txt, append 3aster bdec(4) tdec(4) nol adjr2 reg mpg weight dis headroom outreg using d:\temp.txt, append 3aster bdec(4) tdec(4) nol adjr2 reg mpg weight dis headroom foreign outreg using d:\temp.txt, append 3aster bdec(4) tdec(4) nol adjr2
clear sysuse auto table foreign table foreign, nol sum mpg if foreign==0 sum mpg if foreign==1 tabstat mpg, s(N mean median sd min max ) by(foreign) c(s) reg mpg foreign
y 0 1 x1 2 x2 k xk
~iid N (0, )
2
寻找回归关系 graph box varlist 建立回归方程,进行计算 regress var (independent variable) varlist (dependent variables) 残差及其相关信息 predict, (residual/rsstudent/xb/stdp/cooksd /leverage/) 回归拟合图 tw store, estimate table xml_tab;outreg2;estout;modltbl;mktab; outtex;est2tex
Stata软件之回归分析
![Stata软件之回归分析](https://img.taocdn.com/s3/m/68be0142e518964bcf847c6e.png)
0
10
20
30
5
10 years of education Fitted values
15
20
hourly wage
三、简单回归分析的Stata软件操作实例
7、wage对edu的OLS回归,只使用年龄小于或等于30岁的样 本。命令如下: reg wage edu if age<=30 得到以下运行结果,保存该运行结果;
Variable age edu exp expsq wage lnwage Obs 1225 1225 1225 1225 1225 1225 Mean 36.79755 8.992653 21.8049 613.9776 7.1255 1.808352 Std. Dev. 10.67631 2.719068 11.77443 548.3072 4.766828 .5307399 Min 16 0 0 0 1.25 .2231435 Max 60 19 50 2500 37.5 3.624341
计量经济软件应用
——Stata软件实验之一元、 多元回归分析
内容概要
一、实验目的 二、简单回归分析的Stata基本命令 三、简单回归分析的Stata软件操作实例 四、多元回归分析的Stata基本命令 五、多元回归分析的Stata软件操作实例
一、实验目的:
掌握运用Stata软件进行简单回归分析以及 多元回归分析的操作方法和步骤,并能看懂 Stata软件运行结果。
三、简单回归分析的Stata软件操作实例
1、打开数据文件。直接双击“工资方程1.dta”文件;或者点 击Stata窗口工具栏最左侧的Open键,然后选择“工资方程 1.dta”即可;或者先复制Excel表S-2中的数据,再点击Stata 窗口工具栏右起第4个Data Editor键,将数据粘贴到打开的 数据编辑窗口中,然后关闭该数据编辑窗口,点击工具栏左 起第二个Save键保存数据,保存时需要给数据文件命名。 2、给出数据的简要描述。使用describe命令,简写为: des 得到以下运行结果;
(整理)stata回归分析完整步骤-吐血推荐
![(整理)stata回归分析完整步骤-吐血推荐](https://img.taocdn.com/s3/m/a549f74fb94ae45c3b3567ec102de2bd9605de2f.png)
(整理)stata回归分析完整步骤-吐血推荐stata回归分析完整步骤——吐血推荐****下载连乘函数prod,方法为:findit dm71sort stkcd date //对公司和日期排序gen r1=1+r //r为实际公司的股票收益率gen r2=1+r_yq //r_yq为公司的预期股票收益率egen r3=prod(r1),by(stkcd date) //求每个公司事件日的累计复合收益率egen r4=prod(r2),by(stkcd date) //求每个公司事件日的累计预期的复合收益率gen r=r4-r3capture clear (清空内存中的数据)capture log close (关闭所有打开的日志文件)set mem 128m (设置用于stata使用的内存容量)set more off (关闭more选项。
如果打开该选项,那么结果分屏输出,即一次只输出一屏结果。
你按空格键后再输出下一屏,直到全部输完。
如果关闭则中间不停,一次全部输出。
)set matsize 4000 (设置矩阵的最大阶数。
我用的是不是太大了?)cd D: (进入数据所在的盘符和文件夹。
和dos的命令行很相似。
)log using (文件名).log,replace (打开日志文件,并更新。
日志文件将记录下所有文件运行后给出的结果,如果你修改了文件内容,replace选项可以将其更新为最近运行的结果。
)use (文件名),clear (打开数据文件。
)(文件内容)log close (关闭日志文件。
)exit,clear (退出并清空内存中的数据。
)假设你清楚地知道所需的变量,现在要做的是检查数据、生成必要的数据并形成数据库供将来使用。
检查数据的重要命令包括codebook,su,ta,des和list。
其中,codebook提供的信息最全面,缺点是不能使用if条件限制范围,所以,有时还要用别的帮帮忙。
stata软件基本操作和简单的一元线性回归学习资料
![stata软件基本操作和简单的一元线性回归学习资料](https://img.taocdn.com/s3/m/4f26c68126fff705cc170a51.png)
16
• 思考:目前,无论时间序列还是截面数据, 我们导入的方式完全一样,做法也完全一样 ,是否有区别?
此课件下载可自行编辑修改,仅供参考! 感谢您的支持,我们Байду номын сангаас力做得更好!谢谢
所有的图表绘制都 在graphs里面
分析命令在这里输入 查看历史命令
数据读入和保存(从Excel)
1. 点击data editor(edit)图标进入数据编辑器 2. 复制数据(连同第一行表头),在数据编辑器里
粘贴 3. 弹出提示,询问第一行是否要当成变量名称(表
头),选左边为是,选第二个为否 4. 点击保存,存为xxx.dta文件,便于以后使用
为Y,收入为X
第二步描述统计/画散点图
(1)描述统计 按钮操作方法1:在data editor数据表窗口中,点击Data— Describe data—Summary statistics,如图所示选择第二个
第二步描述统计/画散点图
(1)描述统计
命令操作方法2: 若想对现在程序中已粘贴进去的全部数据进行描述, 则直接在命令栏输入:summarize, detail 注意用英文逗号,然后空格!! 若只想对某一个变量进行描述,则输入 summarize 变量名, detail 多个变量直接以空格隔开即可
变量的使用
3. 生成新变量,例如想生成变量Y,Y是sale的平方 用generate函数即可(简写为gen) gen Y=sale^2
4. 删掉变量:drop 变量名
二、一元线性回归
第一节 问题提出
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
expsq health migrant wage
more
float float float float
%9.0g %9.0g %9.0g %9.0g
float %9.0g float %9.0g
float float float float
%9.0g %9.0g %9.0g %9.0g
结果显示“工资方程1.dta”数据文件包含1225个样本和11个 变
量;11个变量的定义及说明见第3列。
三、简单回归分析的Stata软件操作实例
3、变量的描述性统计分析。对于定量变量,使用summarize 命令:su age edu exp expsq wage lnwage,得到以下运行结 果,保存该运行结果;
三、简单回归分析的Stata软件操作实例
1、打开数据文件。直接双击“工资方程1.dta”文件;或者点 击Stata窗口工具栏最左侧的Open键,然后选择“工资方程 1.dta”即可;或者先复制Excel表S-2中的数据,再点击Stata 窗口工具栏右起第4个Data Editor键,将数据粘贴到打开的 数据编辑窗口中,然后关闭该数据编辑窗口,点击工具栏左 起第二个Save键保存数据,保存时需要给数据文件命名。
obs:
1,225
vars:
11
25 Aug 2009 08:38
size:
58,800 (99.4% of memory free)
storage display variable name type format
value label
variable label
age female married edulevel
其中,wage 为被解释变量,表示小时工资,单位为元;edu 为解释变量,表示受教育年限,即个人接受教育的年数,单 位为年;u为随机误差项。假定模型(3.1)满足简单回归模型的 全部5条基本假定,这样 0 , 1 的OLS估计量 ˆ 0 , ˆ1 将是最佳线性 无偏估计量。请根据表S-2中给出的数据采用Stata软件完成上 述模型的估计等工作。
16 0 0 0
1.25
60 19 50 2500 37.5
lnwage
1225 1.808352 .5307399 .2231435 3.624341
第1列:变量名; 第2列:观测数; 第3列:均值; 第4列:标准差; 第5列:最小值; 第6列:最大值。
➢ regress y x, noconstant y 对 x 的回归,不包含截距项 (constant),即过原点回归。
➢ predict z 根据最近的回归生成一个新变量 z,其值等于每一个观测
的拟合值(即 yˆ i )。
➢ predict u, residual 根据最近的回归生成一个新变量 u,其值等于每一个观测 的残差(即 ei yi yˆi)。
y 1xu
即假定截距系数 0 0 时,该模型被称为过原点回归;过 原点回归在实际中有一定的应用,但除非有非常明确的理 论分析表明 0 0 ,否则不宜轻易使用过原点回归模型。
二、简单回归分析的Stata基本命令
➢ regress y x 以 y 为被解释变量,x 为解释变量进行普通最小二乘 (OLS)回归。regress命令可简写为横线上方的三个字 母reg。
Variable
Obs
Mean
Std. Devxp expsq wage
1225 1225 1225 1225 1225
36.79755 8.992653
21.8049 613.9776
7.1255
10.67631 2.719068 11.77443 548.3072 4.766828
计量经济软件应用
——Stata软件实验之一元、 多元回归分析
内容概要
一、实验目的 二、简单回归分析的Stata基本命令 三、简单回归分析的Stata软件操作实例 四、多元回归分析的Stata基本命令 五、多元回归分析的Stata软件操作实例
一、实验目的:
掌握运用Stata软件进行简单回归分析以及 多元回归分析的操作方法和步骤,并能看懂 Stata软件运行结果。
三、简单回归分析的Stata软件操作实例
实验 1 简单回归分析:教育对工资的影响
劳动经济学中经常讨论的一个问题是劳动者工资的决定。不 难想象,决定工资的因素有很多,例如能力、性别、工作经验、 教育水平、行业、职业等。在这里仅考虑其中一种因素:教育 水平,建立如下计量模型:
w a g e 0 1 e d u u , , , , , , , , , , , , , , , , , , , , , , , , , ( 3 . 1 )
age in years 1:female; 0:male 1:married; 0:unmarried 1:primary; 2:junior; 3:senior;
4:college years of education years of work experience:
age-edu-6 exp^2 1:bad; 2:good; 3:very good 1:migrant worker; 0:local worker hourly wage
2、给出数据的简要描述。使用describe命令,简写为: des 得到以下运行结果;
三、简单回归分析的Stata软件操作实例
Contains data fromD:\½²¿Î×ÊÁÏ\ÖÜÝíµÄÉÏ¿Î×ÊÁÏ\Êý¾Ý\¡¾ÖØÒª¡¿\¡¾¼ÆÁ¿¾¼ÃѧÈí¼þÓ¦Ó
> ÿμþ¡¿\10649289\stata10\¹¤×Ê·½³Ì1.dta
二、简单回归分析的Stata基本命令
简单线性回归模型 ( simple linear regression model ) 指 只有一个解释变量的回归模型。如:
y01xu
其中,y 为被解释变量,x 为解释变量,u 为随机误差项, 表示除 x 之外影响 y 的因素; 1 称为斜率参数或斜率系 数, 0 称为截距参数或截距系数,也称为截距项或常数项。 简单线性回归模型的一种特殊情况: