# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # # Computations used for the problems in this section of the text. # #----- # Ex 7.33 # DF = read.csv( "../../Data/CH07/ex7-33.txt", header=TRUE, quote="'" ) boxplot( DF$polymerization ) qqnorm( DF$polymerization ) qqline( DF$polymerization ) grid() # Construct the requested confidence interval: # n = length( DF$polymerization ) xbar = mean( DF$polymerization ) s = sd( DF$polymerization ) t_crit = qt( 1 - 0.05/2, n-1 ) xbar + ( s / sqrt(n) ) * t_crit * c(-1,+1) # Ex 7.34 # n = 14 xbar = 8.48 s = 0.79 t_crit = qt( 1 - 0.05, n-1 ) xbar - ( s / sqrt(n) ) * t_crit s_prediction = s * sqrt( 1 + 1 / n ) xbar - s_prediction * t_crit # Ex 7.35 # n = 15 xbar = 25.0 s = 3.5 t_crit = qt( 1 - 0.05/2, n-1 ) xbar + ( s / sqrt(n) ) * t_crit * c(-1,+1) # CI s_prediction = s * sqrt( 1 + 1/n ) xbar + s_prediction * t_crit * c(-1,+1) # PI # Ex 7.36 # n = 26 xbar = 370.69 s = 24.36 t_crit = qt( 1 - 0.05, n-1 ) xbar + ( s / sqrt(n) ) * t_crit # upper CI limit s_prediction = s * sqrt( 1 + 1/n ) xbar + s_prediction * t_crit # upper PI limit s_prediction_x_new = s * sqrt( 1/2 + 1/n ) t_crit = qt( 1 - 0.05/2, n-1 ) xbar + s_prediction_x_new * t_crit * c(-1,+1) # two-sided PI # Ex 7.37 # DF = read.csv( "../../Data/CH07/ex7-37.txt", header=TRUE, quote="'" ) qqnorm( DF$cadence ) qqline( DF$cadence ) n = 20 xbar = 0.9255 s = 0.0809 t_crit = qt( 1 - 0.05/2, n-1 ) xbar + ( s / sqrt(n) ) * t_crit * c(-1,+1) s_prediction = s * sqrt( 1 + 1/n ) xbar + s_prediction * t_crit * c(-1,+1) install.packages( c("tolerance"), dependencies=TRUE ) library(tolerance) normtol.int( DF$cadence, alpha=0.05, P=0.99 ) # Ex 7.38 # n = 25 xbar = 0.0635 s = 0.0065 t_crit = qt( 1 - 0.05/2, n-1 ) s_prediction = s * sqrt( 1 + 1/n ) xbar + s_prediction * t_crit * c(-1,+1) # two-sided PI s_tolerance = 2.972 xbar + s_tolerance * s * c(-1,+1) # Ex 7.39 # DF = read.csv( "../../Data/CH01/ex01-72.txt", header=TRUE, quote="'" ) Healthy = DF[ DF$Health_status == "Healthy", ] qqnorm(Healthy$volume) qqline(Healthy$volume) normtol.int( Healthy$volume, alpha=0.05, P=0.95, side=2 ) V = Healthy$volume n = length(V) xbar = mean(V) s = sd(V) t_crit = qt( 1 - 0.05/2, n-1 ) s_prediction = s * sqrt( 1 + 1/n ) xbar + s_prediction * t_crit * c(-1,+1) # two-sided PI # Ex 7.40 # DF = read.csv( "../../Data/CH01/ex01-13.txt", header=TRUE, quote="'" ) qqnorm(DF$strength) qqline(DF$strength) S = DF$strength n = length(S) xbar = mean(S) s = sd(S) t_crit = qt( 1 - 0.05, n-1 ) # we want a single lower bound xbar - s * sqrt( 1 + 1/n ) * t_crit # lower PI end point