Assignment-4

pdf

School

McMaster University *

*We aren’t endorsed by this school

Course

2B03

Subject

Statistics

Date

Apr 3, 2024

Type

pdf

Pages

6

Uploaded by MinisterAnt14343

Report
2B03 Assignment 4 Statistical Inference (Chapters 7, 8, & 9) Matthew Musulin 400329990 Due Thursday November 18 2021 Instructions: You are to use R Markdown for generating your assignment output file. You begin with the R Markdown script downloaded from A2L, and need to pay attention to information provided via introductory material posted to A2L on working with R, R Markdown. Having downloaded all necessary files, placed them in the same folder/directory, and added your answers to the R Markdown script, you then are to generate your output file using “Knit to PDF” and, when complete, upload both your R Markdown file and your PDF file to the appropriate folder on A2L. 1. Define the following terms in a sentence (or short paragraph) and state a formula if appropriate (this question is worth 5 marks). i. Type II Error A term referring a false null hypothesis. Type II errors describe what occurs when one fails to reject a null hypothesis that is actually false. ii. Power of a Test It is the probability of making the correct decision if the alternative hyopthesis is true. That is, it is the probability of rejecting the null hypothesis H0 when the hypothesis HA is the hypothesis that is true. iii. Goodness of Fit Test Used to compare an anticpated frequency to anactual frequency. Null hypotheis and an alternative hypothesis is needed in order to calculate a chi-square goodness-of-fit. The critical value can be determined using the significance level. iv. P -value Assuming H0 is true, it is the probability that the test statistic would take a value as extreme or more extreme than that actually observed. v. Simple Regression Analysis A statistical tool for quantifying the relationship between one independent variable and one dependent variable based on past experience or observations. 2. A coin operated coffee machine is set to pour 8 oz per cup. A random sample of the weights of a number of cups is as follows: 8.40, 8.25, 8.05, 7.84, 7.36, 8.54, 7.56, 7.56, 8.02, 7.39, 8.34, 8.56. Test the hypothesis that the machine is delivering at the level set by the manufacturer. Use a 0.01 level of significance (this question is worth 2 marks). x = c( 8.4 , 8.25 , 8.05 , 7.84 , 7.36 , 8.54 , 7.56 , 7.56 , 8.02 , 7.39 , 8.34 , 8.56 ) t.test(x, mu= 8 , alternative= "less" , conf.level= 0.99 ) ## 1
## One Sample t-test ## ## data: x ## t = -0.085097, df = 11, p-value = 0.4669 ## alternative hypothesis: true mean is less than 8 ## 99 percent confidence interval: ## -Inf 8.335194 ## sample estimates: ## mean of x ## 7.989167 Therefore because the p-value which is 0.4669 > 0.01 we do not reject H0 and confirm that the coffee machine is delivering at the level set by the manufacturer. 3. Two different brands of milk are randomly sampled, and the fat content in each bottle of milk is determined. Twenty-six bottles of Brand A milk yielded an average fat content of ¯ X 1 = 25 grams with s 2 1 = 4 , and thirty one bottles of Brand B yielded an average fat content of ¯ X 2 = 25 . 8 grams with s 2 2 = 7 (this question is worth 3 marks). Test the hypothesis that both brands have identical average fat content at the 5% level of significance. x1 = 25 x2 = 25.8 s12 = 4 s22 = 7 n1 = 26 n2 = 31 S2 = (((n1 -1 )*s12)+((n2 -1 )*s22))/(n1+n2 -2 ) S2 ## [1] 5.636364 tstat = (x1-x2)/(sqrt(S2*(( 1 /n1)+( 1 /n2)))) tstat ## [1] -1.267128 pvalue = pt(abs(tstat), df= n1+n2 -2 , lower.tail= FALSE) pvalue ## [1] 0.1052243 Therefore because the p-value 0.105 > 0.05 we do not reject H0 and confirm that both brands have identical average fat content. 4. To compare two programs for training industrial workers to perform a skilled job, 20 workers are included in an experiment. Of these, 10 are selected at random and trained by method 1; the remaining 10 are trained by method 2. After completion of training, all the workers are subjected to a time-and-motion test that records the speed of performance of a skilled job. The following time, as measured in minutes, is obtained. Method Method 1 15 20 11 23 16 21 18 16 27 24 Method 2 23 31 13 19 23 17 28 26 25 28 Test the hypothesis that the mean job time is equal before and after training with method 1 and 2 versus the alternative that it is significantly less after training with method 1 than after training with 2
method 2. Use a signficance level of α = 0 . 05 (this question is worth 4 marks). x = c( 15 , 20 , 11 , 23 , 16 , 21 , 18 , 16 , 27 , 24 ) y = c( 23 , 31 , 13 , 19 , 23 , 17 , 28 , 26 , 25 , 28 ) mean(x) ## [1] 19.1 mean(y) ## [1] 23.3 sd(x) ## [1] 4.817791 sd(y) ## [1] 5.558777 t.test(x,y, var.equal= T, alternative= "less" ) ## ## Two Sample t-test ## ## data: x and y ## t = -1.8055, df = 18, p-value = 0.04387 ## alternative hypothesis: true difference in means is less than 0 ## 95 percent confidence interval: ## -Inf -0.1662568 ## sample estimates: ## mean of x mean of y ## 19.1 23.3 Therefore because the p-value 0.4387 < 0.05 we reject H0. 5. A Canadian-wide marketing survey found that only one-fifth of Canadians drink beer on a regular basis. A random sample of 36 residents in North York found nine who were regular beer drinkers. Test whether or not North York has a greater then the national proportion of beer drinkers (i.e. test H 0 : π = 0 . 2 versus H 1 : π > 0 . 2 - this question is worth 3 marks). res <- prop.test( x= 9 , n= 36 , p= 0.2 , alternative= "greater" , correct= FALSE) res ## ## 1-sample proportions test without continuity correction ## ## data: 9 out of 36, null probability 0.2 ## X-squared = 0.5625, df = 1, p-value = 0.2266 ## alternative hypothesis: true p is greater than 0.2 ## 95 percent confidence interval: ## 0.151666 1.000000 ## sample estimates: ## p ## 0.25 Therefore because the p-value 0.25 > 0.05 we do not reject H0 and confirm that the proportion of North Yorkers that drink beer are different from the proportion of Canadian people drinking beer. 6. A firm draws a random sample of 18 ball bearings from the day’s output. The sample variance of their diameters is 0.009 inches (this question is worth 4 marks). 3
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
i. Construct a 95% confidence interval for the population variance. v = 0.009 n = 18 df = n -1 conf.level = 0.95 chilower = qchisq(( 1 -conf.level)/ 2 ,df) chiupper = qchisq(( 1 -conf.level)/ 2 ,df, lower.tail= FALSE) conf.interval = c(round(df*v/chiupper, 4 ),round(df*v/chilower, 4 )) conf.interval ## [1] 0.0051 0.0202 ii. Construct a 90% confidence interval for the population variance. v = 0.009 n = 18 df = n -1 conf.level = 0.90 chilower = qchisq(( 1 -conf.level)/ 2 ,df) chiupper = qchisq(( 1 -conf.level)/ 2 ,df, lower.tail= FALSE) conf.interval = c(round(df*v/chiupper, 4 ),round(df*v/chilower, 4 )) conf.interval ## [1] 0.0055 0.0176 iii. What assumptions underlie the answers in the first two parts of this question. The value of s 2 can be used as a point estimate of the population variance. The shape of the distribution depends on the degrees of freedom and as the number of degrees of freedom increases, the distribution becomes more symmetric. 7. In an agricultural experiment to determine the effects of a particular insecticide, a field was planted with corn. Half the plants were sprayed with the insecticide, and half were unsprayed. Several weeks later, independent random samples of 200 sprayed plants and 200 unsprayed plants were examined. The number of healthy plants in each sample was as follows (this question is worth 4 marks). Status Sprayed Unsprayed Healthy 131 111 Unhealthy 69 89 If the significance level is set at α = 0 . 05 , does the evidence indicate that a higher proportion of sprayed than of unsprayed plants were healthy? Use a one tailed Z test for equality of population proprtions (note - since the null is that the proportions are equal, use this information to construct a pooled estimate of the proportion). #Z = (P1-P2)/sqrt(P*(1-P)*((1/N1)+(1/N2))) #X1=131 #X2=111 4
#N1=200 #N2=200 #P= (X1+X2)/(N1+N2) #P= (131 + 111) /(200 + 200) #P= 0.6050 #P1=X1/N1 #P1=131/200 #P1=0.655 #P2=X2/N2 #P2=111/200 #P2=0.555 #Z=(0.655 - 0.555)/sqrt(0.605*(1 - 0.605)*((1/200)+(1/200))) #Z=2.0456 #P-value = 0.0204 (Found by using z-table) Therefore because the p-value 0.0204 < 0.05 we reject H0 and confirm that there is a higher portion of sprayed than unsprayed plants that are healthy. 8. The success of a federally funded, locally administered manpower program was measured by the propor- tion of clients who moved from subsidized employment into unsubsidized (private sector) employment and remained there for a certain length of time. A random sample of n = 376 clients of the program produced the following results (this question is worth 4 marks). Education Success Failure 8 years or less 13 19 9 to 11 years 76 45 12 years 107 65 13 years or more 32 19 i. Estimate the marginal probabilities of success and failure. Marginal Frequencies Table: Education Success Failure 8 years or less 13 19 9 to 11 years 76 45 12 years 107 65 13 years or more 32 19 Total 228 148 Marginal Probabilities Table: Education Success Failure 8 years or less 0.0346 0.0505 9 to 11 years 0.2021 0.1197 12 years 0.2846 0.1729 13 years or more 0.0851 0.0505 5
Education Success Failure Total 0.6064 0.3936 The marginal probability for success and the marginal probability for failure is 0.6064 and 0.3936 respectivley. ii. Test the hypothesis that the program outcomes are independent of educational level using a χ 2 test of independence. table <- matrix(c( 13 , 19 , 76 , 45 , 107 , 65 , 32 , 19 ), ncol= 2 , byrow= TRUE) colnames(table) <- c( "Success" , "Failure" ) rownames(table) <- c( "8 years or less" , "9 to 11 years" , "12 years" , "13 years or more" ) chisq.test(table) ## ## Pearson ' s Chi-squared test ## ## data: table ## X-squared = 5.8817, df = 3, p-value = 0.1175 Based on the given data there is no evidence that success is not independant of education. 6
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