【问题标题】:Graphing two cumulative distributions in Stata在 Stata 中绘制两个累积分布图
【发布时间】:2014-11-20 21:18:16
【问题描述】:

我正在尝试这段代码(就在下面),Stata 似乎读到了它——它没有显示任何错误——但它没有生成任何变量。这里是:

cumul price if dummy==1, gen(cprice1)

cumul price if dummy==0, gen (cprice2)

line cprice1 cprice2 price

你们能帮帮我吗?我可以用类似的代码绘制两个内核密度分布,其中虚拟对象的条件为“if”,我在其中存储了结果以供稍后绘制它们 - 遵循 Stata 中的帮助文件。但我不能用累积分布来做到这一点。

【问题讨论】:

  • help cumul 中的示例运行良好。试试看。如果您不提供可重现的示例,就很难找出问题所在。
  • Stata Journal 中的 distplot 支持累积分布图。 search distplot 在 Stata 中获取下载位置,然后选择最新的。
  • 问题是我没有生成变量。我想知道为什么。
  • 我们的问题是你没有给出一个可重现的例子。

标签: statistics distribution stata kernel-density


【解决方案1】:

如果您不需要存储变量,cdfplot 可以解决问题。如果没有,cumul 似乎可以正常工作:

sysuse auto, clear

/* Without Storing Variables */
ssc install cdfplot
cdfplot price, by(foreign) saving(cdfplot, replace)

/* With Variable Creation */ 
cumul price if foreign == 0, gen(cprice0)
cumul price if foreign == 1, gen(cprice1)

tw conn cprice* price, sort connect(J J) ms(none none) saving(cumulplot, replace)

/* Compare the two methods */
graph combine cdfplot.gph cumulplot.gph

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-10
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    相关资源
    最近更新 更多