【问题标题】:Using xline() with values from a matrix in Stata将 xline() 与来自 Stata 中的矩阵的值一起使用
【发布时间】:2015-10-23 10:03:27
【问题描述】:

我正在使用 xline() 在 Stata 中添加垂直线以散点图。我将线的值存储在矩阵中,这些值是不同子样本的平均值。现在我想使用矩阵中的值作为xline() 中的坐标。

我试过了:

mat means=J(1,5,.)
mat means[1,1]=mean(subsample1)
...

scatter data1 data2, xline(means[1,1])
scatter data3 data4, xline(means[1,2])
...

但是,我收到错误 invalid line argument

感谢任何提示!

【问题讨论】:

    标签: stata


    【解决方案1】:
    // open some example data
    sysuse nlsw88, clear
    
    // create a matrix of means
    reg grade ibn.race, hascons
    matrix means = e(b)
    
    // use those means in -xline()-
    scatter wage grade, xline(`=el(means,1,1)' `=el(means,1,2)' `=el(means,1,3)')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-23
      • 1970-01-01
      • 2017-09-10
      • 2018-02-01
      • 1970-01-01
      相关资源
      最近更新 更多