




免费预览已结束,剩余4页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
insheet using d:研究生statalianxicha3.csvrename v1 yearrename v2 ybrowse*查看数据browse if year20000 high, 15000 medium, 小于=小于等于10000*生成虚拟变量的快捷方法:gen p=price10000(price10000取1,否则取0)sort pricegen pp=_n*生成一个表示价格高低的序列help function*显示全部stata函数drop p pp ww www wdis round(_pi,0.00001)*显示pi四舍五入到0.00001dis normal(1.96)*返回标准正态分布t=1.96的累积概率分布dis invnormal(0.975)*返回标准正态分布累积分布临界概率对应的临界值dis Ftail(2,1500,3.6979)*返回自由度为2样本容量为1500的F分布的F=3.6979的累积概率dis invFtail(2,1500,0.025)*返回自由度为2样本容量为1500的F分布的累积概率为0.025的F值lookfor p*寻找含有p的变量sort pricelist make-mpg in 1/10,cleanlist make-mpg if price0histogram inc if inc0,normalladder inc if inc0boxcox inc if inc0bcskew0 incx=inc if inc0histogram incx,normalgladder inc if inc0*回归之后发现age对inc不显著,不符合常识,经过作图发现因变量不符合/*/正态分布假定,故而想办法将因变量转化为符合正态分布的变量,首先用/*/常见的幂指数进行试验,观察有无通过检验的形式,结果是没有(ladder)/*/然后用boxcox命令强制进行幂指数转换,计算出最佳幂指数为0.096/*/再用bcskew0命令计算出可以令偏度等于零的boxcox转换,并生成新的变量/*/incx,对incx进行画图正态比较发现结果较满意。gladder命令是用作图/*/显示调整结果ta edu,nolabelgen edug=recode(edu,2,3,4,6)ta edug,gen(sb)rename sb1 primaryrename sb2 juniorrename sb3 seniorrename sb4 collegegen incn=log(inc) if inc0reg incn age male junior senior college*一种生成多组别虚拟变量的方法,在ta命令后直接加入gen(*)选项,即可直接/*/根据ta分组创建等量的变量,每个变量都以*命名。adjust age=40 male=1,by(edug)*回归后的点预测!xi:reg incn age male g*最方便的设定虚拟变量用于拟合回归的方法,直接在回归命令前加xi:,然后在/*/需要转换为虚拟变量的类别变量前加i.,stata将自动生成虚拟变量,并且/*/自动选取n-1个虚拟变量(放弃一个)进入方程。use cgss2003,clearxi:reg incn i.ageg i.party*i.state i.male*eduyr*带交乘项的虚拟变量回归拟合(自动生成)。sw reg incn male age edu party state,pr(.05)sw reg incn male age edu party state,pe(.05)*逐步回归(stepwise)pr(probility of removing)向后逐步回归/*/pe(begin with empty model)向前逐步回归use hdr2004x,clearhist hdi,freq start(.2) width(.1) ylabel(0 (5) 35)/*/ xlabel(.2 (.1) 1.0) gap(8) normal addlabels /*/title(the distribution of human development index)*直方图绘制命令gen hdigroup=recode(hdi,.5,.7,.8,.9,1)ta hdigroup,gen(h)replace h1=. if h1=0replace h2=. if h2=0replace h3=. if h3=0replace h4=. if h4=0replace h5=. if h5=0graph pie h1-h5,legend(off) plabel(_all name)/*/ title(Human Development Index) /*/subtitle(by hdi group) /*/note(source:2004 UNDP Human Development Report)*饼图绘制命令use chnhf2000,cleargraph bar inc if occ1,over(edu) ylabel(0 (600) 2400) /*/ title(Monthly Average Income) /*/subtitle(by education) ytitle(Ave. Inc.) /*/note(Source: 2000 CHNHF Project Subsample)*简单条形图绘制命令graph bar inc if occ1,over(edu,label(alt) /*/over(male) ylabel(0 (600) 2400) /*/title(Monthly Average Income) /*/subtitle(by education and gender) /*/ytitle(Ave. Inc.) /*/note(Source: 2000 CHNHF Project Subsample)graph bar inc if occ1,over(male,gap(8) label(alt)/*/ over(edu) ylabel(0 (600) 2400) /*/title(Monthly Average Income) /*/subtitle(by education and gender) ytitle(Ave. Inc.) /*/note(Source: 2000 CHNHF Project Subsample)*绘制根据多个变量分组的单变量条形图use netview,clearreplace day=0 if day=7label define day 0 sunday 1 monday 2 tuesday,modifylabel val day daylist day view1-view3 if day3,cleangraph bar view1-view3 if day3|day=0,over(day) bargap(-25)/*/ legend(posi(1) rows(3) ring(0) lab(1 Department1) /*/lab(2 Department2) lab(3 Department3) /*/title(Internet Visits) subtitle(by development and day) /*/ytitle(Visits) note(Source: Undisclosed Sources)graph bar (sum) view1-view3 if day1,over(occ,sort(inc) descending) by(male) nofill /*/ylab(0 (2000) 6000) yline(943) title(Monthly Average Income) /*/ytitle(Ave. Inc.) note(Source: 2000 CHNHF Project Subsample)*横向条形图use bankchina3q,clearformat changex %3.1fgraph twoway bar changex day if month=8,yline(0) ylab(-5.0 (5) 10.0) /*/xlab(1 (1) 31,alter) ymtick(-5 (1) 10) title(Bank Of China) /*/subtitle(August 2007) ytitle(Change in %) xtitle(Date) /*/note(Source: /,extracted on 10/04/2007)*多方向条形图(股票走势图)use hdr2004x,clearscatter enrollf literacy,msymbol(oh)count if literacy95&contin=3scatter enrollf literacy if literacy95&contin=3,msymbol(oh)scatter enrollf literacy if literacy95&contin=3,msymbol(oh) jitter(5)*绘制散点图,处理重合点scatter hdi lifeexp if contin=1,mlabel(nation)gen pos=3replace pos=9 if rank=147replace pos=9 if rank=168replace pos=2 if rank=175replace pos=8 if rank=148replace pos=9 if rank=152scatter hdi lifeexp if contin=1,xlabel(25 (5) 75) mlabel(nation) mlabv(pos)*设置数据标签的位置gen gdpn=log(gdp)lab var gdpn gdp per capital in log formgraph matrix hdi gdpn literacy lifeexp,subtitle(Summary of HDR2004 data) /*/note(Source: UNDP Human Development Report 2004)*矩阵散点图use lifestats,clearscatter birth year ,connect(l) msymbol(o) subtitle(Birth Rate In China) /*/note(Source: from Statistical Yearbook 2006)*带连线的散点图line birth year,sort(year)line birth increase death year,sort(year) lpattern(solid dash_dot dash) /*/yaxis(1 2) xaxis(1 2) ylabel(0 10 (5) 25) ylabel(0 (2) 10,axis(2) /*/xlab(,axis(2) xtitle(,axis(2) legend(pos(2) ring(0) rows(3) size(small) /*/subtitle(Life Statistics in China,1980-2005) /*/note(Source: from Statistical Yearbook 2006)*直线图use hdr2004x,clearscatter hdi literacy|lfit hdi literacyscatter hdi literacy|lfitci hdi literacy*直线拟合图形gen gdpn=log(gdp)scatter internetk gdpn|qfit internetk gdpnscatter internetk gdpn|qfitci internetk gdpn*二次曲线拟合图形use bankchina3q,cleartwoway spike change datetm,yline(0)twoway dropline change datetm,yline(0)use lifestats,cleartwoway spike birth year,base(18) yline(18) ylabel(10 (2) 24)*长钉图use lifestats,cleartwoway area birth death year,ytitle(percent)use bankchina3q,cleartwoway area change datetm,xtitle(Date) ytitle(Price Change)*面积图use lifestats,cleartwoway rarea birth death year,ytitle(percent)*面积区间图use bankchina3q,cleartwoway rbar high low datetm|scatter close datetm,legend(pos(5) ring(0) row(2)*条形区间图use hdr2004x,cleartwoway lfitci hdi literacy|scatter hdi literacy|,legend(order(3 1 2) /*/lab(3 Observed) lab(2 Estd Line) rows(3) position(10) ring(0) ) /*/text(80 .2 I Love You Bei!)*图例的设计(legend)use bankchina3q,clearreplace volume=volume/1000000twoway rbar high low datetm|line close datetm|bar volume datetm, yaxis(2)|,/*/yscale(axis(1) range(4 6.5) yscale(axis(2) range(0 12) ylabel(4.5 (.5) 6.5) /*/ylabel(0 (2) 6,axis(2) legend(pos(3) ring(0) rows(3) xtitle(Date) /*/ytitle(Stock Volume in million axis(2) title(Bank of China Stock Trend) /*/subtitle(3rd Quarter,2007) /*/note(Source: /,exteracted on 10/04/2007)*双坐标轴的用法(axis)graph save bcstock,replacegraph dirgraph use bcstockgraph export bcstock.png,replace*图形的保存、调用与输出。use append1,clearlistappend using append2save data,replace*纵向合并数据(变量数目不变,样本数增加
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中国移动CAD行业市场调查研究及发展战略规划报告
- 2025年中国电磁铁行业发展监测及市场发展潜力预测报告
- 电机嵌线工实操任务书
- 乙炔发生工安全技术操作规程
- 中国网络工程行业市场全景分析及投资前景展望报告
- 小学生亭子写生课件
- 焦化装置操作工上岗证考试题库及答案
- 2025年中国电磁屏蔽膜行业市场调研及未来发展趋势预测报告
- 土方机械维修工应急处置分析及对策
- 纺丝工(纺丝凝固浴液配制工)上岗证考试题库及答案
- 北京市朝阳区人民法院人身保险合同纠纷案件审判白皮书(2020年度-2024年度)
- 生产车间菌种管理制度
- 临床用血安全管理制度
- 蛇咬伤的急救处理措施
- 2025年内蒙古呼伦贝尔农垦集团有限公司招聘笔试参考题库含答案解析
- 高中物理人教版选修3-5课件第十八章第1节电子的发现
- 医药研发体系管理制度
- 印刷业财务管理制度
- 八素八少考试试题及答案
- 保险合同赠予协议书
- 医疗科室共享协议书
评论
0/150
提交评论