Search code examples
rstatisticsnormal-distributionp-value

Plotting p-value in normal distribution (in R)?


i am a beginner when it comes to statistics. I am trying to display p-value in a plot, or rather, to add an abline to display it on the plot of normal distribution. Currently I am doing it like this.

pVal = 0.04
abline(v=qnorm(pVal/2))

I am however not sure if this is correct. I would like to visualize whether p-value is above/below alpha (in this case lets say alpha=0.05).


Solution

  • You really need to spend some time with a basic R tutorial. I'm not sure what you want, but maybe this is close:

    x <- seq(-3, 3, length.out=100)
    plot(x, dnorm(x), typ="l")
    alpha <- .05
    a <- c(-1, 1) * qnorm(alpha/2)
    pVal <- 0.04
    v <- c(-1, 1) * qnorm(pVal/2)
    abline(v=a)
    abline(v=v, lty=2)
    

    Plot