---
title: "Lab 7: Inference for Numerical Data"
author: "Your name"
format: html
editor: visual
editor_options:
  chunk_output_type: console
---

## North Carolina births

```{r}
library(dplyr)
library(ggplot2)

load(url(
  "https://raw.githubusercontent.com/GarciaRios/govt_3990/gh-pages/Labs/lab5/nc.RData"
))
```

```{r}
glimpse(nc)
```

## Exploratory analysis

```{r}
ggplot(nc, aes(x = habit, y = weight)) +
  geom_boxplot() +
  labs(
    x = "Mother's smoking status",
    y = "Birth weight (pounds)",
    title = "Birth weight by maternal smoking status"
  ) +
  theme_minimal()
```

```{r}
nc |>
  group_by(habit) |>
  summarise(
    mean_weight = mean(weight, na.rm = TRUE),
    sd_weight = sd(weight, na.rm = TRUE),
    n = sum(!is.na(weight))
  )
```

1. What are the cases in this data set? Approximately how many cases are in the sample?

> 

2. What does the boxplot suggest about the relationship between smoking status and birth weight?

> 

3. How do the average birth weights of the two groups compare?

> 

## Inference

```{r}
nc |>
  count(habit)
```

4. Are the conditions for comparing the two population means reasonably satisfied?

> 

5. Write the null and alternative hypotheses.

\[
H_0:
\]

\[
H_A:
\]

## Conduct the hypothesis test

```{r}
birthweight_test <- t.test(
  weight ~ habit,
  data = nc,
  alternative = "two.sided",
  conf.level = 0.95
)

birthweight_test
```

6. Record the two sample means, the test statistic, and the p-value.

> 

7. Using \(\alpha = 0.05\), reject or fail to reject the null hypothesis.

> 

8. Interpret the conclusion in context.

> 

## Confidence interval

9. Record the 95% confidence interval.

> 

10. Does the interval contain 0? Does this agree with the hypothesis test?

> 

11. Interpret the interval in context.

> 

## Policy interpretation

12. Name one or two possible confounding variables that could matter in the relationship between smoking status and birth weight.

> 

13. In 2--3 sentences, summarize what this analysis contributes to a policy discussion and what it does not establish.

> 

# Group analysis

Your instructor will assign your group one relationship to analyze.

## Group A
Smoking and pregnancy length: `weeks ~ habit`

## Group B
Maternal age and prenatal care: `visits ~ mature`

## Group C
Racial disparities in prenatal care: `visits ~ whitemom`

## Group D
Marital status and birth weight: `weight ~ marital`

## Group E
Maternal age and pregnancy weight gain: `gained ~ mature`

### 1. Visualization

```{r}

```

### 2. Descriptive statistics

```{r}

```

### 3. Hypotheses

\[
H_0:
\]

\[
H_A:
\]

### 4. Hypothesis test

```{r}

```

### 5. Results

**P-value:**

> 

**95% confidence interval:**

> 

**Conclusion:**

> 

### 6. Two-minute policy briefing

> **We examined...**

> 

> **We found...**

> 

> **The hypothesis test indicates...**

> 

> **For policy, this may matter because...**

> 

> **One important limitation is...**

> 

# On Your Own

Choose one numerical response variable and one two-category explanatory variable that your group did **not** analyze.

14. Write a research question.

> 

15. Create a visualization and calculate descriptive statistics.

```{r}

```

16. State \(H_0\) and \(H_A\).

\[
H_0:
\]

\[
H_A:
\]

17. Conduct the hypothesis test.

```{r}

```

18. Report the p-value and 95% confidence interval.

> 

19. Write a short conclusion in plain language. Include the direction of the difference, the inferential conclusion, what the confidence interval adds, and one limitation.

> 
