1、stata入门入门3统计指标篇统计指标篇江金启沈阳农业大学经济管理学院-精品-一、基本描述统计量一、基本描述统计量lsummarize命令l可概括观测值个数、平均值、标准差、最大值和最小值五个指标。l语法:summarize varlist in if weight,optionsl选项:detail可统计方差、偏度、峰度和各个分位数等指标。l范例:summarize price mpg-精品-2022-10-102l菜单:Statistics Summaries,tables,and tests Summary and descriptive statistics Summary stati
2、stics-精品-2022-10-103tabstat命令命令l语法:tabstat varlist if in weight,optionsl选项:默认结果是均值。lby(varname)按变量varname进行分组描述性统计;lstatistics(statname.)报告指定的描述性统计指标值。lnototal不报告总体统计值,通常是与by()配合使用 lmissing用by()选项时,显示by()变量的缺失值也作一类的结果。l范例:tabstat price mpg,by(id)statistics(mean ma mi sd n)missing-精品-2022-10-104l菜单:S
3、tatisticsSummaries,tables,and testsTablesTable of summary statistics(tabstat)-精品-2022-10-105ameans命令命令l估计算术、几何和调和平均数l语法:ameans varlist if in weight,optionsl范例:ameans price-精品-2022-10-106l菜单:Statistics Summaries,tables,and tests Summary and descriptive statistics Arith./geometric/harmonic means-精品-20
4、22-10-107二、单个分类变量的汇总统计二、单个分类变量的汇总统计ltabulate/tab1命令l对分类变量的描述统计是观察其不同类别的频数或百分数。l语法1:tabulate varname if in weight,optionsl语法2:tab1 varlist if in weight,optionsl选项:missing缺失值也作一类,plot作柱状图l范例:tabulate foreign/tab1 foreign id-精品-2022-10-108l菜单1:Statistics Summaries,tables,and tests Tables One-way tables
5、-精品-2022-10-109l菜单2:Statistics Summaries,tables,and tests Tables Multiple one-way tables-精品-2022-10-1010三、两个分类变量的列联表三、两个分类变量的列联表l列联表是考察两个分类变量相关关系的方法l列联表给出从属于两个分类变量不同类别的观测值的频数l如果两个分类变量各有r,c个类别,则列联表共有rc个单元格 Total 11 53 64 Foreign 4 16 20 Domestic 7 37 44 Car type 1 2 Total id-精品-2022-10-1011ltabulate命
6、令:l语法1指定两个变量的列联表ltabulate varname1 varname2 if in weight,optionsl范例:tabulate foreign id-精品-2022-10-1012l菜单:Statistics Summaries,tables,and tests Tables Two-way tables with measures of association-精品-2022-10-1013l语法2多个变量内存在的所有可能列联分析结果ltab2 varlist if in weight,optionsl范例:tab2 foreign id rep78-精品-2022
7、-10-1014l菜单:Statistics Summaries,tables,and tests Tables All possible two-way tabulations-精品-2022-10-1015四、列联表描述统计量四、列联表描述统计量l tabulate,summarize():单个或两个分类变量的描述性统计l格式:tabulate varname1 varname2 if in weight,optionsl选项:no means(不)包含均值,no standard(不)包含标准差,no freq(不)包含频数,no obs(不)包含观测值个数,missing将缺失值作为一
8、类-精品-2022-10-1016l菜单:Statistics Summaries,tables,and tests Tables One/two-way table of summary statistics-精品-2022-10-1017五、经验分布函数五、经验分布函数l对变量累积分布函数的估计lcumul命令:通常与scatter(做散点图)一起使用l格式:cumul varname if in weight,generate(newvar)optionsl选项:freq使用频数作为累积分布l范例:cumul price,generate(cprice)l scatter cprice price-精品-2022-10-1018l菜单:Statistics Summaries,tables,and tests Distributional plots and tests Generate cumulative distribution-精品-2022-10-1019六、正态性检验六、正态性检验lsktest varnamelswilk varname-精品-2022-10-1020本讲练习本讲练习-精品-2022-10-1021