使用 R 进行逆向统计
我想做的事情听起来很简单。我想用 R 绘制一条平均值为 100、标准差为 15 的正常 IQ 曲线。然后,我希望能够在其上叠加数据散点图。
有人知道该怎么做吗?
What I want to do sounds simple. I want to plot a normal IQ curve with R with a mean of 100 and a standard deviation of 15. Then, I'd like to be able to overlay a scatter plot of data on top of it.
Anybody know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我猜您想要做的是这样的:您想要绘制平均值为 100 且 sd = 15 的模型正态密度,并且您想要在其上覆盖经验密度 一些据称遵循模型正态密度的观察值,以便您可以直观地看到模型密度与经验密度的拟合程度。下面的代码应该做到这一点(这里,x将是实际观察的向量,但为了说明目的,我用混合正态分布 N(100,15) + 15*N(0,1) 生成它,即所谓的N(100,15) 分布加上噪声)。
I'm guessing what you want to do is this: you want to plot the model normal density with mean 100 and sd = 15, and you want to overlay on top of that the empirical density of some set of observations that purportedly follow the model normal density, so that you can visualize how well the model density fits the empirical density. The code below should do this (here, x would be the vector of actual observations but for illustration purposes I'm generating it with a mixed normal distribution N(100,15) + 15*N(0,1), i.e. the purported N(100,15) distribution plus noise).
好吧,它更像是一个直方图,因为我认为您期望它们更像是一个整数舍入过程:
如果您想要叠加 dnorm 的理论值,请使用其中之一:
-或者
Well, it's more like a histogram, since I think you are expecting these to be more like an integer rounded process:
If you want the theoretic value of dnorm superimposed, then use one of these:
-or
您可以使用以下方法生成 IQ 分数 PDF:
但是为什么要在密度曲线上叠加散点图呢?恕我直言,这很不寻常......
You can generate IQ scores PDF with:
But why would you like to overlay scatter over density curve? IMHO, that's very unusual...
除了其他好的答案之外,您可能有兴趣绘制多个面板,每个面板都有自己的图表。 类似的东西。
In addition to the other good answers, you might be interested in plotting a number of panels, each with its own graph. Something like this.