两个列矩阵的散点图

Scatterplot of two column matrices

A(自变量)和B(因变量)是大小为1 x 1000的两个矩阵向量时,我目前在使用Stata绘制散点图时遇到问题。

我使用了命令 twoway scatter,但是这一直失败,因为 Stata 认为 AB 不是 是变量。但是,我用命令 matrix define 定义了 AB

变量 window 是空的,我不确定为什么 AB 而不是 变量。

示例代码:

matrix define A = [1,2,3,4,5,6,7,8,9,10]' 

matrix define B = [2,3,4,5,6,7,8,9,10]'

//drawing scatterplot with A vs B and overlay a horizontal line x = 5 onto the scatterplot.   
twoway scatter A B || xline(5)

我可以将矩阵声明为变量类型并保存它以便我可以在 twoway scatter 中重新使用它吗?

您需要使用svmat命令先创建变量然后绘制图形:

clear
matrix define A = (1,2,3,4,5,6,7,8,9,10)'
matrix define B = (2,3,4,5,6,7,8,9,10)'

svmat A
svmat B

twoway scatter A B, xline(5)

Stata 中的矩阵和变量是两个不同的东西。