0
$\begingroup$

I calculate the probability of finding a value as extremum as alpha using this function (toy distribution):

2*(1-pnorm(abs(0), mean = 0, sd = 1))

But I'm not sure how to do this when the null distribution does not behave as a Gaussian distribution. I've tried something like integrate(approxfun(neg.dis), lower=3, upper=7) but I don't think this is the way to do this.

This is the density plot of my distribution, I'm only interested in one tail (the most negative).

enter image description here

$\endgroup$

1 Answer 1

2
$\begingroup$

This is the proper way to do it.

You need a cumulative density function (so the integral of neg.dis), and then use this to extract the p-value for the sample you have.

$\endgroup$
4
  • $\begingroup$ I though it so, but I'm confused as by puting integrate(approxfun(neg.dis), lower=-4, upper= -1.2) I get an area of 1.000637 with absolute error < 0.00011 bigger than 1. And I'm not sure how to calculate the lowest bounds I can use (lower and upper) without getting the error message Error in integrate(approxfun(neg.dis), lower = -3.4, upper = -1.1) : non-finite function value $\endgroup$ Dec 21, 2018 at 15:17
  • $\begingroup$ As it's an approximation, it's "normal" to get numerical differences. The bounds should be the bounds of neg.dis (I don't know the language you are using, not familiar with this), inside, you can get an approximation, outside, it's basically 0 (lower) or 1 (higher). $\endgroup$ Dec 21, 2018 at 15:20
  • $\begingroup$ I'm confused because of thinks like this 1 - integrate(approxfun(neg.dis), lower=-4.5, upper=max(neg.dis$x))$value then I get -0.0009573024 as the area calculated is bigger than 1. Tha's why I'm not fully sure this is the ok way to calculate the probability, or it's just that I need more values to get my null distribution. $\endgroup$ Dec 21, 2018 at 15:39
  • $\begingroup$ Well, depends on what's the question you are asking, but integrateion or 1-integration is the same. With more points, you would get less numerical noise indeed. $\endgroup$ Dec 21, 2018 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.