Key_Lab 9

pdf

School

Drexel University *

*We aren’t endorsed by this school

Course

410

Subject

Statistics

Date

Feb 20, 2024

Type

pdf

Pages

8

Uploaded by ChiefOtter2846

Report
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 1/8 Key_Lab 9 2023-11-29 Lab 9 t-Distribution Exercise 1 n=50 avg=220 sd=20 df=n-1 alpha=0.05 #By hand t_text=(2.021+2.00)/2 print(t_text) ## [1] 2.0105 #Using R t_R=qt(alpha/2,df,lower.tail=F) print(t_R) ## [1] 2.009575 By hand I got a t value of 2.0105 and by R I got a t value of 2.009575. The two values are very close to one another. Exercise 2 height=read.csv("/Users/zacharykey/Downloads/heights.csv") samp=sample(height$Height,30,replace=F) N=30 Avg=mean(samp) Sd=sd(samp) Df=(N-1) alpha
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 2/8 ## [1] 0.05 T_R=qt(alpha/2,Df,lower.tail=F) se=Sd/sqrt(N) ul=Avg+(T_R*se) ll=Avg-(T_R*se) #Checking to See if Mean falls in between print(c(ll,ul)) ## [1] 69.09684 71.19783 print(Avg) ## [1] 70.14733 #100 times num_iterations=100 count=0 for (i in 1:num_iterations) { samp =sample(height$Height, 30, replace = FALSE) N=length(samp) Avg=mean(samp) Sd=sd(samp) Df=N - 1 alpha=0.05 T_R=qt(alpha / 2, Df, lower.tail = FALSE) se=Sd / sqrt(N) ul=Avg+(T_R * se) ll=Avg-(T_R * se) if (mean(height$Height) >= ll && mean(height$Height) <= ul) { count <- count + 1 } } print(count)
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 3/8 ## [1] 97 The 95 confidence interval calculated was 68.7 for ll and 70.9 for ul. When the mean when run once was 69.8 and fell in between those bounds. When run 100 times I got the amount of means falling into that range from 97-99 times. The expected should of been 95 times as this is a 95 confidence interval. t-Test Exercise 1 #Made my own sense I could not import the Dataset as we had two labled the same data=sample(c(1:8),70,replace=T) qqnorm(data) qqline(data) Assumptions 1. Data is not continuous (but we still run the test anyways) 2. Normality of Dataset (looks good enough) 3. Random sampling Hypothesis
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 4/8 Null:The output mean is not equal to the expected mean Alternative: The output mean is equal to the expected mean Size=70 DF=Size-1 Sampavg=mean(data) SampSd=sd(data) alpha ## [1] 0.05 ## t-test by hand t_statistic=(Sampavg-4.5)/(SampSd/sqrt(Size)) t_text=(1.671+1.664)/2 print(c(t_statistic,t_text)) ## [1] 1.147078 1.667500 ## Using R t.test(data,mu=4.5,alternative = "less") ## ## One Sample t-test ## ## data: data ## t = 1.1471, df = 69, p-value = 0.8723 ## alternative hypothesis: true mean is less than 4.5 ## 95 percent confidence interval: ## -Inf 5.271089 ## sample estimates: ## mean of x ## 4.814286 qt(alpha,DF,lower.tail=F) ## [1] 1.667239 Alpha: 0.05 p-value: 0.2898 t-value= 1.6675 (hand), 1.6672 (R) Degree of Freedom: 69 The t-statistic value was 0.052807 and the t value was 1.667. The t-statistic value was less than the t value therefore we fail to reject the null. The p-value (0.521) is also greater than the critical value (0.05) which also supports we failed to reject the null. This means that the data set did not generate a mean that was equally to the expected mean of 4.5. Exercise 2
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 5/8 score=read.csv("/Users/zacharykey/Downloads/scores.csv") Score=score$Score qqnorm(Score) qqline(Score) Assumptions 1.Data is continuous 2.Data looks normal 3.Random Sampling Hypothesis Null: The student scores will be greater or equal to 75 Alternative: The student scores will be less than 75 size=30 dF=size-1 SampAVG=mean(Score) SampSD=sd(Score) alpha ## [1] 0.05
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 6/8 ## t-test by hand T_statistic=(SampAVG-75)/(SampSD/sqrt(size)) T_text=1.699 print(c(T_statistic,T_text)) ## [1] 2.724602 1.699000 ## Using R t.test(Score,mu=75,alternative = "less") ## ## One Sample t-test ## ## data: Score ## t = 2.7246, df = 29, p-value = 0.9946 ## alternative hypothesis: true mean is less than 75 ## 95 percent confidence interval: ## -Inf 83.064 ## sample estimates: ## mean of x ## 79.96667 qt(alpha,dF,lower.tail=F) ## [1] 1.699127 Alpha: 0.05 p-value: 0.9946 t-value= 1.699 (hand), 1.699127 (R) Degree of Freedom:29 The t-statistic value was 2.72 and the t value was 1.699. The t-statistic value was less than the t value therefore we fail to reject the null. The p-value (.9946) is also greater than the critical value (0.05) which also supports that we to reject the null. This means that the scores from the school were greater or equal to 75. Paired t-test Exercise 1 pepper=read.csv("/Users/zacharykey/Downloads/peppers.csv") PlantA=pepper$PlantA PlantB=pepper$PlantB Pepperdiff=PlantA-PlantB Assumptions
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 7/8 1. Measurements are continuous (Scoville units) 2. Normality was told to be assumed 3. Matched Pairs 4. Random Sampling Hypothesis Null: Plant A has less than or equal Scoville units than Plant B Alternative: Plant A has greater Scoville units than Plant B S=10 Free= S-1 Pepperavg=mean(Pepperdiff) Peppersd=sd(Pepperdiff) alpha ## [1] 0.05 # By hand T_Statistic=(Pepperavg-0)/(Peppersd/sqrt(S)) TR=qt(alpha,Free,lower.tail=F) print(c(T_Statistic,TR)) ## [1] 2.582188 1.833113 #Using R t.test(PlantA,PlantB,paired = T, alternative = "greater") ## ## Paired t-test ## ## data: PlantA and PlantB ## t = 2.5822, df = 9, p-value = 0.0148 ## alternative hypothesis: true mean difference is greater than 0 ## 95 percent confidence interval: ## 1189.382 Inf ## sample estimates: ## mean difference ## 4100 t_R ## [1] 2.009575 Alpha: 0.05 p-value: 0.0148 t-value= 2.009575 Degree of Freedom:9
12/5/23, 9:45 PM Key_Lab 9 file:///Users/zacharykey/Key_Lab-9.html 8/8 The t-statistic value was 2.58 and the t value was 2.009. The t-statistic value was greater than the t value therefore the null is rejected. The p-value (.0148) is also less than the critical value (0.05) which also supports the null is rejected. This means that Plant A does have a higher Scoville unit peppers than Plant B.