收藏 分享(赏)

李子奈《计量经济学》第三版例题及习题的stata解答.docx

上传人:kpmy5893 文档编号:6565693 上传时间:2019-04-17 格式:DOCX 页数:38 大小:1.39MB
下载 相关 举报
李子奈《计量经济学》第三版例题及习题的stata解答.docx_第1页
第1页 / 共38页
李子奈《计量经济学》第三版例题及习题的stata解答.docx_第2页
第2页 / 共38页
李子奈《计量经济学》第三版例题及习题的stata解答.docx_第3页
第3页 / 共38页
李子奈《计量经济学》第三版例题及习题的stata解答.docx_第4页
第4页 / 共38页
李子奈《计量经济学》第三版例题及习题的stata解答.docx_第5页
第5页 / 共38页
点击查看更多>>
资源描述

1、 第二章例 2.11(p24)(1 )表 2.1.2 中 E(Y|X=800)即条件均值的求法,将数据直接复制到 stata 中。程序:sum y if x=800Variable Obs Mean Std. Dev. Min Maxy 4 605 34.78505 561 638程序:sum y if x=1100Variable Obs Mean Std. Dev. Min Maxy 6 825 121.698 638 968程序:sum y if x=1400Variable Obs Mean Std. Dev. Min Maxy 11 1045 116.3091 869 1210(2

2、)图 2.1.1 的做法:程序:twoway(scatter y x )(lfit y x ),title(“不同可支配收入水平组家庭消费支出的条件分布图“)xtitle(“每月可支配收入(元)“)ytitle(“每月消费支出(元)“)xtick(500(500)4000)ytick(0(500)3500)其他条件均值求法程序相同,sum 是 summarize 的缩写(横线表示最简省形式) ,显示变量的描述统计信息,包括:观测量数,均值,标准差,最小值,最大值,if 是条件表达式。例 2.31(p37)将数据直接复制到 stata中程序:(1)total xiyixiyi 4974750 1

3、507821 1563822 8385678Total Std. Err. 95% Conf. Intervalreturn listscalars:r(skip) = 0r(first) = 1r(k_term) = 0r(k_operator) = 0r(k) = 0r(k_level) = 0r(output) = 1r(b) = 4974750r(se) = 1507820.761894463g a=r(b) in 1total xi2Scatter 表示散点图选项,lfit 表示回归线,title 表示题目,xtick 表示刻度,(500(500)4000)分别表示起始刻度,中间数表

4、示以单位刻度,4000 表示最后的刻度。要注意的是命令中的符号都要用英文字符,否则命令无效。这个图可以直接复制的,但是由于我的软件出问题,只能直接剪切,所以影响清晰度。Total 表示求和,return list命令可以引用其中的数据,接下来在第一列生成一个新的变量代表 xiyi 的和,同样生成一个 b 代表 xi 平方的,a 除以 b 即可得到batareturn listg b=r(b) in 1di a/b.67(2) mean Yigen m=r(b) in 1mean Xig n=r(b) in 1di m-n*0.67142.4由此得到回归方程:Y=142.4+0.67Xi例 2.

5、62(p53)程序:(1)回归reg y x (2 ) 求 X 的样本均值和样本方差:mean xx 11363.69 591.7041 10155.27 12572.11Mean Std. Err. 95% Conf. IntervalMean estimation Number of obs = 31sum x ,d(d 表示 detail 的省略,这个命令会产生更多的信息)99% 20667.91 20667.91 Kurtosis 4.73926795% 19977.52 19977.52 Skewness 1.69197390% 16015.58 18265.1 Variance 1

6、.09e+0775% 12192.24 16015.58Largest Std. Dev. 3294.46950% 9898.75 Mean 11363.6925% 9267.7 9000.35 Sum of Wgt. 3110% 9000.35 8941.08 Obs 315% 8920.59 8920.59 1% 8871.27 8871.27Percentiles Smallest xdi r(Var)(特别注意 Var 的大小写)10853528例 2.6.2(P56)(1)reg Y X_cons 2091.295 334.987 6.24 0.000 1403.959 2778.6

7、32X .4375268 .0092973 47.06 0.000 .4184503 .4566033 Y Coef. Std. Err. t P|t| 95% Conf. Interval Total 2.5122e+09 28 89720219.8 Root MSE = 1058.6 Adj R-squared = 0.9875Residual 30259023.9 27 1120704.59 R-squared = 0.9880 Model 2.4819e+09 1 2.4819e+09 Prob F = 0.0000F( 1, 27) = 2214.60 Source SS df MS

8、 Number of obs = 29(2 )图 2.6.1 的绘制:twoway (line Y X year),title(“中国居民可支配总收入 X 与消费总支出 Y 的变动图“)第三章例 3.2.2(p72)reg Y X1 X2_cons 143.3266 260.4032 0.55 0.586 -390.0851 676.7383X2 .2500854 .1136343 2.20 0.036 .0173161 .4828547 X1 .5556438 .0753076 7.38 0.000 .4013831 .7099046Y Coef. Std. Err. t P|t| 95%

9、Conf. IntervalTotal 171142081 30 5704736.02 Root MSE = 385.92 Adj R-squared = 0.9739Residual 4170092.27 28 148931.867 R-squared = 0.9756 Model 166971988 2 83485994.2 Prob F = 0.0000F( 2, 28) = 560.57 Source SS df MS Number of obs = 31例 3.51(p85)g lnP1=ln(P1)g lnP0=ln(P0)g lnQ=ln(Q)g lnX=ln(X)_cons 5

10、.53195 .0931071 59.41 0.000 5.336339 5.727561lnP0 -.2885609 .2051844 -1.41 0.177 -.7196373 .1425155 lnP1 -.2580119 .1781856 -1.45 0.165 -.632366 .1163422lnX .5399167 .0365299 14.78 0.000 .4631703 .6166631 lnQ Coef. Std. Err. t P|t| 95% Conf. Interval Total .783419051 21 .037305669 Root MSE = .0314 A

11、dj R-squared = 0.9736Residual .017748183 18 .00098601 R-squared = 0.9773 Model .765670868 3 .255223623 Prob F = 0.0000F( 3, 18) = 258.84 Source SS df MS Number of obs = 22drop lnX lnP1 lnP0 g lnXP0=ln(X/P0)g lnP1P0=ln(P1/P0)reg lnQ lnXP0 lnP1P0_cons 5.524569 .0831077 66.47 0.000 5.350622 5.698515lnP

12、1P0 -.2753473 .1511432 -1.82 0.084 -.5916936 .040999 lnXP0 .5344394 .0231984 23.04 0.000 .4858846 .5829942lnQ Coef. Std. Err. t P|t| 95% Conf. IntervalTotal .783419051 21 .037305669 Root MSE = .0306 Adj R-squared = 0.9749Residual .01778672 19 .000936143 R-squared = 0.9773 Model .765632331 2 .3828161

13、65 Prob F = 0.0000F( 2, 19) = 408.93 Source SS df MS Number of obs = 22练习题 13(p105)g lnY=ln(Y)g lnK=ln(K)g lnL=ln(L)reg lnY lnK lnL_cons 1.153994 .7276114 1.59 0.124 -.33645 2.644439lnL .3607965 .2015915 1.79 0.084 -.0521449 .7737378 lnK .6092356 .1763779 3.45 0.002 .2479419 .9705293lnY Coef. Std. E

14、rr. t P|t| 95% Conf. IntervalTotal 26.6752291 30 .889174303 Root MSE = .42554 Adj R-squared = 0.7963Residual 5.07030244 28 .18108223 R-squared = 0.8099 Model 21.6049266 2 10.8024633 Prob F = 0.0000F( 2, 28) = 59.66 Source SS df MS Number of obs = 31第二问:test b_lnk+b_lnl=1第四章例 4.14 (P116)(1 )回归g lnY=l

15、n(Y)g lnX1=ln(X1)g lnX2=ln(X2)reg lnY lnX1 lnX2_cons 3.266068 1.041591 3.14 0.004 1.132465 5.39967lnX2 .4774534 .0515951 9.25 0.000 .3717657 .5831412 lnX1 .1502137 .1085379 1.38 0.177 -.072116 .3725435lnY Coef. Std. Err. t P|t| 95% Conf. IntervalTotal 3.79673642 30 .126557881 Root MSE = .17277 Adj R

16、-squared = 0.7642Residual .835744123 28 .029848004 R-squared = 0.7799 Model 2.9609923 2 1.48049615 Prob F = 0.0000F( 2, 28) = 49.60 Source SS df MS Number of obs = 31于是得到方程: lnY=3.266+0.1502lnX1+0.4775lnX2(2)绘制参差图:predict e, residg ei2=e2scatter ei2 lnX2,title(“图 4.1.3 异方差性检验图“)xtick(6(0.4)9.2)ytick

17、(0(0.04)0.24)predict 在回归结束后,需要对拟合值以及残差进行分析,需要使用此命令。(3)G-Q 检验sort X2drop in 13 /19reg lnY lnX1 lnX2 in 1/12_cons 3.141209 1.122358 2.80 0.021 .6022575 5.68016lnX2 .2347508 .1097475 2.14 0.061 -.0135153 .4830169 lnX1 .3983847 .0787908 5.06 0.001 .2201475 .5766219lnY Coef. Std. Err. t P|t| 95% Conf. In

18、tervalTotal .269669142 11 .024515377 Root MSE = .08832 Adj R-squared = 0.6818Residual .070196863 9 .007799651 R-squared = 0.7397 Model .19947228 2 .09973614 Prob F = 0.0023F( 2, 9) = 12.79 Source SS df MS Number of obs = 12reg lnY lnX1 lnX2 in 13/24_cons 3.993643 1.884053 2.12 0.063 -.2683811 8.2556

19、68lnX2 .6201685 .1116539 5.55 0.000 .3675898 .8727472 lnX1 -.113766 .1599622 -0.71 0.495 -.4756257 .2480937lnY Coef. Std. Err. t P|t| 95% Conf. IntervalTotal 1.55357967 11 .141234516 Root MSE = .14575 Adj R-squared = 0.8496Residual .191197445 9 .021244161 R-squared = 0.8769 Model 1.36238223 2 .68119

20、1114 Prob F = 0.0001F( 2, 9) = 32.06 Source SS df MS Number of obs = 12di F=0.1911/0.0702(可以用字母替代)2.72364672.7222222(4)怀特检验(重新把原始数据出入)reg lnY lnX1 lnX2predict e ,residg e2=e2g lnX12=(lnX1)2g lnX22=(lnX2)2g lnX1X2=lnX1*lnX2reg e2 lnX1 lnX2 lnX12 lnX22 lnX1X2_cons 10.24328 5.474522 1.87 0.073 -1.03170

21、7 21.51827lnX1X2 .0193327 .0412645 0.47 0.643 -.0656532 .1043186 lnX22 .0211007 .0133574 1.58 0.127 -.0064095 .0486109lnX12 .1491144 .0581072 2.57 0.017 .0294404 .2687884 lnX2 -.4573069 .4540203 -1.01 0.323 -1.392379 .4777655lnX1 -2.32907 1.116442 -2.09 0.047 -4.628426 -.0297138 e2 Coef. Std. Err. t

22、 P|t| 95% Conf. Interval Total .05324601 30 .001774867 Root MSE = .02679 Adj R-squared = 0.5955Residual .017947599 25 .000717904 R-squared = 0.6629 Model .035298411 5 .007059682 Prob F = 0.0000F( 5, 25) = 9.83 Source SS df MS Number of obs = 31reg e2 lnX1 lnX2 lnX12 lnX22_cons 7.763275 1.375323 5.64

23、 0.000 4.936257 10.59029lnX22 .0172142 .0103109 1.67 0.107 -.0039802 .0384085 lnX12 .1261597 .0307668 4.10 0.000 .0629176 .1894018lnX2 -.2581661 .1571598 -1.64 0.112 -.5812127 .0648806 lnX1 -1.851123 .4467273 -4.14 0.000 -2.769384 -.932862e2 Coef. Std. Err. t P|t| 95% Conf. IntervalTotal .05324601 3

24、0 .001774867 Root MSE = .02639 Adj R-squared = 0.6077Residual .018105178 26 .000696353 R-squared = 0.6600 Model .035140831 4 .008785208 Prob F = 0.0000F( 4, 26) = 12.62 Source SS df MS Number of obs = 31g lne2= ln(e2)reg lne2 lnX2 lnX22_cons 93.19585 37.65529 2.47 0.020 16.06249 170.3292lnX22 1.7010

25、71 .6414051 2.65 0.013 .3872121 3.01493 lnX2 -25.97629 9.860002 -2.63 0.014 -46.17359 -5.778992lne2 Coef. Std. Err. t P|t| 95% Conf. IntervalTotal 144.632248 30 4.82107492 Root MSE = 2.0299 Adj R-squared = 0.1453Residual 115.374726 28 4.12052593 R-squared = 0.2023 Model 29.2575216 2 14.6287608 Prob

26、F = 0.0423F( 2, 28) = 3.55 Source SS df MS Number of obs = 31. predict m ,xb(和书上直接以差残作为权数是有区别的,理论上不能能以残差直接作为权数). predictnl n=exp(xb(). g wi=sqrt(n). vwls lnX1 lnX2,sd(wi)_cons 2.338164 .4472981 5.23 0.000 1.461476 3.214852lnX2 .428669 .0275805 15.54 0.000 .3746122 .4827257lnX1 .3177322 .0514579 6.17

27、 0.000 .2168765 .4185879lnY Coef. Std. Err. z P|z| 95% Conf. IntervalProb chi2 = 0.0000 Prob chi2 = 0.0000Goodness-of-fit chi2(28) = 73.28 Model chi2(2) = 263.97Variance-weighted least-squares regression Number of obs = 31例 4.21(老师有标准答案)reg Y X_cons 2091.295 334.987 6.24 0.000 1403.959 2778.632X .43

28、75268 .0092973 47.06 0.000 .4184503 .4566033 Y Coef. Std. Err. t P|t| 95% Conf. Interval Total 2.5122e+09 28 89720219.8 Root MSE = 1058.6 Adj R-squared = 0.9875Residual 30259023.9 27 1120704.59 R-squared = 0.9880 Model 2.4819e+09 1 2.4819e+09 Prob F = 0.0000F( 1, 27) = 2214.60 Source SS df MS Number

29、 of obs = 29predict e,residtsset yeartime variable: year, 1978 to 2006delta: 1 unitline e year,title(“残差相关图“)xtick(1978(5)2006)ytick(-3000(1000)3000)scatter e e1,title(“残差相关图“)xtick(-2000(1000)3000)ytick(-3000(1000)3000)g T=_ng T2=T2reg Y X T2reg e X T2 e1_cons 910.3409 172.739 5.27 0.000 553.8251 1

30、266.857e1 .6186482 .1467037 4.22 0.000 .3158666 .9214297 T2 11.04582 2.915754 3.79 0.001 5.028004 17.06365X -.1435191 .0335797 -4.27 0.000 -.2128242 -.074214 e Coef. Std. Err. t P|t| 95% Conf. Interval Total 28750771.3 27 1064843.38 Root MSE = 362.48 Adj R-squared = 0.8766Residual 3153351.72 24 1313

31、89.655 R-squared = 0.8903 Model 25597419.6 3 8532473.19 Prob F = 0.0000F( 3, 24) = 64.94 Source SS df MS Number of obs = 28_cons 3328.191 195.0326 17.06 0.000 2927.296 3729.086T2 21.65582 2.124183 10.19 0.000 17.2895 26.02215 X .1761519 .0259858 6.78 0.000 .1227374 .2295664Y Coef. Std. Err. t P|t| 9

32、5% Conf. IntervalTotal 2.5122e+09 28 89720219.8 Root MSE = 482.57 Adj R-squared = 0.9974Residual 6054792.7 26 232876.642 R-squared = 0.9976 Model 2.5061e+09 2 1.2531e+09 Prob F = 0.0000F( 2, 26) = 5380.77 Source SS df MS Number of obs = 29g e2=e_n-1reg e X T2 e1 e2_cons 886.1107 321.3096 2.76 0.011

33、221.4311 1550.79e2 4.183503 46.36562 0.09 0.929 -91.73108 100.0981 e1 .6192203 .1499666 4.13 0.000 .3089908 .9294498T2 10.80845 3.973581 2.72 0.012 2.58847 19.02843 X -.1421776 .0373799 -3.80 0.001 -.2195039 -.0648513e Coef. Std. Err. t P|t| 95% Conf. IntervalTotal 28750771.3 27 1064843.38 Root MSE

34、= 370.21 Adj R-squared = 0.8713Residual 3152235.94 23 137053.737 R-squared = 0.8904 Model 25598535.3 4 6399633.84 Prob F = 0.0000F( 4, 23) = 46.69 Source SS df MS Number of obs = 28prais Y X T2,rhotype(orrc)Durbin-Watson statistic (transformed) 1.361658Durbin-Watson statistic (original) 0.442033rho

35、.764553_cons 3118.169 329.4324 9.47 0.000 2441.011 3795.327T2 20.79527 2.693162 7.72 0.000 15.25939 26.33114 X .1896298 .0292979 6.47 0.000 .1294071 .2498524Y Coef. Std. Err. t P|t| 95% Conf. IntervalTotal 218377329 28 7799190.31 Root MSE = 305.97 Adj R-squared = 0.9880Residual 2434113.93 26 93619.7

36、664 R-squared = 0.9889 Model 215943215 2 107971607 Prob F = 0.0000F( 2, 26) = 1153.30 Source SS df MS Number of obs = 29Prais-Winsten AR(1) regression - iterated estimatesnewey lnY lnX, lag(2)例 4.3.1(P140)g lnX1=ln(X1)g lnX2=ln(X2)g lnX3=ln(X3)g lnX4=ln(X4)g lnX5=ln(X5)g lnY=ln(Y)reg lnY lnX1 lnX2 l

37、nX3 lnX4 lnX5_cons -4.173174 1.923624 -2.17 0.043 -8.199365 -.1469838lnX5 -.1011737 .0576866 -1.75 0.096 -.2219131 .0195656 lnX4 -.0472287 .0447674 -1.05 0.305 -.1409279 .0464705lnX3 -.0811099 .0153037 -5.30 0.000 -.1131409 -.0490789 lnX2 1.222289 .1351786 9.04 0.000 .9393566 1.505221lnX1 .3811446 .

38、050242 7.59 0.000 .275987 .4863022 lnY Coef. Std. Err. t P|t| 95% Conf. Interval Total .209348611 24 .008722859 Root MSE = .01424 Adj R-squared = 0.9768Residual .003852744 19 .000202776 R-squared = 0.9816 Model .205495866 5 .041099173 Prob F = 0.0000F( 5, 19) = 202.68 Source SS df MS Number of obs =

39、 25corr lnX1 lnX2 lnX3 lnX4 lnX5lnX5 0.4402 -0.0733 0.4113 0.2795 1.0000 lnX4 0.9644 -0.6976 0.3988 1.0000lnX3 0.4517 -0.2141 1.0000 lnX2 -0.5687 1.0000lnX1 1.0000 lnX1 lnX2 lnX3 lnX4 lnX5stepwise, pr(0.05) : reg Y X1 X2 X3 X4 X5或者 stepwise, pe(0.05) : reg Y X1 X2 X3 X4 X5(逐步向前回归和逐步向后回归)reg lnY lnX1 lnX2 lnX3_cons -5.999638 1.162078 -5.16 0.000 -8.416312 -3.582964lnX3 -.0867539 .0151549 -5.72 0.000 -.1182702 -.0552376 lnX2 1.290729 .0961534 13.42 0.000 1.090767 1.490691lnX1 .3233849 .0108608 29.78 0.000 .3007987 .3459711 lnY Coef. Std. Err. t P|t| 95% Conf. Interval Total

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 经济财会 > 经济学

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报