Created
April 7, 2016 18:12
-
-
Save Lakens/bf2924797475ae0f5bcd758ead576635 to your computer and use it in GitHub Desktop.
F-distribution and t-distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df1<-1 | |
df2<-100 | |
critF<-qf(.95, df1=df1, df2=df2) #determine critical F-value | |
critT<-qt(.975, df2) #determine critical F-value | |
critF #critical F-value | |
critT^2 #Critical t squared is the same as critical F-value | |
critT #critical t-value | |
x=seq(0,10,length=10000) | |
maxy<-ifelse(max(df(x,df1,df2))==Inf,1, max(df(x,df1,df2))) #set maximum y axis | |
#png(file=paste('Fdist.png'),width=8000,height=4000, res = 750) | |
plot(x,df(x,df1,df2),col='black',type='l', lwd=2, xlim=c(0,8), ylim=c(0,maxy), xlab="F- or t-value", ylab="Density",main=paste("F-distribution, df1 = ",df1,", df2 = ",df2), xaxt="n",yaxt="n") | |
x=seq(critF,10,length=10000) | |
z<-(df(x,df1,df2)) #determine upperbounds polygon | |
polygon(c(critF,x,10),c(0,z,0),col="skyblue") #draw polygon | |
x=seq(0,8,length=10000) | |
lines(x,dt(x,df=df2),col='palegreen4',type='l',lwd=2) | |
x=seq(critT,10,length=10000) | |
z<-(dt(x,df=df2)) #determine upperbounds polygon | |
polygon(c(critT,x,10),c(0,z,0),col="palegreen2") | |
axis(1, at = seq(0, 8, by = 1)) | |
#dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment