# topic 11 e the Student's-t # # for Student's-t with 7 degrees of freedom # find P( X < -1.43 ) pt( -1.43, 7 ) # for Student's-t with 15 degrees of freedom # 1) find P( X < -1.3 ) pt( -1.3, 15 ) # 2) find P( X > 2.6 ) 1 - pt( 2.6 ,15 ) # old way pt( 2.6, 15, lower.tail = FALSE) # better way # 3) find P( X < -1.83 or X > 1.54 ) pt( -1.83, 15 ) + (1 - pt( 1.54, 15) ) #old way pt( -1.83, 15 ) + pt( 1.54, 15, lower.tail=FALSE ) #better way # 4) find P( X < -2.45 or X > 2.45 ) pt( -2.45, 15 ) + (1 - pt( 2.45, 15) ) #old way pt( -2.45, 15 ) + pt( 2.45, 15, lower.tail=FALSE ) #better way # or, using symmetry 2 * pt( -2.45, 15 ) # 5) find P( 0.48 < X < 1.76 ) pt( 1.76, 15) - pt( 0.48, 15 ) # 6) find P( -2.37 < X < 2.37 ) pt( 2.37, 15) - pt( -2.37, 15 ) # or, using the complement 1 - 2*pt( -2.37, 15 ) # For Student's-t with 11 degrees of freedom # find the value of y such that # 7) P( X < y ) = 0.33 qt( 0.33, 11 ) # 8) P( X > y ) = 0.075 qt( 1 - 0.075, 11 ) # the old, ugly way qt( 0.075, 11, lower.tail = FALSE ) # the better way # 9) P( X < -y or X > y ) = 0.08 -qt( 0.08/2, 11 ) # note the leading - qt( 0.08/2, 11, lower.tail=FALSE) # more clear statement # 10) P( -y < X < y ) = 0.033 qt( (1 - 0.033)/2, 11, lower.tail=FALSE) # when mean=154.3 and standard deviation = 13.2 # and for 24 degrees of freedom, find P( X < 140.0 ) t <- (140 -154.3)/13.2 pt( t, 24 ) # when mean=483.2 and standard deviation=26.4 # with 27 degrees of freedom, find y such # that P( X < y ) = 0.15. t <- qt( 0.15, 27 ) t t*26.4 + 483.2 ################################## ###### B O N U S #### ################################## # # It seems to be a real shame that pt() and qt() # do not have the mean= and sd= parameters that we # had in pnorm() and qnorm(). If it is important # for us to have such parameters in pt() and qt() # then we can just define new functions that do # have them. pt_full <- function( t_val, df_val, mean_val=0, sd_val=1, ...) { t_stand <- (t_val - mean_val)/ sd_val pt( t_stand, df_val, ...) } qt_full <- function( t_area, df_val, mean_val=0, sd_val=1, ...) { t_stand <-qt( t_area, df_val, ... ) t_val <- t_stand * sd_val + mean_val t_val } # # Once we run those statements we can use the # new functions. # # when mean=154.3 and standard deviation = 13.2 # and for 24 degrees of freedom, find P( X < 140.0 ) pt_full( 140.0, 24, mean=154.3, sd=13.2) # when mean=483.2 and standard deviation=26.4 # with 27 degrees of freedom, find y such # that P( X < y ) = 0.15. qt_full( 0.15, 27, mean=483.2, sd=26.4 )