## Inference on Regression|Hypothesis tests and Intervals {.build}

## Playbill
<div class="columns-2">
  ![playbill](http://www.reducedprinting.com/blog/wp-content/uploads/2011/11/playbill.jpg)

  - Promoter's rule of thumb: the best prediction for this weeks revenue is last 
  weeks.
  - $\hat{y} = x$.
  - Implies that $\beta_0 = 0$ and $\beta_1 = 1$.
  - Is this reasonable?
</div>


## Playbill

```{r}
playbill <- read.csv("playbill.csv")
plot(CurrentWeek ~ LastWeek, data = playbill, asp = 1)
abline(0, 1, col = "darkgreen")
```


## Hypothesis test for $\hat{\beta}_1$

Let's focus on the claim that the slope is 1.

\[ H_0: \beta_1^0 = 1 \\
H_A: \beta_1^0 \ne 1 \]

We know that

\[ T = \frac{\hat{\beta}_1 - \beta_1^0}{SE(\hat{\beta}_1)} \]

T will be t distributed with $n-2$ degrees of freedom and with $SE(\hat{\beta}_1)$
calculated the same as in the CI.


## Hypothesis test for $\hat{\beta}_1$

```{r}
m1 <- lm(CurrentWeek ~ LastWeek, data = playbill)
beta_1_null <- 1
beta_1_hat <- m1$coef[2]
SE_beta_1_hat <- summary(m1)$coef[2, 2]
t_stat <- (beta_1_hat - beta_1_null)/SE_beta_1_hat
n <- nrow(playbill)
pval <- pt(t_stat, df = n - 2) * 2
pval
```

Our p-value is `r pval`, which is more than the standard $\alpha = 0.05$, therefore
we have no reason to reject $H_0: \beta_1^0 = 1$.  The promoters rule looks fine
so far.


## Inference for $\hat{\beta}_0$

Often less interesting (but not always!).  You use the t-distribution again but
with a different $SE$.

```{r}
summary(m1)$coef
summary(m1)$coef[1, 2]
```


## Activity 4b

Additional questions:

8. Is zero in your confidence interval?

9. Conduct a hypothesis test that the slope is zero all the way through to the
interpretation of the p-value.

10. Does the conclusion of the hypothesis test agree or disagree with the inference
that you drew from the confidence interval.

