|
在多变量图表中,增加的变量仅仅限于定距变量,也可以是定类变量。
打开数据集:
use "D:\Stata12.0\auto.dta", clear
双变量图表:
graph twoway scatter price weight #双变量之间的散点关系图
graph twoway line price weight #双变量之间的折线关系图
没想到会变成这个样子,可能两个变量之间实在是没有什么相关关系吧
graph twoway connected price weight #带圆点标记的折线关系图
graph twoway area price weight #面积关系图
以上三个图自动忽略掉,好像没有啥实际意义。
graph twoway bar price weight #柱形关系图
graph twoway spike price weight 针状关系图
至于柱状图和针状图为啥一个样,我觉得应该是变量数据较多,图形挤压所致。
graph twoway scatter price weight||lfit price weight 散点+线性拟合图
graph twoway scatter price weight||qfit price weight #散点+曲线拟合图
graph twoway scatter price weight||fpfit price weight #散点+曲线拟合图
lowess price weight #散点+曲线拟合图
sunflower price weight #花朵散点图
该图在输出图表的同时会输出一个汇总结果:
graph box price,over(foreign) #箱线图(分类变量)
graph bar price,over(foreign) #柱形图(分类变量)
graph hbar price,over(foreign) #条形图(分类变量)
graph dot price,over(foreign) #点状图(分类变量)
graph pie price,over(foreign) #饼状图(分类变量)
qqplot price weight #两个变量分部之间的距离
多变量图表:
graph matrix price weight foreign #矩阵图
这个就是相关系数图矩阵
以下图表需要用到两个及以上分类变量,所以这里我换了一个数据集:
use "F:\数据可视化\数据分析\计量经济学\计量经济学导论第四版(伍德里奇)\stata伍德里奇\WAGE1.DTA", clear
graph box wage,over(female) over(educ) #多维散点图+箱线图
graph bar wage,over(female) over(educ) #多维柱形图
graph dot wage,over(female) over(educ) #多维点图
|
|