首页 > 解决方案 > 绘制R中各种分布曲线下的面积

问题描述

假设我试图为学生 t 分布找到某个值以下的区域。例如,我计算我的 t 检验统计量为 t=1.78,自由度为 23。我知道如何使用 pt() 函数获得 t=1.78 以上曲线下的面积。如何获得具有 23 个自由度的学生分布图和 1.78 以上曲线下的区域阴影。也就是说,我希望用适当的曲线绘制 pt(1.78,23,lower.tail=FALSE)阴影区域。有没有办法做到这一点?

标签: rplotdistributionprobability-distribution

解决方案


ggplot版本:

ggplot(data.frame(x = c(-4, 4)), aes(x)) +
  stat_function(fun = dt, args =list(df =23)) +
  stat_function(fun = dt,   args =list(df =23),
                xlim = c(1.78,4),
                geom = "area") 

在此处输入图像描述


推荐阅读