class: center, middle, inverse, title-slide # Lab 03 ## Inference for Simple Linear Regression ### 01.30.20 --- class: center, middle # Welcome to lab! --- ## Agenda 1. Outline: Inference for Regression 2. Tips for collaborating in GitHub 3. Starting a new project & lab tips --- ### Confidence interval for `\(\beta_1\)` The confidence interval for the regression slope is .alert[ `$$\mathbf{\hat{\beta}_1 \pm t^* SE(\hat{\beta}_1)}$$` ] **Interpretation**: We are *C%* confident that for every one unit increase in `\(x\)`, `\(y\)` is predicted to *[increase/decrease]* on average by *LB* to *UB*. --- ### Outline of hypothesis Test for `\(\beta_1\)` **Hypotheses: ** `$$\begin{aligned}& H_0: \beta_1 = 0\\& H_a: \beta_1 \neq 0\end{aligned}$$` **Test Statistic:** `$$t = \frac{\hat{\beta}_1 - 0}{SE(\hat{\beta}_1)}$$` **p-value:** calculated calculated from a `\(t\)` distribution with `\(n-2\)` degrees of freedom `$$\text{p-value} = P(t \geq |\text{test statistic}|)$$` <br> **Conclusion:** reject/fail to reject `\(H_0\)` based on p-value --- ### Tips for collaborating via GitHub - Always pull first before you start working. - Knit, commit, and push often to minimize merge conflicts and/or to make merge conflicts easier to resolve. (More on merge conflicts next week) - If you find yourself in a situation that is difficult to resolve, ask questions as soon as possible, don't let it linger and get bigger. --- ## Lab Introduction - In today's lab, you will be analyzing data from the food menu at Starbucks. - The focus of the lab is to give you practice conducting statistical inference and prediction for simple linear regression. - This will also give you more practice establishing a team workflow by following the guided prompts throughout the lab. --- ## Starting a new project - Go to the course GitHub organization and find the **lab-03-slr-inf** repo that has your team name on it. - On GitHub, click on the green Clone or download button, select Use HTTPS (this might already be selected by default, and if it is, you’ll see the text Clone with HTTPS). Click on the clipboard icon to copy the repo URL. - Go to RStudio Cloud and into the course workspace. Create a New Project from Git Repo. You will need to click on the down arrow next to the New Project button to see this option. - Copy and paste the URL of your assignment repo into the dialog box and click OK. --- ## Configure Git - Type the following lines of code in the console in RStudio filling in your name and email address. ```r library(usethis) use_git_config(user.name="GITHUB USERNAME", user.email="your email") ``` --- ## Tips for Lab - Each group member should commit and push to GitHub at least once - It is good practice to name your R code chunks. Do not put spaces in the code chunk names. - Check the .md file on GitHub to make sure it has all of your work, including output and graphs.