-
Notifications
You must be signed in to change notification settings - Fork 4
/
a3kritieketwaarden.Rmd
62 lines (56 loc) · 2.71 KB
/
a3kritieketwaarden.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
# Kritieke waarden van $t$-verdeling {#app-kritieketwaarden}
```{r kritieketwaarden-hulpfiguur, echo=FALSE, fig.height=2}
# adapted from `kritieketwaarden_hulpfiguur.R`
# HQ 20140320
# alles met df=49
op <- par(mar=c(3,1,1,1)+0.1)
xx <- seq(1,4,by=.01)
yy <- dt(xx,df=49)
curve( dt(x,df=49), from=-4, to=4, xaxt="n", yaxt="n", xlab="", ylab="", bty="n", lwd=3 )
polygon( x=c(1,xx), y=c(0,yy), col="lavender", border="lavender" )
# 20240828 added other polygon corresponding to B, three commands
xx <- seq(-1,1,by=.01)
yy <- dt(xx,df=49)
polygon( x=c(-1,xx,1), y=c(0,yy,0), col="wheat1", border="wheat1" )
#
curve( dt(x,df=49), from=-4, to=4, xaxt="n", yaxt="n", xlab="", ylab="", bty="n", lwd=3, add=TRUE )
text( 1.5, dt(1.5,df=49)*.4, "p", adj=.5, cex=1 )
# 20240828 added other polygon corresponding to B, two more commands
text( -0.5, dt(0.5,df=49)*.4, "B/2", adj=.5, cex=1 )
text( +0.5, dt(0.5,df=49)*.4, "B/2", adj=.5, cex=1 )
#
axis( side=1, at=c(0,1), labels=c("0","t*"), cex=1, tick=F, line=-1 ) # cex is ignored
abline( h=0, lty=1, col="grey70" )
segments( x0=0, x1=0, y0=0, y1=dt(0,df=49), col="grey70" )
segments( x0=1, x1=1, y0=0, y1=yy[1], col="grey70" )
curve( dt(x,df=49), from=-4, to=4, xaxt="n", yaxt="n", xlab="", ylab="", bty="n", lwd=3, add=TRUE )
```
De hieronder gegeven kritieke grenswaarde $t^*$ heeft een overschrijdingskans $p$
onder $H_0$, d.w.z. $P(t \geq t^*|H_0)=p$, en heeft kans $B$ op een
waarde tussen $(-t^*, +t^*)$. De $t$-verdeling is symmetrisch rond
$t=0$, dus $P(t < -t^*) = P(t > t^*)$.
De tabel hieronder geeft de kritieke grenswaarden $t^*$ voor veel gebruikte overschrijdingskansen $p$ en betrouwbaarheidsintervallen $B$, voor de vrijheidsgraden aangegeven in de eerste kolom.
```{r A3.1, echo=FALSE}
pvals <- c(.2,.1,.05,.025,.01,.005,.0025,.001)
df <- c( seq(1,25,by=1),30,40,50,100,200,400 )
# add extra row for infinity d.f. (using normal distro)
# add extra columns, one for d.f. values and one for spacing
appendixt1 <- matrix("",nrow=length(df)+1,ncol=2+length(pvals)) # matrix of char strings
for (i in 1:length(df))
for (j in 1:length(pvals))
appendixt1[i,j+2] <- format( qt( p=pvals[j], lower.tail=FALSE, df=df[i] ),
digits=4, nsmall=3 )
i <- length(df)+1 # last row of matrix: normal distrib values
for (j in 1:length(pvals))
appendixt1[i,j+2] <- format( qnorm( p=pvals[j], lower.tail=FALSE ),
digits=4, nsmall=3 )
appendixt1[,1] <- c( format(df)," ∞ " ) # first column
appendixt1 <- rbind(
c( "", "p", as.character(pvals) ),
c( "", "B", paste(as.character(100-200*pvals),"%",sep="" ) ),
appendixt1
)
# suppress first row, and use as column names
knitr::kable(
appendixt1[-1,], booktabs=TRUE, col.names=appendixt1[1,], align="c" )
```