#Homework 7 #Lucas Edgar
#8.16
install.packages("ISwR")
trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-x86_64/contrib/4.4/ISwR_2.0-10.tgz'
Content type 'application/x-gzip' length 213680 bytes (208 KB)
==================================================
downloaded 208 KB
The downloaded binary packages are in
/var/folders/cy/6qm92v_56cbfwppnzr3_j5r40000gn/T//Rtmp5hN7dd/downloaded_packages
# Load the ISwR package
library(ISwR)
# Perform the one-sample t-test by subtracting 120 from each observation
t.test(bp.obese$bp - 120)
One Sample t-test
data: bp.obese$bp - 120
t = 3.8986, df = 101, p-value = 0.0001743
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
3.44785 10.59137
sample estimates:
mean of x
7.019608
#because the p-value is less than 0.05, then that provides substantial evidence that the mean is not 120. The
#population is All Mexican American adults in the small California town.
#8.17
data("bp.obese")
# Count the number of 1s (obese)
num_obese <- sum(bp.obese$obese == 1)
n_total <- length(bp.obese$obese)
# Using same values as before
binom.test(num_obese, n_total, p = 0.5)
Exact binomial test
data: num_obese and n_total
number of successes = 0, number of trials = 102, p-value < 2.2e-16
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.00000000 0.03551933
sample estimates:
probability of success
0
#The natural null hypothesis is p=0.05
#There is evidence that the proportion of obese individuals in the population is different from 50%.
#8.18 #a.)
alpha <- 2 * (1 - pt(1.6, df = 19))
alpha
[1] 0.1260951
#b.)
qt(1 - 0.0025, df = 19) # Upper critical value
[1] 3.173725