Math411 Key_Lab 2

pdf

School

Drexel University *

*We aren’t endorsed by this school

Course

411

Subject

Mathematics

Date

Feb 20, 2024

Type

pdf

Pages

10

Uploaded by ChiefOtter2846

Report
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 1/10 Math411 Key_Lab 2 2024-01-17 T-test for Two Independent Random Samples Exercise 1 #A Null Hypothesis: The population length mean in small and large bass are equal. Alternative Hypothesis: The population length mean in small and large bass are not equal. Assumptions: 1. Samples are collected randomly from each of the two populations of interest. 2.The variable is measured on a continuous scale 3.The variable is approximately normally distributed #B #two sample t-test mean1=272.8 mean2=164.8 sd1=96.4 sd2=40 n1=125 n2=97 ttest=(mean1-mean2)/sqrt(((sd1*sd1)/n1)+(sd2*sd2)/n2) ttest ## [1] 11.33153 tcrit=qt(.05/2,sd2-1,lower.tail = F) tcrit ## [1] 2.022691 The t-test gave a value of 11.33 while the t-critical value come out to be 2.023. Since the t value is greater than the t-critical value we would reject the null. This means that the population lengths of the large and small bass are probability not equal.
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 2/10 #C lb=(mean1-mean2)-tcrit*sqrt((sd1^2/n1)+(sd2^2/n2)) ub=(mean1-mean2)+tcrit*sqrt((sd1^2/n1)+(sd2^2/n2)) bin=c(lb,ub) bin ## [1] 88.72189 127.27811 #D In part B the comparison between the t-value and t-critical value supported that the population mean lengths were not equal to each other. In part C we were to find the 95% confidence interval in the difference of the means. If they were equal the values should have been zero but in this case the difference ranged from 89.23 to 126.76. #E largebass=rnorm(n=n1,mean=mean1,sd=sd1) smallbass=rnorm(n=n2,mean=mean2,sd=sd2) t.test(largebass,smallbass,varequal=T) ## ## Welch Two Sample t-test ## ## data: largebass and smallbass ## t = 11.552, df = 181.32, p-value < 2.2e-16 ## alternative hypothesis: true difference in means is not equal to 0 ## 95 percent confidence interval: ## 93.39527 131.86998 ## sample estimates: ## mean of x mean of y ## 274.2540 161.6213 The output of the random sample of each population when run through a t-test gave us a t-value of 11.728 and a p-value less than 2.2e-16. The p-value being less than our critical value 0.05 supports the rejection of the null.This shows that even in a random sample of the data the population mean length is probability not going to be equal. Exercise 2 #A Null:The population mean reaction time between men and women are equal. Alternative: The population mean reaction time between men and women are not equal.
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 3/10 Assumptions: 1.Samples are collected randomly from each of the two populations of interest. 2.The variable is measured on a continuous scale 3.The variable is approximately normally distributed #B mean_1=170.21 mean_2=181.31 s_1=32.643 s_2=45.988 n_1=58 n_2=68 ttest2=(mean_1-mean_2)/sqrt(((s_1*s_1)/n_1)+(s_2*s_2)/n_2) ttest2 ## [1] -1.578112 tcrit2=qt(.05/2,n_1-1,lower.tail = F) tcrit2 ## [1] 2.002465 Taking the absolute value of our t-value it comes out to be 1.58 while the t-critical value is 2.002. Since the t- critical value is greater that means we fail to reject the null. This means that there is a high chance that the population times are equal to each other. #C lower=(mean_1-mean_2)-tcrit*sqrt((s_1^2/n_1)+(s_2^2/n_2)) upper=(mean_1-mean_2)+tcrit*sqrt((s_1^2/n_1)+(s_2^2/n_2)) bin2=c(lower,upper) bin2 ## [1] -25.327044 3.127044 #D In part B the comparison between the t-value and t-critical value supported that the population mean times were equal to each other. In part C we were to find the 95% confidence interval in the difference of the means. If they were equal the values should have been zero in this case it goes through zero as the difference ranged from -25.327 to 3.127 meaning that they could be equal.
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
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 4/10 #E men=rnorm(n=n_1,mean=mean_1,sd=s_1) women=rnorm(n=n_2,mean=mean_2,sd=s_2) t.test(men,women,varequal=T) ## ## Welch Two Sample t-test ## ## data: men and women ## t = -3.2586, df = 123.96, p-value = 0.001445 ## alternative hypothesis: true difference in means is not equal to 0 ## 95 percent confidence interval: ## -35.00852 -8.55077 ## sample estimates: ## mean of x mean of y ## 165.2034 186.9830 The output of the random sample gave a t-value of -1.9544 and a p-value of 0.05298.The p-value is greater than the critical value of 0.05. This means that there is not enough evidence to reject the null. This shows that even in a random sample of the data the population mean times are probability going to be equal. Exercise 3 #A Null Hypothesis:The mean growth length is equal in treated vs untreated plants Alternative Hypothesis: The mean growth length is not equal in treated vs untreated plants. Assumptions: 1.Samples are collected randomly from each of the two populations of interest. 2.The variable is measured on a continuous scale 3.The variable is approximately normally distributed
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 5/10 #B treated=c(15.2,12.3,11.6,14.8,10.0,14.2) untreated=c(13.5,9.8,10.2,8.7,9.2,9.0) #Mean MEAN1=mean(treated) MEAN2=mean(untreated) #Standard Deviation SD1=sd(treated) SD2=sd(untreated) #Sample size N=6 #T-test TTEST=(MEAN1-MEAN2)/sqrt(((SD1*SD1)/N)+(SD2*SD2)/N) TTEST ## [1] 2.670744 #T-critical Tcrit=qt(.05/2,N-1,lower.tail = F) Tcrit ## [1] 2.570582 The t-value came out to be 2.67 while the t-critical value is 2.5705. Since the t-value is greater that means we reject the null. This means that there is a high probability that the growth means are not equal to each other. #C Lower=(MEAN1-MEAN2)-Tcrit*sqrt((SD1^2/N)+(SD2^2/N)) Upper=(MEAN1-MEAN2)+Tcrit*sqrt((SD1^2/N)+(SD2^2/N)) Bin=c(Lower,Upper) Bin ## [1] 0.1106349 5.7893651 #D In part B the comparison between the t-value and t-critical value supported that the population mean lengths were not equal to each other. In part C we were to find the 95% confidence interval in the difference of the means. If they were equal the values should have been zero or at least go through zero. The difference between these
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 6/10 means ranged from 0.1106 to 5.789 meaning that they are probably not equal. #E treatplant=rnorm(n=N,mean=MEAN1,sd=SD1) untreatplant=rnorm(n=N,mean=MEAN2,sd=SD2) t.test(treatplant,untreatplant,varequal=T) ## ## Welch Two Sample t-test ## ## data: treatplant and untreatplant ## t = 5.9054, df = 9.3283, p-value = 0.0001976 ## alternative hypothesis: true difference in means is not equal to 0 ## 95 percent confidence interval: ## 2.455348 5.478168 ## sample estimates: ## mean of x mean of y ## 12.969526 9.002769 The output of the random sample of each population when run through a t-test gave us a t-value of 1.6813 and a p-value of 0.1351. The p-value being less than our critical value 0.05 supports the rejection of the null.This shows that even in a random sample of the data the population mean growth is probability not going to be equal between treated and untreated plants. Exercise 4 #A Null Hypothesis: The mean pulse rate between women smokers and non-smokers are equal. Alternative Hypothesis: The mean pulse rate between women smokers and non-smokers are not equal. Assumptions: 1.Samples are collected randomly from each of the two populations of interest. 2.The variable is measured on a continuous scale 3.The variable is approximately normally distributed
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
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 7/10 #B studentdata=read.csv("/Users/zacharykey/Downloads/Student_Data.csv") splitstudent=split(studentdata,studentdata$Gender) female=splitstudent$female femalepulse=female$Pulse femalesmoke=split(femalepulse,female$Smoke) nosmoke=femalesmoke$no yessmoke=femalesmoke$yes #Mean Mean1=mean(nosmoke) Mean2=mean(yessmoke) #SD Sd1=sd(nosmoke) Sd2=sd(yessmoke) #Sample Size N1=77 N2=11 #T-test Ttest=(Mean1-Mean2)/sqrt(((Sd1*Sd1)/N1)+(Sd2*Sd2)/N2) Ttest ## [1] -0.668862 #T-critical TCRIT=qt(.05/2,N2-1,lower.tail = F) TCRIT ## [1] 2.228139 Taking the absolute value of our t-value it comes out to be 0.669 while the t-critical value is 2.228. Since the t- critical value is greater that means we fail to reject the null. This means that there is a high chance that the population pulses are equal to each other.
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 8/10 #C LOWER=(Mean1-Mean2)-TCRIT*sqrt((Sd1^2/N1)+(Sd2^2/N2)) UPPER=(Mean1-Mean2)+TCRIT*sqrt((Sd1^2/N1)+(Sd2^2/N2)) BIN=c(LOWER,UPPER) BIN ## [1] -16.818706 9.052472 In part B the comparison between the t-value and t-critical value supported that the population mean pulses were equal to each other. In part C we were to find the 95% confidence interval in the difference of the means. If they were equal the values should have been zero or go through zero. The difference ranged from -16.8187 to 9.052472 meaning that they could be equal. #E Smoke=rnorm(n=N1,mean=Mean1,sd=Sd1) Nosmoke=rnorm(n=N2,mean=Mean2,sd=Sd2) t.test(Smoke,Nosmoke,varequal=T) ## ## Welch Two Sample t-test ## ## data: Smoke and Nosmoke ## t = -1.8025, df = 12.571, p-value = 0.09549 ## alternative hypothesis: true difference in means is not equal to 0 ## 95 percent confidence interval: ## -18.028270 1.659336 ## sample estimates: ## mean of x mean of y ## 83.47065 91.65512 The output of the random sample gave a t-value of -0.37444 and a p-value of 0.71513.The p-value is greater than the critical value of 0.05. This means that there is not enough evidence to reject the null. This shows that even in a random sample of the data the population mean pulses are probability going to be equal. Mann-Whitney U test Exercise 1 #A
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 9/10 Null Hypothesis: There is no difference in interaction time between pairs with and without a female. Alternative Hypothesis: There is a difference in interaction time between pairs with and without a female. #B #Ranking NoFemale=c(3,4,2,5,1,11) Female=c(8,6,10,9,7,12) Ua=(6*6)+(42/2)-26 Ub=36-Ua Ua ## [1] 31 Ub ## [1] 5 The U-Statistic value is 31 and the U-critical value based on a two-tailed 0.05 critical value with sample size of 6 was 5. Since the U-statistic value is greater than the U-critical value the null is rejected.This means that the null is rejected,indicating a high probability of a difference in interaction time between pairs with and without a female. #C wilcox.test(NoFemale,Female,correct=F) ## ## Wilcoxon rank sum exact test ## ## data: NoFemale and Female ## W = 5, p-value = 0.04113 ## alternative hypothesis: true location shift is not equal to 0 The W value is 5 which is equal to what I got for the Ub value by hand. The p-value is 0.04113 which is below the critical value of 0.05. This supports that the null is rejected,indicating a high probability of a difference in interaction time between pairs with and without a female. Exercise 2 #A Null Hypothesis:There is no difference in enzyme activity between the treated and untreated groups. Alternative Hypothesis: There is a difference in enzyme activity between the treated and untreated groups
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
1/23/24, 9:32 PM Math411 Key_Lab 2 file:///Users/zacharykey/Math411-Key_Lab-1.html 10/10 #B Treated=c(10,14,11,4.5,13,8.5,12) unTreated=c(3,7,1.5,8.5,6,1.5,4.5) UA=(7*7)+(56/2)-73 UB=(7*7)-UA UA ## [1] 4 UB ## [1] 45 The U-Statistic value is 45 and the U-critical value based on a two-tailed 0.05 critical value with sample size of 7 was 8. Since the U-statistic value is greater than the U-critical value the null is rejected.This means that the null is rejected,indicating a high probability of a difference in enzyme activity between the treated and untreated groups #C wilcox.test(Treated,unTreated,correct=F) ## Warning in wilcox.test.default(Treated, unTreated, correct = F): cannot compute ## exact p-value with ties ## ## Wilcoxon rank sum test ## ## data: Treated and unTreated ## W = 45, p-value = 0.008587 ## alternative hypothesis: true location shift is not equal to 0 The W value is 45 which is equal to what I got for the Ub value by hand. The p-value is 0.008587 which is below the critical value of 0.05. This supports that the null is rejected,indicating a high probability of a difference in enzyme activity between the treated and untreated groups. There also was a warning that it could connot cupte exact p-value with ties which I am unsure what that means.