Advertisement
1StrangeGod

AppliedStatsLab8

May 17th, 2022 (edited)
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 2.17 KB | None | 0 0
  1. # Lab Class 08 (17-05-2022)
  2. # S Vijay Balaji (19BCE7571)
  3.  
  4. x1bar <- 74
  5. n1 <- 40
  6. sigma1 <- 8
  7. x2bar <- 78
  8. n2 <- 50
  9. sigma2 <- 7
  10. level <- 0.05
  11. # calculation of z
  12. z <- (x1bar - x2bar) / sqrt(((sigma1)^2 / n1) + ((sigma2)^2 / n2))
  13. print(z)
  14. pvalue <- 2 * pnorm(z, lower.tail = TRUE)
  15. print(pvalue)
  16. if (pvalue <= level) {
  17.     print("Null Hypothesis H0 is rejected")
  18. } else {
  19.     print("Null Hypothesis H0 is accepted")
  20. }
  21.  
  22. # Example 2: The research investigator is interested in studying wheather there is a significant difference
  23. # in the salaries of B.Tech grades in two metropolian cities.
  24. # A random sample of size 100 from kolkata yields an average income of Rs. 20,150. Another random sample of 60 from Delhi results in an average income of
  25. # Rs. 20,250. If the variance of both the populations are given as sigma square = Rs. 40,000 and sigma square 2 = Rs 32,400 respectively,
  26. # What is your conclusion?
  27.  
  28. x1bar <- 20150
  29. n1 <- 100
  30. sigma1 <- 40000
  31. x2bar <- 20250
  32. n2 <- 60
  33. sigma2 <- 32400
  34. level <- 0.05
  35. # calculation of z
  36. z <- (x1bar - x2bar) / sqrt(((sigma1)^2 / n1) + ((sigma2)^2 / n2))
  37. print(z)
  38. pvalue <- 2 * pnorm(z, lower.tail = TRUE)
  39. print(pvalue)
  40. if (pvalue <= level) {
  41.     print("Null Hypothesis H0 is rejected")
  42. } else {
  43.     print("Null Hypothesis H0 is accepted")
  44. }
  45.  
  46. # Example 3: A manufacturer claims that the average tensile strength of thread A exceeds the average tensile strength of thread B by at least 12 kgs.
  47. # To test this claim, 50 pieces of each type of thread were tested under similar conditions. Type A thread had an average tensile strength of 86.7 kgs with a
  48. # Standard devaiation of 6.28 kgs, while type B thread had an average tensile strength of 77.8 kilograms with a standard devation of 5.61 kgs.
  49. # Test the manufacturer's claim using a 0.05 level of significance.
  50.  
  51. x1bar <- 86.7
  52. n1 <- 50
  53. sigma1 <- 6.28
  54. x2bar <- 77.8
  55. n2 <- 50
  56. sigma2 <- 5.61
  57. level <- 0.05
  58. # calculation of z
  59. z <- (x1bar - x2bar) / sqrt(((sigma1)^2 / n1) + ((sigma2)^2 / n2))
  60. print(z)
  61. pvalue <- 2 * pnorm(z, lower.tail = TRUE)
  62. print(pvalue)
  63. if (pvalue <= level) {
  64.     print("Null Hypothesis H0 is rejected")
  65. } else {
  66.     print("Null Hypothesis H0 is accepted")
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement