-
Notifications
You must be signed in to change notification settings - Fork 4
/
a2kritiekeZwaarden.Rmd
78 lines (70 loc) · 3.12 KB
/
a2kritiekeZwaarden.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Standaard-normale kansverdeling {#app-kritiekeZwaarden}
<!-- kritiekeZwaarden_hulpfiguur.R, no caption, no labels -->
```{r kritiekeZwaarden-hulpfiguur, echo=FALSE, fig.height=2}
op <- par(mar=c(3,1,1,1)+0.1)
xx <- seq(1,4,by=.01)
curve( dnorm(x), from=-4, to=4, xaxt="n", yaxt="n", xlab="", ylab="", bty="n", lwd=3 )
yy <- dnorm(xx,0,1)
polygon( x=c(1,xx), y=c(0,yy), col="lavender", border="lavender" )
# 20201128 added other polygon corresponding to B, three commands
xx <- seq(-1,1,by=.01)
yy <- dnorm(xx,0,1)
polygon( x=c(-1,xx,1), y=c(0,yy,0), col="wheat1", border="wheat1" )
#
curve( dnorm(x), from=-4, to=4, xaxt="n", yaxt="n", xlab="", ylab="", bty="n", lwd=3, add=T )
text( 1.5, dnorm(1.5)*.4, "p", adj=.5, cex=1 )
# 20201128 added other polygon corresponding to B, two more commands
text( -0.5, dnorm(0.5)*.4, "B/2", adj=.5, cex=1 )
text( +0.5, dnorm(0.5)*.4, "B/2", adj=.5, cex=1 )
axis( side=1, at=c(0,1), labels=c("0","Z*"), cex=1, tick=F, line=-1 ) # cex is ignored
# abline( h=0, lty=1, col="grey70" ) # should not extend outside tails of distribution
segments( x0=-4, x1=4, y0=0, col="grey70" ) # as X axis
segments( x0=0, x1=0, y0=0, y1=dnorm(0), col="grey70" )
segments( x0=1, x1=1, y0=0, y1=yy[1], col="grey70" )
curve( dnorm(x), from=-4, to=4, xaxt="n", yaxt="n", xlab="", ylab="", bty="n", lwd=3, add=T )
par(op)
```
De hieronder gegeven kritieke grenswaarde $Z^*$ heeft een overschrijdingskans $p$ onder $H_0$,
d.w.z. $P(Z > Z^*|H_0)=p$ (de blauwe oppervlakte),
en heeft kans $B$ op een waarde tussen $(-Z^*, +Z^*)$ (de gele oppervlakte).
De $Z$-verdeling is symmetrisch rond $Z=0$, dus $P(Z < -Z^*) = P(Z > Z^*)$.
---
De eerste tabel geeft de kritieke grenswaarden $Z^*$ voor veel gebruikte overschrijdingskansen $p$ en betrouwbaarheidsintervallen $B$:
```{r A2.1, echo=FALSE}
pvals <- c(.2,.1,.05,.025,.01,.005,.0025,.001)
appendixZ1 <- matrix("",nrow=1,ncol=1+length(pvals)) # matrix of char strings
for (i in 1:1)
for (j in 1:length(pvals))
appendixZ1[i,j+1] <- format( qnorm( p=pvals[j], lower.tail=FALSE),
digits=4, nsmall=3 )
appendixZ1 <- rbind(
c( "p", as.character(pvals) ),
c( "B", paste(as.character(100-200*pvals),"%",sep="" ) ),
appendixZ1
)
appendixZ1[3,1] <- "Z*"
# suppress first row, and use as column names
knitr::kable(
appendixZ1[-1,], booktabs=TRUE, col.names=appendixZ1[1,], align="c" )
```
---
De tweede tabel geeft overschrijdingskansen $p$ en betrouwbaarheidsintervallen $B$ voor afgeronde kritieke grenswaarden $Z^*$:
```{r A2.2, echo=FALSE}
Zvals <- seq(from=0.5, to=3.5, by=0.5)
pvals <- pnorm(Zvals, lower.tail=FALSE )
appendixZ2 <- matrix("",nrow=1,ncol=length(pvals)+1)
# for (i in 1:1)
# for (j in 1:length(pvals))
# appendixZ2[i,j+1] <- format( Zvals,
# digits=3, nsmall=1 )
appendixZ2[1,2:ncol(appendixZ2)] <- Zvals
appendixZ2 <- rbind(
c( "p", format(pvals, digits=1, scientific=FALSE) ),
c( "B", paste(as.character(round(100-200*pvals,digits=2)),"%",sep="" ) ),
appendixZ2
)
appendixZ2[3,1] <- "Z*"
# suppress first row, and use as column names
knitr::kable(
appendixZ2[-1,], booktabs=TRUE, col.names=appendixZ2[1,], align="c" )
```