hw2
challenge1
my name
dataset
ggplot2
Author

Megha joseph

Published

Invalid Date

Code
library(tidyverse)

knitr::opts_chunk$set(echo = TRUE)
library(readxl)
library(tidyverse)
library(ggplot2)
library(dplyr)

##QUESTION1

Code
procedure <- c('Bypass', 'Angiography')
samplesize <- c(539, 847)
meanwait <- c(19, 18)
standev <- c(10, 9)

surgdata <- data.frame(procedure, samplesize, meanwait, standev)

surgdata
    procedure samplesize meanwait standev
1      Bypass        539       19      10
2 Angiography        847       18       9

##QUESTION2

Code
prop.test(567, 1031, conf.level = .95)

    1-sample proportions test with continuity correction

data:  567 out of 1031, null probability 0.5
X-squared = 10.091, df = 1, p-value = 0.00149
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
 0.5189682 0.5805580
sample estimates:
        p 
0.5499515 

##QUESTION3

Code
stdevBooks <- (200-30)/4
margerrorBooks <- (10/2)
zBooks <- 1.96

stdevBooks^2 * (zBooks/margerrorBooks)^2
[1] 277.5556

##QUESTION4 ##A

Code
(410-500)/(90/sqrt(9))
[1] -3
Code
pt(-3, 8)*2 
[1] 0.01707168

##B

Code
 pt(-3, 8, lower.tail = TRUE)
[1] 0.008535841

##C

Code
 pt(-3, 8, lower.tail = FALSE)
[1] 0.9914642

##QUESTION5 ##A1

Code
 JonesT <- (519.5-500)/10
JonesT
[1] 1.95

##A2

Code
 JonesP <- pt(1.95, 999, lower.tail = FALSE)*2
JonesP
[1] 0.05145555

##A3

Code
SmithT <- (519.7-500)/10
SmithT
[1] 1.97

##A4

Code
SmithP <- pt(1.97, 999, lower.tail = FALSE)*2
SmithP
[1] 0.04911426

##B

With an α-level of .05, the p-values that both Jones (P=.051) and Smith (P=.049) found are very close to equivalent. Although Jones’ P-value is slightly greater than α=.05 and Smith’s P-value is slightly less than α=.05, the proximity of the results should yield the same conclusion. Both P-values provide moderate evidence to reject the null hypothesis and indicate that the mean is not equal to 500. If we were to technically interpret the P-values, then Jones’ test would fail to reject the null hypothesis, and Smith’s test would reject the null hypothesis.

##C

If we fail to report the P-value and simply state whether the P-value is less than/equal to or greater than the defined significance level of the test, one cannot determine the strength of the conclusion. For example, a P-value of .009 for a significance level of .05 provides much stronger evidence to reject the null than a P-value of .045, however both values allow for rejection of the null at the significance level .05. In the Jones/Smith example, reporting the results only as “P ≤ 0.05” versus “P > 0.05” will lead to different conclusions about very similar results (rejecting versus failing to reject the null).

##QUESTION6

Code
gas_taxes <- c(51.27, 47.43, 38.89, 41.95, 28.61, 41.29, 52.19, 49.48, 35.02, 48.13, 39.28, 54.41, 41.66, 30.28, 18.49, 38.72, 33.41, 45.02)
t.test(gas_taxes, mu = 18.4, conf.level = .95)

    One Sample t-test

data:  gas_taxes
t = 10.238, df = 17, p-value = 1.095e-08
alternative hypothesis: true mean is not equal to 18.4
95 percent confidence interval:
 36.23386 45.49169
sample estimates:
mean of x 
 40.86278