n <- 1259
p <- 0.48

n*p
## [1] 604.32
n*(1-p)
## [1] 654.68
ME <- sqrt(p*(1-p)/n)*1.96

p - ME
## [1] 0.4524028
p + ME
## [1] 0.5075972

It can be stated with 95% confidence that the proportion of Americans that support marijuana legalization is between 45.24% and 50.76%

\[1.96\times\sqrt{\frac{0.48(1-0.48)}{n}}=0.02, n\approx2398\] 2398 Americans would need to be survered.

pc <- 0.08
nc <- 11545
po <- 0.088
no <- 4691

CV <- 1.96

pc*nc
## [1] 923.6
(1-pc)*nc
## [1] 10621.4
po*no
## [1] 412.808
(1-po)*no
## [1] 4278.192
ME <- sqrt(pc*(1-pc)/nc + po*(1-po)/no)

pd <- po-pc

pd + ME
## [1] 0.01284598
pd - ME
## [1] 0.003154016

The sample is less than 10% of the population. We can assume an independence. np and n(1-p) are greater than 10. Thus, the conditions for inference are met.

It can me stated with with 95% confidence that the difference in percentage of Oregan residents vs California residents who are sleep deprived is between 0.3% and 1%.

.048*426
## [1] 20.448
found <- c(4, 16, 61, 345)
expected <- c(20.448, 62.622, 168.696, 174.234)

sum((found - expected)^2 / expected)
## [1] 284.0609

With a p-value so small we reject the null hypothesis. It can be stated with strong confidence that barking deer prefer to forage in certain habitats.

2607/50739
## [1] 0.05138059
48132/50739
## [1] 0.9486194
expected <- 6617*2607/50739
observed <- 373

(observed-expected)^2 / expected
## [1] 3.205914