Minor changes
This commit is contained in:
parent
f052a42c03
commit
1fdb98af89
3 changed files with 20 additions and 8 deletions
|
@ -1,10 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
N=rnorm(9999999,mean=0,sd=1)
|
N=rnorm(9999999,mean=0,sd=1)
|
||||||
cdf=ecdf(N)
|
cdf=ecdf(N)
|
||||||
zscore=-1.8
|
zscore=-1.8
|
||||||
|
|
||||||
message(paste0("Alpha approximated is ",cdf(zscore)))
|
message(paste0("Alpha approximated is ",cdf(zscore)))
|
||||||
message(paste0("Alpha from built-in CDF ",pnorm(zscore,mean=0,sd=1)))
|
message(paste0("Alpha from built-in CDF ",pnorm(zscore,mean=0,sd=1)))
|
||||||
message(paste0("Bonus: zscore from p-value ",qnorm(0.02275,mean=0,sd=1)))
|
|
||||||
|
|
||||||
|
|
7
source/statistics/code/ztest_rejection_region.R
Normal file
7
source/statistics/code/ztest_rejection_region.R
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
alpha=0.0003
|
||||||
|
lower=qnorm(alpha,mean=0,sd=1)
|
||||||
|
upper=qnorm(1-alpha,mean=0,sd=1)
|
||||||
|
|
||||||
|
message(paste0("Rejection region left tail Z in ]-inf,",lower,"]"))
|
||||||
|
message(paste0("Rejection region right tail Z in [",lower,",+inf["))
|
||||||
|
|
|
@ -63,15 +63,24 @@ Output example:
|
||||||
|
|
||||||
Alpha approximated is 0.0359588035958804
|
Alpha approximated is 0.0359588035958804
|
||||||
Alpha from built-in CDF 0.0359303191129258
|
Alpha from built-in CDF 0.0359303191129258
|
||||||
Bonus: zscore from p-value -2.0000024438996
|
|
||||||
|
|
||||||
If the :math:`\alpha` value given by the test is lower or equal to the *p-value* threshold chosen prior the test,
|
If the :math:`\alpha` value given by the test is lower or equal to the *p-value* threshold chosen prior the test,
|
||||||
:math:`H_0` is rejected and :math:`H_1` is considered accepted.
|
:math:`H_0` is rejected and :math:`H_1` is considered accepted.
|
||||||
|
|
||||||
Using the z-score from *p-value* function allows you to create a *rejection region*.
|
An alternative way of doing the z-test is to build a **rejection region** from the *p-value*.
|
||||||
It is an interval :math:`[\mathrm{zscore}_{min},\mathrm{zscore}_{max}]`.
|
This is done by using the reverse :ref:`CDF <CDF>` function :math:`\Phi_{0,1}^{-1}(x)` as in the following code:
|
||||||
If the sample z-score is not part of the interval, then :math:`H_0` is rejected and :math:`H_1` is considered accepted.
|
|
||||||
|
|
||||||
|
.. literalinclude:: ../../code/ztest_rejection_region.R
|
||||||
|
:language: R
|
||||||
|
|
||||||
|
Output:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
Rejection region left tail Z in ]-inf,-3.43161440362327]
|
||||||
|
Rejection region right tail Z in [-3.43161440362327,+inf[
|
||||||
|
|
||||||
|
Thus, if the z-score if part of one of the rejection regions, :math:`H_0` is rejected and :math:`H_1` is considered accepted.
|
||||||
|
|
||||||
One-tailed vs Two-tailed
|
One-tailed vs Two-tailed
|
||||||
========================
|
========================
|
||||||
|
|
Loading…
Add table
Reference in a new issue