# Lecture_29.knit
Author: Zheyuan Wu
Date: 2023-04-03

### Examples continued from last week

Example: Find the 95% confidence interval for the variance in temperature in New York in 1973

Use data continued from last chapter.

\[ S=10.01,n=10,S^2=10.01^2=100.20 \]

\[ \alpha=0.05,\alpha/2=0.025,df=n-1=9 \]

\[ \chi^2_{9,0.025}\approx19.023,\chi^2_{9,0.975}\approx 2.700 \]

    qchisq(0.975,9) # use 1-p instead of p

    ## [1] 19.02277

    qchisq(0.025,9)

    ## [1] 2.700389

\[ ({9\times 10.01^2\over 19.023},{9\times 10.01^2\over 2.7})=(47.41,334.00) \]

(47.41,334.00) is the estimation for \(\sigma^2\) (population variance)

Interpretation: We are 95% confident that the true temperature variance falls between 47.41 and 334.

Notes:

1. We can also obtain a \((1-\alpha)100\%\) confidence interval for the standard deviation

\[ \sqrt{(n-1)S^2\over \chi^2_{n-1,\alpha/2}}<\sigma<\sqrt{(n-1)S^2\over \chi^2_{n-1,1-\alpha/2}} \]

Example: Find the 95% confidence interval for the standard deviation in temperature in New York in 1973.

\[ (\sqrt{47,41},\sqrt{334})=(6.89,1828) \]

2. The confidence intervals for the variance and standard deviation only hold if the population had a normal distribution.

Even if n is large, we still need normality.

Review: Confidence Interval for Proportion:

- A \(100(1-\alpha)\%\) Confidence interval for \(\hat p\) is \(\hat p \pm z_{\alpha/2}\sqrt{\hat p (1-\hat p)/n}\)

Use z test for proportion, and mean when population variance is known

Use t test for mean when population variance is unknown

Use chi square test for variance