Sunday, October 11, 2020

Mod 7: Confidence Interval Estimation And introduction to Fundamentals of hypothesis testing

Mod-7.utf8


Set environment

#env <- c("dplyr")
#lapply(env, library, character.only = 1)


Part I


Confidence Interval estimation questions when the mean is known.

For CI using: \(\Large \bar{x} \ \pm z \ \frac{alpha}{2} \cdot \frac{\sigma}{sqrt(n)}\)

  1. A 95% Confidence Interval:

    \(\bar{x} = 85 \ ->\) xbar
    \(alpha = 0.05 \ ->\) alpha
    \(\sigma = 8 \ ->\) sd
    \(n = 64 \ ->\) n

    In R: xbar +- qnorm( alpha/2 ) * ( sd/sqrt(n) )
    Value 1 = 83.040036
    Value 2 = 86.959964

    The 95% CI is ( 83 , 87 ).

  2. A 99% Confidence Interval:

    \(\bar{x} = 125 \ ->\) xbar
    \(alpha = 0.01 \ ->\) alpha
    \(\sigma = 24 \ ->\) sd
    \(n = 36 \ ->\) n

    In R: xbar +- qnorm( alpha/2 ) * ( sd/sqrt(n) )
    Value 1 = 114.6966828
    Value 2 = 135.3033172

    The 99% CI is ( 114 , 136 ).

  3. The manager of a supply store wants to estimate the actual amount of paint contained in 1-gallon cans purchased from a nationally known manufacturer. It is known from the manufacturer’s specification sheet that standard deviation of the amount of paint is equal to 0.02 gallon. A Random sample of 50 cans is selected and the sample mean amount of paint per 1 gallon is 0.99 gallon.

    1. Set up a 99% Confidence Interval:

      \(\bar{x} = 0.99 \ ->\) xbar
      \(alpha = 0.01 \ ->\) alpha
      \(\sigma = 0.02 \ ->\) sd
      \(n = 50 \ ->\) n

      In R: xbar +- qnorm( alpha/2 ) * ( sd/sqrt(n) )
      Value 1 = 0.9827145
      Value 2 = 0.9972855
      The 99% CI is ( 0.983 , 0.997 ).

    1. The manager does not have the right to complain because the sample mean (0.99) is within the 99% confidence interval (0.983 - 0.997).


Part II


Confidence Interval estimation questions when the mean is unknown.

For CI using: \(\Large \bar{x} \ \pm z \ \frac{alpha}{2} \cdot \frac{\sigma}{sqrt(n)}\)

  1. A stationery store wants to estimate the mean retail value of greeting cards that has in its inventory. A random sample of 20 greeting cards indicates an average value of $1.67 and standard deviation of $0.32.

    1. Set up a 95% Confidence Interval assuming a normal distribution:

      \(\bar{x} = 1.67 \ ->\) xbar
      \(alpha = 0.05 \ ->\) alpha
      \(\sigma = 0.32 \ ->\) sd
      \(n = 20 \ ->\) n

      In R: xbar +- qnorm( alpha/2 ) * ( sd/sqrt(n) )
      Value 1 = 1.5297564
      Value 2 = 1.8102436

      The 95% CI is ( 1.03 , 2.31 ).

    1. Obtaining an estimate for the mean value of all greeting cards in the store’s inventory could be useful in estimating the anticipated revenue.


Part III


Determine sample size.

Using: \(\Large n = (\frac{ z \ \frac{alpha}{2} \cdot \sigma} E) ^2\)

In R: \(\Large n= (\frac{qnorm( alpha/2 ) \cdot \sigma}{E}) ^2\)

  1. If you want to be 95% confident of estimating the population mean to within a sampling error of ± 5 and standard deviation is assumed to be equal 15, what sample size is required?

\(alpha = 0.05 \ ->\) alpha
\(\sigma = 15 \ ->\) sd
\(E = 5 \ ->\) E

\(\Large n =\) 34.5731294
Sample size required is 35

Part IV


Hypothesis Statement.

Source: http://usatoday30.usatoday.com/news/health/2004-10-12-vioxx-cover_x.htm

Key verbiage from the article:

  • “…those who took Vioxx were more likely to suffer a heart attack or sudden cardiac death than those who took Celebrex, Vioxx’s main rival.”
  • “But there was no possibility that you could discern a heart attack due to Vioxx from a heart attack not due to Vioxx,” he says.

There appears to be conflicting information or the presence of confounding variables that requires a thorough analysis drug reactions/interactions.

Sample hypothesis to test:
Null: Taking Vioxx can increase risk of cardiac death.
Alternative: Taking Vioxx has no effect on risk of cardiac death.

GitHub

Related file(s) can be found at Git Me

No comments:

Post a Comment